babylon.d.ts 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427
  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(): 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. private _mainSoundTrack;
  1183. /**
  1184. * The list of sound tracks added to the scene
  1185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1186. */
  1187. soundTracks: SoundTrack[];
  1188. private _audioEnabled;
  1189. private _headphone;
  1190. /**
  1191. * Gets the main soundtrack associated with the scene
  1192. */
  1193. readonly mainSoundTrack: SoundTrack;
  1194. /**
  1195. * Gets or sets the VRExperienceHelper attached to the scene
  1196. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1197. * @ignorenaming
  1198. */
  1199. VRHelper: VRExperienceHelper;
  1200. private _engine;
  1201. private _totalVertices;
  1202. /** @hidden */
  1203. _activeIndices: PerfCounter;
  1204. /** @hidden */
  1205. _activeParticles: PerfCounter;
  1206. /** @hidden */
  1207. _activeBones: PerfCounter;
  1208. private _animationRatio;
  1209. private _animationTimeLast;
  1210. private _animationTime;
  1211. /**
  1212. * Gets or sets a general scale for animation speed
  1213. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1214. */
  1215. animationTimeScale: number;
  1216. /** @hidden */
  1217. _cachedMaterial: Nullable<Material>;
  1218. /** @hidden */
  1219. _cachedEffect: Nullable<Effect>;
  1220. /** @hidden */
  1221. _cachedVisibility: Nullable<number>;
  1222. private _renderId;
  1223. private _executeWhenReadyTimeoutId;
  1224. private _intermediateRendering;
  1225. private _viewUpdateFlag;
  1226. private _projectionUpdateFlag;
  1227. private _alternateViewUpdateFlag;
  1228. private _alternateProjectionUpdateFlag;
  1229. /** @hidden */
  1230. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1231. private _activeRequests;
  1232. private _pendingData;
  1233. private _isDisposed;
  1234. /**
  1235. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1236. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1237. */
  1238. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1239. private _activeMeshes;
  1240. private _processedMaterials;
  1241. private _renderTargets;
  1242. /** @hidden */
  1243. _activeParticleSystems: SmartArray<IParticleSystem>;
  1244. private _activeSkeletons;
  1245. private _softwareSkinnedMeshes;
  1246. private _renderingManager;
  1247. private _physicsEngine;
  1248. /** @hidden */
  1249. _activeAnimatables: Animatable[];
  1250. private _transformMatrix;
  1251. private _sceneUbo;
  1252. private _alternateSceneUbo;
  1253. private _pickWithRayInverseMatrix;
  1254. private _viewMatrix;
  1255. private _projectionMatrix;
  1256. private _alternateViewMatrix;
  1257. private _alternateProjectionMatrix;
  1258. private _alternateTransformMatrix;
  1259. private _useAlternateCameraConfiguration;
  1260. private _alternateRendering;
  1261. /** @hidden */
  1262. _forcedViewPosition: Nullable<Vector3>;
  1263. /** @hidden */
  1264. readonly _isAlternateRenderingEnabled: boolean;
  1265. private _frustumPlanes;
  1266. /**
  1267. * Gets the list of frustum planes (built from the active camera)
  1268. */
  1269. readonly frustumPlanes: Plane[];
  1270. /**
  1271. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1272. * This is useful if there are more lights that the maximum simulteanous authorized
  1273. */
  1274. requireLightSorting: boolean;
  1275. private _selectionOctree;
  1276. private _pointerOverMesh;
  1277. private _debugLayer;
  1278. private _pickedDownMesh;
  1279. private _pickedUpMesh;
  1280. private _externalData;
  1281. private _uid;
  1282. /**
  1283. * @hidden
  1284. * Backing store of defined scene components.
  1285. */
  1286. _components: ISceneComponent[];
  1287. /**
  1288. * @hidden
  1289. * Backing store of defined scene components.
  1290. */
  1291. _serializableComponents: ISceneSerializableComponent[];
  1292. /**
  1293. * List of components to register on the next registration step.
  1294. */
  1295. private _transientComponents;
  1296. /**
  1297. * Registers the transient components if needed.
  1298. */
  1299. private _registerTransientComponents;
  1300. /**
  1301. * @hidden
  1302. * Add a component to the scene.
  1303. * Note that the ccomponent could be registered on th next frame if this is called after
  1304. * the register component stage.
  1305. * @param component Defines the component to add to the scene
  1306. */
  1307. _addComponent(component: ISceneComponent): void;
  1308. /**
  1309. * @hidden
  1310. * Gets a component from the scene.
  1311. * @param name defines the name of the component to retrieve
  1312. * @returns the component or null if not present
  1313. */
  1314. _getComponent(name: string): Nullable<ISceneComponent>;
  1315. /**
  1316. * @hidden
  1317. * Defines the actions happening before camera updates.
  1318. */
  1319. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1320. /**
  1321. * @hidden
  1322. * Defines the actions happening before clear the canvas.
  1323. */
  1324. _beforeClearStage: 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 NAME_PROCEDURALTEXTURE: string;
  2555. static readonly NAME_SHADOWGENERATOR: string;
  2556. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2557. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2558. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2559. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2560. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2561. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2562. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2563. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2564. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2565. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2566. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2567. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2568. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2571. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2572. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2573. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2574. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2575. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2577. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2578. static readonly STEP_REBUILDGEOMETRY_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2579. static readonly STEP_POINTERMOVE_SPRITE: number;
  2580. static readonly STEP_POINTERDOWN_SPRITE: number;
  2581. static readonly STEP_POINTERUP_SPRITE: number;
  2582. }
  2583. /**
  2584. * This represents a scene component.
  2585. *
  2586. * This is used to decouple the dependency the scene is having on the different workloads like
  2587. * layers, post processes...
  2588. */
  2589. interface ISceneComponent {
  2590. /**
  2591. * The name of the component. Each component must have a unique name.
  2592. */
  2593. name: string;
  2594. /**
  2595. * The scene the component belongs to.
  2596. */
  2597. scene: Scene;
  2598. /**
  2599. * Register the component to one instance of a scene.
  2600. */
  2601. register(): void;
  2602. /**
  2603. * Rebuilds the elements related to this component in case of
  2604. * context lost for instance.
  2605. */
  2606. rebuild(): void;
  2607. /**
  2608. * Disposes the component and the associated ressources.
  2609. */
  2610. dispose(): void;
  2611. }
  2612. /**
  2613. * This represents a SERIALIZABLE scene component.
  2614. *
  2615. * This extends Scene Component to add Serialization methods on top.
  2616. */
  2617. interface ISceneSerializableComponent extends ISceneComponent {
  2618. /**
  2619. * Adds all the element from the container to the scene
  2620. * @param container the container holding the elements
  2621. */
  2622. addFromContainer(container: AbstractScene): void;
  2623. /**
  2624. * Removes all the elements in the container from the scene
  2625. * @param container contains the elements to remove
  2626. */
  2627. removeFromContainer(container: AbstractScene): void;
  2628. /**
  2629. * Serializes the component data to the specified json object
  2630. * @param serializationObject The object to serialize to
  2631. */
  2632. serialize(serializationObject: any): void;
  2633. }
  2634. /**
  2635. * Strong typing of a Mesh related stage step action
  2636. */
  2637. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2638. /**
  2639. * Strong typing of a Evaluate Sub Mesh related stage step action
  2640. */
  2641. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2642. /**
  2643. * Strong typing of a Active Mesh related stage step action
  2644. */
  2645. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2646. /**
  2647. * Strong typing of a Camera related stage step action
  2648. */
  2649. type CameraStageAction = (camera: Camera) => void;
  2650. /**
  2651. * Strong typing of a RenderingGroup related stage step action
  2652. */
  2653. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2654. /**
  2655. * Strong typing of a Mesh Render related stage step action
  2656. */
  2657. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2658. /**
  2659. * Strong typing of a simple stage step action
  2660. */
  2661. type SimpleStageAction = () => void;
  2662. /**
  2663. * Strong typing of a render target action.
  2664. */
  2665. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2666. /**
  2667. * Strong typing of a pointer move action.
  2668. */
  2669. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2670. /**
  2671. * Strong typing of a pointer up/down action.
  2672. */
  2673. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2674. /**
  2675. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2676. * @hidden
  2677. */
  2678. class Stage<T extends Function> extends Array<{
  2679. index: number;
  2680. component: ISceneComponent;
  2681. action: T;
  2682. }> {
  2683. /**
  2684. * Hide ctor from the rest of the world.
  2685. * @param items The items to add.
  2686. */
  2687. private constructor();
  2688. /**
  2689. * Creates a new Stage.
  2690. * @returns A new instance of a Stage
  2691. */
  2692. static Create<T extends Function>(): Stage<T>;
  2693. /**
  2694. * Registers a step in an ordered way in the targeted stage.
  2695. * @param index Defines the position to register the step in
  2696. * @param component Defines the component attached to the step
  2697. * @param action Defines the action to launch during the step
  2698. */
  2699. registerStep(index: number, component: ISceneComponent, action: T): void;
  2700. /**
  2701. * Clears all the steps from the stage.
  2702. */
  2703. clear(): void;
  2704. }
  2705. }
  2706. declare module BABYLON {
  2707. type Nullable<T> = T | null;
  2708. type float = number;
  2709. type double = number;
  2710. type int = number;
  2711. type FloatArray = number[] | Float32Array;
  2712. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2713. /**
  2714. * Alias for types that can be used by a Buffer or VertexBuffer.
  2715. */
  2716. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * The action to be carried out following a trigger
  2721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2722. */
  2723. class Action {
  2724. /** the trigger, with or without parameters, for the action */
  2725. triggerOptions: any;
  2726. /**
  2727. * Trigger for the action
  2728. */
  2729. trigger: number;
  2730. /**
  2731. * Internal only - manager for action
  2732. * @hidden
  2733. */
  2734. _actionManager: ActionManager;
  2735. private _nextActiveAction;
  2736. private _child;
  2737. private _condition?;
  2738. private _triggerParameter;
  2739. /**
  2740. * An event triggered prior to action being executed.
  2741. */
  2742. onBeforeExecuteObservable: Observable<Action>;
  2743. /**
  2744. * Creates a new Action
  2745. * @param triggerOptions the trigger, with or without parameters, for the action
  2746. * @param condition an optional determinant of action
  2747. */
  2748. constructor(
  2749. /** the trigger, with or without parameters, for the action */
  2750. triggerOptions: any, condition?: Condition);
  2751. /**
  2752. * Internal only
  2753. * @hidden
  2754. */
  2755. _prepare(): void;
  2756. /**
  2757. * Gets the trigger parameters
  2758. * @returns the trigger parameters
  2759. */
  2760. getTriggerParameter(): any;
  2761. /**
  2762. * Internal only - executes current action event
  2763. * @hidden
  2764. */
  2765. _executeCurrent(evt?: ActionEvent): void;
  2766. /**
  2767. * Execute placeholder for child classes
  2768. * @param evt optional action event
  2769. */
  2770. execute(evt?: ActionEvent): void;
  2771. /**
  2772. * Skips to next active action
  2773. */
  2774. skipToNextActiveAction(): void;
  2775. /**
  2776. * Adds action to chain of actions, may be a DoNothingAction
  2777. * @param action defines the next action to execute
  2778. * @returns The action passed in
  2779. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2780. */
  2781. then(action: Action): Action;
  2782. /**
  2783. * Internal only
  2784. * @hidden
  2785. */
  2786. _getProperty(propertyPath: string): string;
  2787. /**
  2788. * Internal only
  2789. * @hidden
  2790. */
  2791. _getEffectiveTarget(target: any, propertyPath: string): any;
  2792. /**
  2793. * Serialize placeholder for child classes
  2794. * @param parent of child
  2795. * @returns the serialized object
  2796. */
  2797. serialize(parent: any): any;
  2798. /**
  2799. * Internal only called by serialize
  2800. * @hidden
  2801. */
  2802. protected _serialize(serializedAction: any, parent?: any): any;
  2803. /**
  2804. * Internal only
  2805. * @hidden
  2806. */
  2807. static _SerializeValueAsString: (value: any) => string;
  2808. /**
  2809. * Internal only
  2810. * @hidden
  2811. */
  2812. static _GetTargetProperty: (target: Scene | Node) => {
  2813. name: string;
  2814. targetType: string;
  2815. value: string;
  2816. };
  2817. }
  2818. }
  2819. declare module BABYLON {
  2820. /**
  2821. * ActionEvent is the event being sent when an action is triggered.
  2822. */
  2823. class ActionEvent {
  2824. /** The mesh or sprite that triggered the action */
  2825. source: any;
  2826. /** The X mouse cursor position at the time of the event */
  2827. pointerX: number;
  2828. /** The Y mouse cursor position at the time of the event */
  2829. pointerY: number;
  2830. /** The mesh that is currently pointed at (can be null) */
  2831. meshUnderPointer: Nullable<AbstractMesh>;
  2832. /** the original (browser) event that triggered the ActionEvent */
  2833. sourceEvent?: any;
  2834. /** additional data for the event */
  2835. additionalData?: any;
  2836. /**
  2837. * Creates a new ActionEvent
  2838. * @param source The mesh or sprite that triggered the action
  2839. * @param pointerX The X mouse cursor position at the time of the event
  2840. * @param pointerY The Y mouse cursor position at the time of the event
  2841. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2842. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2843. * @param additionalData additional data for the event
  2844. */
  2845. constructor(
  2846. /** The mesh or sprite that triggered the action */
  2847. source: any,
  2848. /** The X mouse cursor position at the time of the event */
  2849. pointerX: number,
  2850. /** The Y mouse cursor position at the time of the event */
  2851. pointerY: number,
  2852. /** The mesh that is currently pointed at (can be null) */
  2853. meshUnderPointer: Nullable<AbstractMesh>,
  2854. /** the original (browser) event that triggered the ActionEvent */
  2855. sourceEvent?: any,
  2856. /** additional data for the event */
  2857. additionalData?: any);
  2858. /**
  2859. * Helper function to auto-create an ActionEvent from a source mesh.
  2860. * @param source The source mesh that triggered the event
  2861. * @param evt The original (browser) event
  2862. * @param additionalData additional data for the event
  2863. * @returns the new ActionEvent
  2864. */
  2865. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2866. /**
  2867. * Helper function to auto-create an ActionEvent from a source sprite
  2868. * @param source The source sprite that triggered the event
  2869. * @param scene Scene associated with the sprite
  2870. * @param evt The original (browser) event
  2871. * @param additionalData additional data for the event
  2872. * @returns the new ActionEvent
  2873. */
  2874. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2875. /**
  2876. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2877. * @param scene the scene where the event occurred
  2878. * @param evt The original (browser) event
  2879. * @returns the new ActionEvent
  2880. */
  2881. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2882. /**
  2883. * Helper function to auto-create an ActionEvent from a primitive
  2884. * @param prim defines the target primitive
  2885. * @param pointerPos defines the pointer position
  2886. * @param evt The original (browser) event
  2887. * @param additionalData additional data for the event
  2888. * @returns the new ActionEvent
  2889. */
  2890. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2891. }
  2892. /**
  2893. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2894. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2896. */
  2897. class ActionManager {
  2898. private static _NothingTrigger;
  2899. private static _OnPickTrigger;
  2900. private static _OnLeftPickTrigger;
  2901. private static _OnRightPickTrigger;
  2902. private static _OnCenterPickTrigger;
  2903. private static _OnPickDownTrigger;
  2904. private static _OnDoublePickTrigger;
  2905. private static _OnPickUpTrigger;
  2906. private static _OnLongPressTrigger;
  2907. private static _OnPointerOverTrigger;
  2908. private static _OnPointerOutTrigger;
  2909. private static _OnEveryFrameTrigger;
  2910. private static _OnIntersectionEnterTrigger;
  2911. private static _OnIntersectionExitTrigger;
  2912. private static _OnKeyDownTrigger;
  2913. private static _OnKeyUpTrigger;
  2914. private static _OnPickOutTrigger;
  2915. /**
  2916. * Nothing
  2917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2918. */
  2919. static readonly NothingTrigger: number;
  2920. /**
  2921. * On pick
  2922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2923. */
  2924. static readonly OnPickTrigger: number;
  2925. /**
  2926. * On left pick
  2927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2928. */
  2929. static readonly OnLeftPickTrigger: number;
  2930. /**
  2931. * On right pick
  2932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2933. */
  2934. static readonly OnRightPickTrigger: number;
  2935. /**
  2936. * On center pick
  2937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2938. */
  2939. static readonly OnCenterPickTrigger: number;
  2940. /**
  2941. * On pick down
  2942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2943. */
  2944. static readonly OnPickDownTrigger: number;
  2945. /**
  2946. * On double pick
  2947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2948. */
  2949. static readonly OnDoublePickTrigger: number;
  2950. /**
  2951. * On pick up
  2952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2953. */
  2954. static readonly OnPickUpTrigger: number;
  2955. /**
  2956. * On pick out.
  2957. * This trigger will only be raised if you also declared a OnPickDown
  2958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2959. */
  2960. static readonly OnPickOutTrigger: number;
  2961. /**
  2962. * On long press
  2963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2964. */
  2965. static readonly OnLongPressTrigger: number;
  2966. /**
  2967. * On pointer over
  2968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2969. */
  2970. static readonly OnPointerOverTrigger: number;
  2971. /**
  2972. * On pointer out
  2973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2974. */
  2975. static readonly OnPointerOutTrigger: number;
  2976. /**
  2977. * On every frame
  2978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2979. */
  2980. static readonly OnEveryFrameTrigger: number;
  2981. /**
  2982. * On intersection enter
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2984. */
  2985. static readonly OnIntersectionEnterTrigger: number;
  2986. /**
  2987. * On intersection exit
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly OnIntersectionExitTrigger: number;
  2991. /**
  2992. * On key down
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnKeyDownTrigger: number;
  2996. /**
  2997. * On key up
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnKeyUpTrigger: number;
  3001. /** Gets the list of active triggers */
  3002. static Triggers: {
  3003. [key: string]: number;
  3004. };
  3005. /** Gets the list of actions */
  3006. actions: Action[];
  3007. /** Gets the cursor to use when hovering items */
  3008. hoverCursor: string;
  3009. private _scene;
  3010. /**
  3011. * Creates a new action manager
  3012. * @param scene defines the hosting scene
  3013. */
  3014. constructor(scene: Scene);
  3015. /**
  3016. * Releases all associated resources
  3017. */
  3018. dispose(): void;
  3019. /**
  3020. * Gets hosting scene
  3021. * @returns the hosting scene
  3022. */
  3023. getScene(): Scene;
  3024. /**
  3025. * Does this action manager handles actions of any of the given triggers
  3026. * @param triggers defines the triggers to be tested
  3027. * @return a boolean indicating whether one (or more) of the triggers is handled
  3028. */
  3029. hasSpecificTriggers(triggers: number[]): boolean;
  3030. /**
  3031. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3032. * speed.
  3033. * @param triggerA defines the trigger to be tested
  3034. * @param triggerB defines the trigger to be tested
  3035. * @return a boolean indicating whether one (or more) of the triggers is handled
  3036. */
  3037. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3038. /**
  3039. * Does this action manager handles actions of a given trigger
  3040. * @param trigger defines the trigger to be tested
  3041. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3042. * @return whether the trigger is handled
  3043. */
  3044. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3045. /**
  3046. * Does this action manager has pointer triggers
  3047. */
  3048. readonly hasPointerTriggers: boolean;
  3049. /**
  3050. * Does this action manager has pick triggers
  3051. */
  3052. readonly hasPickTriggers: boolean;
  3053. /**
  3054. * Does exist one action manager with at least one trigger
  3055. **/
  3056. static readonly HasTriggers: boolean;
  3057. /**
  3058. * Does exist one action manager with at least one pick trigger
  3059. **/
  3060. static readonly HasPickTriggers: boolean;
  3061. /**
  3062. * Does exist one action manager that handles actions of a given trigger
  3063. * @param trigger defines the trigger to be tested
  3064. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3065. **/
  3066. static HasSpecificTrigger(trigger: number): boolean;
  3067. /**
  3068. * Registers an action to this action manager
  3069. * @param action defines the action to be registered
  3070. * @return the action amended (prepared) after registration
  3071. */
  3072. registerAction(action: Action): Nullable<Action>;
  3073. /**
  3074. * Unregisters an action to this action manager
  3075. * @param action defines the action to be unregistered
  3076. * @return a boolean indicating whether the action has been unregistered
  3077. */
  3078. unregisterAction(action: Action): Boolean;
  3079. /**
  3080. * Process a specific trigger
  3081. * @param trigger defines the trigger to process
  3082. * @param evt defines the event details to be processed
  3083. */
  3084. processTrigger(trigger: number, evt?: ActionEvent): void;
  3085. /** @hidden */
  3086. _getEffectiveTarget(target: any, propertyPath: string): any;
  3087. /** @hidden */
  3088. _getProperty(propertyPath: string): string;
  3089. /**
  3090. * Serialize this manager to a JSON object
  3091. * @param name defines the property name to store this manager
  3092. * @returns a JSON representation of this manager
  3093. */
  3094. serialize(name: string): any;
  3095. /**
  3096. * Creates a new ActionManager from a JSON data
  3097. * @param parsedActions defines the JSON data to read from
  3098. * @param object defines the hosting mesh
  3099. * @param scene defines the hosting scene
  3100. */
  3101. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3102. /**
  3103. * Get a trigger name by index
  3104. * @param trigger defines the trigger index
  3105. * @returns a trigger name
  3106. */
  3107. static GetTriggerName(trigger: number): string;
  3108. }
  3109. }
  3110. declare module BABYLON {
  3111. /**
  3112. * A Condition applied to an Action
  3113. */
  3114. class Condition {
  3115. /**
  3116. * Internal only - manager for action
  3117. * @hidden
  3118. */
  3119. _actionManager: ActionManager;
  3120. /**
  3121. * Internal only
  3122. * @hidden
  3123. */
  3124. _evaluationId: number;
  3125. /**
  3126. * Internal only
  3127. * @hidden
  3128. */
  3129. _currentResult: boolean;
  3130. /**
  3131. * Creates a new Condition
  3132. * @param actionManager the manager of the action the condition is applied to
  3133. */
  3134. constructor(actionManager: ActionManager);
  3135. /**
  3136. * Check if the current condition is valid
  3137. * @returns a boolean
  3138. */
  3139. isValid(): boolean;
  3140. /**
  3141. * Internal only
  3142. * @hidden
  3143. */
  3144. _getProperty(propertyPath: string): string;
  3145. /**
  3146. * Internal only
  3147. * @hidden
  3148. */
  3149. _getEffectiveTarget(target: any, propertyPath: string): any;
  3150. /**
  3151. * Serialize placeholder for child classes
  3152. * @returns the serialized object
  3153. */
  3154. serialize(): any;
  3155. /**
  3156. * Internal only
  3157. * @hidden
  3158. */
  3159. protected _serialize(serializedCondition: any): any;
  3160. }
  3161. /**
  3162. * Defines specific conditional operators as extensions of Condition
  3163. */
  3164. class ValueCondition extends Condition {
  3165. /** path to specify the property of the target the conditional operator uses */
  3166. propertyPath: string;
  3167. /** the value compared by the conditional operator against the current value of the property */
  3168. value: any;
  3169. /** the conditional operator, default ValueCondition.IsEqual */
  3170. operator: number;
  3171. /**
  3172. * Internal only
  3173. * @hidden
  3174. */
  3175. private static _IsEqual;
  3176. /**
  3177. * Internal only
  3178. * @hidden
  3179. */
  3180. private static _IsDifferent;
  3181. /**
  3182. * Internal only
  3183. * @hidden
  3184. */
  3185. private static _IsGreater;
  3186. /**
  3187. * Internal only
  3188. * @hidden
  3189. */
  3190. private static _IsLesser;
  3191. /**
  3192. * returns the number for IsEqual
  3193. */
  3194. static readonly IsEqual: number;
  3195. /**
  3196. * Returns the number for IsDifferent
  3197. */
  3198. static readonly IsDifferent: number;
  3199. /**
  3200. * Returns the number for IsGreater
  3201. */
  3202. static readonly IsGreater: number;
  3203. /**
  3204. * Returns the number for IsLesser
  3205. */
  3206. static readonly IsLesser: number;
  3207. /**
  3208. * Internal only The action manager for the condition
  3209. * @hidden
  3210. */
  3211. _actionManager: ActionManager;
  3212. /**
  3213. * Internal only
  3214. * @hidden
  3215. */
  3216. private _target;
  3217. /**
  3218. * Internal only
  3219. * @hidden
  3220. */
  3221. private _effectiveTarget;
  3222. /**
  3223. * Internal only
  3224. * @hidden
  3225. */
  3226. private _property;
  3227. /**
  3228. * Creates a new ValueCondition
  3229. * @param actionManager manager for the action the condition applies to
  3230. * @param target for the action
  3231. * @param propertyPath path to specify the property of the target the conditional operator uses
  3232. * @param value the value compared by the conditional operator against the current value of the property
  3233. * @param operator the conditional operator, default ValueCondition.IsEqual
  3234. */
  3235. constructor(actionManager: ActionManager, target: any,
  3236. /** path to specify the property of the target the conditional operator uses */
  3237. propertyPath: string,
  3238. /** the value compared by the conditional operator against the current value of the property */
  3239. value: any,
  3240. /** the conditional operator, default ValueCondition.IsEqual */
  3241. operator?: number);
  3242. /**
  3243. * Compares the given value with the property value for the specified conditional operator
  3244. * @returns the result of the comparison
  3245. */
  3246. isValid(): boolean;
  3247. /**
  3248. * Serialize the ValueCondition into a JSON compatible object
  3249. * @returns serialization object
  3250. */
  3251. serialize(): any;
  3252. /**
  3253. * Gets the name of the conditional operator for the ValueCondition
  3254. * @param operator the conditional operator
  3255. * @returns the name
  3256. */
  3257. static GetOperatorName(operator: number): string;
  3258. }
  3259. /**
  3260. * Defines a predicate condition as an extension of Condition
  3261. */
  3262. class PredicateCondition extends Condition {
  3263. /** defines the predicate function used to validate the condition */
  3264. predicate: () => boolean;
  3265. /**
  3266. * Internal only - manager for action
  3267. * @hidden
  3268. */
  3269. _actionManager: ActionManager;
  3270. /**
  3271. * Creates a new PredicateCondition
  3272. * @param actionManager manager for the action the condition applies to
  3273. * @param predicate defines the predicate function used to validate the condition
  3274. */
  3275. constructor(actionManager: ActionManager,
  3276. /** defines the predicate function used to validate the condition */
  3277. predicate: () => boolean);
  3278. /**
  3279. * @returns the validity of the predicate condition
  3280. */
  3281. isValid(): boolean;
  3282. }
  3283. /**
  3284. * Defines a state condition as an extension of Condition
  3285. */
  3286. class StateCondition extends Condition {
  3287. value: string;
  3288. /**
  3289. * Internal only - manager for action
  3290. * @hidden
  3291. */
  3292. _actionManager: ActionManager;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _target;
  3298. /**
  3299. * Creates a new StateCondition
  3300. * @param actionManager manager for the action the condition applies to
  3301. * @param target of the condition
  3302. * @param value to compare with target state
  3303. */
  3304. constructor(actionManager: ActionManager, target: any, value: string);
  3305. /**
  3306. * @returns the validity of the state
  3307. */
  3308. isValid(): boolean;
  3309. /**
  3310. * Serialize the StateCondition into a JSON compatible object
  3311. * @returns serialization object
  3312. */
  3313. serialize(): any;
  3314. }
  3315. }
  3316. declare module BABYLON {
  3317. class SwitchBooleanAction extends Action {
  3318. propertyPath: string;
  3319. private _target;
  3320. private _effectiveTarget;
  3321. private _property;
  3322. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3323. /** @hidden */
  3324. _prepare(): void;
  3325. execute(): void;
  3326. serialize(parent: any): any;
  3327. }
  3328. class SetStateAction extends Action {
  3329. value: string;
  3330. private _target;
  3331. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3332. execute(): void;
  3333. serialize(parent: any): any;
  3334. }
  3335. class SetValueAction extends Action {
  3336. propertyPath: string;
  3337. value: any;
  3338. private _target;
  3339. private _effectiveTarget;
  3340. private _property;
  3341. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3342. /** @hidden */
  3343. _prepare(): void;
  3344. execute(): void;
  3345. serialize(parent: any): any;
  3346. }
  3347. class IncrementValueAction extends Action {
  3348. propertyPath: string;
  3349. value: any;
  3350. private _target;
  3351. private _effectiveTarget;
  3352. private _property;
  3353. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3354. /** @hidden */
  3355. _prepare(): void;
  3356. execute(): void;
  3357. serialize(parent: any): any;
  3358. }
  3359. class PlayAnimationAction extends Action {
  3360. from: number;
  3361. to: number;
  3362. loop?: boolean | undefined;
  3363. private _target;
  3364. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3365. /** @hidden */
  3366. _prepare(): void;
  3367. execute(): void;
  3368. serialize(parent: any): any;
  3369. }
  3370. class StopAnimationAction extends Action {
  3371. private _target;
  3372. constructor(triggerOptions: any, target: any, condition?: Condition);
  3373. /** @hidden */
  3374. _prepare(): void;
  3375. execute(): void;
  3376. serialize(parent: any): any;
  3377. }
  3378. class DoNothingAction extends Action {
  3379. constructor(triggerOptions?: any, condition?: Condition);
  3380. execute(): void;
  3381. serialize(parent: any): any;
  3382. }
  3383. class CombineAction extends Action {
  3384. children: Action[];
  3385. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3386. /** @hidden */
  3387. _prepare(): void;
  3388. execute(evt: ActionEvent): void;
  3389. serialize(parent: any): any;
  3390. }
  3391. class ExecuteCodeAction extends Action {
  3392. func: (evt: ActionEvent) => void;
  3393. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3394. execute(evt: ActionEvent): void;
  3395. }
  3396. class SetParentAction extends Action {
  3397. private _parent;
  3398. private _target;
  3399. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3400. /** @hidden */
  3401. _prepare(): void;
  3402. execute(): void;
  3403. serialize(parent: any): any;
  3404. }
  3405. class PlaySoundAction extends Action {
  3406. private _sound;
  3407. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3408. /** @hidden */
  3409. _prepare(): void;
  3410. execute(): void;
  3411. serialize(parent: any): any;
  3412. }
  3413. class StopSoundAction extends Action {
  3414. private _sound;
  3415. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3416. /** @hidden */
  3417. _prepare(): void;
  3418. execute(): void;
  3419. serialize(parent: any): any;
  3420. }
  3421. }
  3422. declare module BABYLON {
  3423. class InterpolateValueAction extends Action {
  3424. propertyPath: string;
  3425. value: any;
  3426. duration: number;
  3427. stopOtherAnimations?: boolean | undefined;
  3428. onInterpolationDone?: (() => void) | undefined;
  3429. private _target;
  3430. private _effectiveTarget;
  3431. private _property;
  3432. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3433. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3434. /** @hidden */
  3435. _prepare(): void;
  3436. execute(): void;
  3437. serialize(parent: any): any;
  3438. }
  3439. }
  3440. declare module BABYLON {
  3441. /**
  3442. * Class used to store an actual running animation
  3443. */
  3444. class Animatable {
  3445. /** defines the target object */
  3446. target: any;
  3447. /** defines the starting frame number (default is 0) */
  3448. fromFrame: number;
  3449. /** defines the ending frame number (default is 100) */
  3450. toFrame: number;
  3451. /** defines if the animation must loop (default is false) */
  3452. loopAnimation: boolean;
  3453. /** defines a callback to call when animation ends if it is not looping */
  3454. onAnimationEnd?: (() => void) | null | undefined;
  3455. private _localDelayOffset;
  3456. private _pausedDelay;
  3457. private _runtimeAnimations;
  3458. private _paused;
  3459. private _scene;
  3460. private _speedRatio;
  3461. private _weight;
  3462. private _syncRoot;
  3463. /**
  3464. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3465. * This will only apply for non looping animation (default is true)
  3466. */
  3467. disposeOnEnd: boolean;
  3468. /**
  3469. * Gets a boolean indicating if the animation has started
  3470. */
  3471. animationStarted: boolean;
  3472. /**
  3473. * Observer raised when the animation ends
  3474. */
  3475. onAnimationEndObservable: Observable<Animatable>;
  3476. /**
  3477. * Gets the root Animatable used to synchronize and normalize animations
  3478. */
  3479. readonly syncRoot: Animatable;
  3480. /**
  3481. * Gets the current frame of the first RuntimeAnimation
  3482. * Used to synchronize Animatables
  3483. */
  3484. readonly masterFrame: number;
  3485. /**
  3486. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3487. */
  3488. weight: number;
  3489. /**
  3490. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3491. */
  3492. speedRatio: number;
  3493. /**
  3494. * Creates a new Animatable
  3495. * @param scene defines the hosting scene
  3496. * @param target defines the target object
  3497. * @param fromFrame defines the starting frame number (default is 0)
  3498. * @param toFrame defines the ending frame number (default is 100)
  3499. * @param loopAnimation defines if the animation must loop (default is false)
  3500. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3501. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3502. * @param animations defines a group of animation to add to the new Animatable
  3503. */
  3504. constructor(scene: Scene,
  3505. /** defines the target object */
  3506. target: any,
  3507. /** defines the starting frame number (default is 0) */
  3508. fromFrame?: number,
  3509. /** defines the ending frame number (default is 100) */
  3510. toFrame?: number,
  3511. /** defines if the animation must loop (default is false) */
  3512. loopAnimation?: boolean, speedRatio?: number,
  3513. /** defines a callback to call when animation ends if it is not looping */
  3514. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3515. /**
  3516. * Synchronize and normalize current Animatable with a source Animatable
  3517. * This is useful when using animation weights and when animations are not of the same length
  3518. * @param root defines the root Animatable to synchronize with
  3519. * @returns the current Animatable
  3520. */
  3521. syncWith(root: Animatable): Animatable;
  3522. /**
  3523. * Gets the list of runtime animations
  3524. * @returns an array of RuntimeAnimation
  3525. */
  3526. getAnimations(): RuntimeAnimation[];
  3527. /**
  3528. * Adds more animations to the current animatable
  3529. * @param target defines the target of the animations
  3530. * @param animations defines the new animations to add
  3531. */
  3532. appendAnimations(target: any, animations: Animation[]): void;
  3533. /**
  3534. * Gets the source animation for a specific property
  3535. * @param property defines the propertyu to look for
  3536. * @returns null or the source animation for the given property
  3537. */
  3538. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3539. /**
  3540. * Gets the runtime animation for a specific property
  3541. * @param property defines the propertyu to look for
  3542. * @returns null or the runtime animation for the given property
  3543. */
  3544. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3545. /**
  3546. * Resets the animatable to its original state
  3547. */
  3548. reset(): void;
  3549. /**
  3550. * Allows the animatable to blend with current running animations
  3551. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3552. * @param blendingSpeed defines the blending speed to use
  3553. */
  3554. enableBlending(blendingSpeed: number): void;
  3555. /**
  3556. * Disable animation blending
  3557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3558. */
  3559. disableBlending(): void;
  3560. /**
  3561. * Jump directly to a given frame
  3562. * @param frame defines the frame to jump to
  3563. */
  3564. goToFrame(frame: number): void;
  3565. /**
  3566. * Pause the animation
  3567. */
  3568. pause(): void;
  3569. /**
  3570. * Restart the animation
  3571. */
  3572. restart(): void;
  3573. private _raiseOnAnimationEnd;
  3574. /**
  3575. * Stop and delete the current animation
  3576. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3577. * @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)
  3578. */
  3579. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3580. /**
  3581. * Wait asynchronously for the animation to end
  3582. * @returns a promise which will be fullfilled when the animation ends
  3583. */
  3584. waitAsync(): Promise<Animatable>;
  3585. /** @hidden */
  3586. _animate(delay: number): boolean;
  3587. }
  3588. }
  3589. declare module BABYLON {
  3590. /**
  3591. * Represents the range of an animation
  3592. */
  3593. class AnimationRange {
  3594. /**The name of the animation range**/
  3595. name: string;
  3596. /**The starting frame of the animation */
  3597. from: number;
  3598. /**The ending frame of the animation*/
  3599. to: number;
  3600. /**
  3601. * Initializes the range of an animation
  3602. * @param name The name of the animation range
  3603. * @param from The starting frame of the animation
  3604. * @param to The ending frame of the animation
  3605. */
  3606. constructor(
  3607. /**The name of the animation range**/
  3608. name: string,
  3609. /**The starting frame of the animation */
  3610. from: number,
  3611. /**The ending frame of the animation*/
  3612. to: number);
  3613. /**
  3614. * Makes a copy of the animation range
  3615. * @returns A copy of the animation range
  3616. */
  3617. clone(): AnimationRange;
  3618. }
  3619. /**
  3620. * Composed of a frame, and an action function
  3621. */
  3622. class AnimationEvent {
  3623. /** The frame for which the event is triggered **/
  3624. frame: number;
  3625. /** The event to perform when triggered **/
  3626. action: (currentFrame: number) => void;
  3627. /** Specifies if the event should be triggered only once**/
  3628. onlyOnce?: boolean | undefined;
  3629. /**
  3630. * Specifies if the animation event is done
  3631. */
  3632. isDone: boolean;
  3633. /**
  3634. * Initializes the animation event
  3635. * @param frame The frame for which the event is triggered
  3636. * @param action The event to perform when triggered
  3637. * @param onlyOnce Specifies if the event should be triggered only once
  3638. */
  3639. constructor(
  3640. /** The frame for which the event is triggered **/
  3641. frame: number,
  3642. /** The event to perform when triggered **/
  3643. action: (currentFrame: number) => void,
  3644. /** Specifies if the event should be triggered only once**/
  3645. onlyOnce?: boolean | undefined);
  3646. /** @hidden */
  3647. _clone(): AnimationEvent;
  3648. }
  3649. /**
  3650. * A cursor which tracks a point on a path
  3651. */
  3652. class PathCursor {
  3653. private path;
  3654. /**
  3655. * Stores path cursor callbacks for when an onchange event is triggered
  3656. */
  3657. private _onchange;
  3658. /**
  3659. * The value of the path cursor
  3660. */
  3661. value: number;
  3662. /**
  3663. * The animation array of the path cursor
  3664. */
  3665. animations: Animation[];
  3666. /**
  3667. * Initializes the path cursor
  3668. * @param path The path to track
  3669. */
  3670. constructor(path: Path2);
  3671. /**
  3672. * Gets the cursor point on the path
  3673. * @returns A point on the path cursor at the cursor location
  3674. */
  3675. getPoint(): Vector3;
  3676. /**
  3677. * Moves the cursor ahead by the step amount
  3678. * @param step The amount to move the cursor forward
  3679. * @returns This path cursor
  3680. */
  3681. moveAhead(step?: number): PathCursor;
  3682. /**
  3683. * Moves the cursor behind by the step amount
  3684. * @param step The amount to move the cursor back
  3685. * @returns This path cursor
  3686. */
  3687. moveBack(step?: number): PathCursor;
  3688. /**
  3689. * Moves the cursor by the step amount
  3690. * If the step amount is greater than one, an exception is thrown
  3691. * @param step The amount to move the cursor
  3692. * @returns This path cursor
  3693. */
  3694. move(step: number): PathCursor;
  3695. /**
  3696. * Ensures that the value is limited between zero and one
  3697. * @returns This path cursor
  3698. */
  3699. private ensureLimits;
  3700. /**
  3701. * Runs onchange callbacks on change (used by the animation engine)
  3702. * @returns This path cursor
  3703. */
  3704. private raiseOnChange;
  3705. /**
  3706. * Executes a function on change
  3707. * @param f A path cursor onchange callback
  3708. * @returns This path cursor
  3709. */
  3710. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3711. }
  3712. /**
  3713. * Defines an interface which represents an animation key frame
  3714. */
  3715. interface IAnimationKey {
  3716. /**
  3717. * Frame of the key frame
  3718. */
  3719. frame: number;
  3720. /**
  3721. * Value at the specifies key frame
  3722. */
  3723. value: any;
  3724. /**
  3725. * The input tangent for the cubic hermite spline
  3726. */
  3727. inTangent?: any;
  3728. /**
  3729. * The output tangent for the cubic hermite spline
  3730. */
  3731. outTangent?: any;
  3732. /**
  3733. * The animation interpolation type
  3734. */
  3735. interpolation?: AnimationKeyInterpolation;
  3736. }
  3737. /**
  3738. * Enum for the animation key frame interpolation type
  3739. */
  3740. enum AnimationKeyInterpolation {
  3741. /**
  3742. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3743. */
  3744. STEP = 1
  3745. }
  3746. /**
  3747. * Class used to store any kind of animation
  3748. */
  3749. class Animation {
  3750. /**Name of the animation */
  3751. name: string;
  3752. /**Property to animate */
  3753. targetProperty: string;
  3754. /**The frames per second of the animation */
  3755. framePerSecond: number;
  3756. /**The data type of the animation */
  3757. dataType: number;
  3758. /**The loop mode of the animation */
  3759. loopMode?: number | undefined;
  3760. /**Specifies if blending should be enabled */
  3761. enableBlending?: boolean | undefined;
  3762. /**
  3763. * Use matrix interpolation instead of using direct key value when animating matrices
  3764. */
  3765. static AllowMatricesInterpolation: boolean;
  3766. /**
  3767. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3768. */
  3769. static AllowMatrixDecomposeForInterpolation: boolean;
  3770. /**
  3771. * Stores the key frames of the animation
  3772. */
  3773. private _keys;
  3774. /**
  3775. * Stores the easing function of the animation
  3776. */
  3777. private _easingFunction;
  3778. /**
  3779. * @hidden Internal use only
  3780. */
  3781. _runtimeAnimations: RuntimeAnimation[];
  3782. /**
  3783. * The set of event that will be linked to this animation
  3784. */
  3785. private _events;
  3786. /**
  3787. * Stores an array of target property paths
  3788. */
  3789. targetPropertyPath: string[];
  3790. /**
  3791. * Stores the blending speed of the animation
  3792. */
  3793. blendingSpeed: number;
  3794. /**
  3795. * Stores the animation ranges for the animation
  3796. */
  3797. private _ranges;
  3798. /**
  3799. * @hidden Internal use
  3800. */
  3801. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3802. /**
  3803. * Sets up an animation
  3804. * @param property The property to animate
  3805. * @param animationType The animation type to apply
  3806. * @param framePerSecond The frames per second of the animation
  3807. * @param easingFunction The easing function used in the animation
  3808. * @returns The created animation
  3809. */
  3810. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3811. /**
  3812. * Create and start an animation on a node
  3813. * @param name defines the name of the global animation that will be run on all nodes
  3814. * @param node defines the root node where the animation will take place
  3815. * @param targetProperty defines property to animate
  3816. * @param framePerSecond defines the number of frame per second yo use
  3817. * @param totalFrame defines the number of frames in total
  3818. * @param from defines the initial value
  3819. * @param to defines the final value
  3820. * @param loopMode defines which loop mode you want to use (off by default)
  3821. * @param easingFunction defines the easing function to use (linear by default)
  3822. * @param onAnimationEnd defines the callback to call when animation end
  3823. * @returns the animatable created for this animation
  3824. */
  3825. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3826. /**
  3827. * Create and start an animation on a node and its descendants
  3828. * @param name defines the name of the global animation that will be run on all nodes
  3829. * @param node defines the root node where the animation will take place
  3830. * @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
  3831. * @param targetProperty defines property to animate
  3832. * @param framePerSecond defines the number of frame per second to use
  3833. * @param totalFrame defines the number of frames in total
  3834. * @param from defines the initial value
  3835. * @param to defines the final value
  3836. * @param loopMode defines which loop mode you want to use (off by default)
  3837. * @param easingFunction defines the easing function to use (linear by default)
  3838. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3839. * @returns the list of animatables created for all nodes
  3840. * @example https://www.babylonjs-playground.com/#MH0VLI
  3841. */
  3842. 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[]>;
  3843. /**
  3844. * Creates a new animation, merges it with the existing animations and starts it
  3845. * @param name Name of the animation
  3846. * @param node Node which contains the scene that begins the animations
  3847. * @param targetProperty Specifies which property to animate
  3848. * @param framePerSecond The frames per second of the animation
  3849. * @param totalFrame The total number of frames
  3850. * @param from The frame at the beginning of the animation
  3851. * @param to The frame at the end of the animation
  3852. * @param loopMode Specifies the loop mode of the animation
  3853. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3854. * @param onAnimationEnd Callback to run once the animation is complete
  3855. * @returns Nullable animation
  3856. */
  3857. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3858. /**
  3859. * Transition property of an host to the target Value
  3860. * @param property The property to transition
  3861. * @param targetValue The target Value of the property
  3862. * @param host The object where the property to animate belongs
  3863. * @param scene Scene used to run the animation
  3864. * @param frameRate Framerate (in frame/s) to use
  3865. * @param transition The transition type we want to use
  3866. * @param duration The duration of the animation, in milliseconds
  3867. * @param onAnimationEnd Callback trigger at the end of the animation
  3868. * @returns Nullable animation
  3869. */
  3870. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3871. /**
  3872. * Return the array of runtime animations currently using this animation
  3873. */
  3874. readonly runtimeAnimations: RuntimeAnimation[];
  3875. /**
  3876. * Specifies if any of the runtime animations are currently running
  3877. */
  3878. readonly hasRunningRuntimeAnimations: boolean;
  3879. /**
  3880. * Initializes the animation
  3881. * @param name Name of the animation
  3882. * @param targetProperty Property to animate
  3883. * @param framePerSecond The frames per second of the animation
  3884. * @param dataType The data type of the animation
  3885. * @param loopMode The loop mode of the animation
  3886. * @param enableBlendings Specifies if blending should be enabled
  3887. */
  3888. constructor(
  3889. /**Name of the animation */
  3890. name: string,
  3891. /**Property to animate */
  3892. targetProperty: string,
  3893. /**The frames per second of the animation */
  3894. framePerSecond: number,
  3895. /**The data type of the animation */
  3896. dataType: number,
  3897. /**The loop mode of the animation */
  3898. loopMode?: number | undefined,
  3899. /**Specifies if blending should be enabled */
  3900. enableBlending?: boolean | undefined);
  3901. /**
  3902. * Converts the animation to a string
  3903. * @param fullDetails support for multiple levels of logging within scene loading
  3904. * @returns String form of the animation
  3905. */
  3906. toString(fullDetails?: boolean): string;
  3907. /**
  3908. * Add an event to this animation
  3909. * @param event Event to add
  3910. */
  3911. addEvent(event: AnimationEvent): void;
  3912. /**
  3913. * Remove all events found at the given frame
  3914. * @param frame The frame to remove events from
  3915. */
  3916. removeEvents(frame: number): void;
  3917. /**
  3918. * Retrieves all the events from the animation
  3919. * @returns Events from the animation
  3920. */
  3921. getEvents(): AnimationEvent[];
  3922. /**
  3923. * Creates an animation range
  3924. * @param name Name of the animation range
  3925. * @param from Starting frame of the animation range
  3926. * @param to Ending frame of the animation
  3927. */
  3928. createRange(name: string, from: number, to: number): void;
  3929. /**
  3930. * Deletes an animation range by name
  3931. * @param name Name of the animation range to delete
  3932. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3933. */
  3934. deleteRange(name: string, deleteFrames?: boolean): void;
  3935. /**
  3936. * Gets the animation range by name, or null if not defined
  3937. * @param name Name of the animation range
  3938. * @returns Nullable animation range
  3939. */
  3940. getRange(name: string): Nullable<AnimationRange>;
  3941. /**
  3942. * Gets the key frames from the animation
  3943. * @returns The key frames of the animation
  3944. */
  3945. getKeys(): Array<IAnimationKey>;
  3946. /**
  3947. * Gets the highest frame rate of the animation
  3948. * @returns Highest frame rate of the animation
  3949. */
  3950. getHighestFrame(): number;
  3951. /**
  3952. * Gets the easing function of the animation
  3953. * @returns Easing function of the animation
  3954. */
  3955. getEasingFunction(): IEasingFunction;
  3956. /**
  3957. * Sets the easing function of the animation
  3958. * @param easingFunction A custom mathematical formula for animation
  3959. */
  3960. setEasingFunction(easingFunction: EasingFunction): void;
  3961. /**
  3962. * Interpolates a scalar linearly
  3963. * @param startValue Start value of the animation curve
  3964. * @param endValue End value of the animation curve
  3965. * @param gradient Scalar amount to interpolate
  3966. * @returns Interpolated scalar value
  3967. */
  3968. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3969. /**
  3970. * Interpolates a scalar cubically
  3971. * @param startValue Start value of the animation curve
  3972. * @param outTangent End tangent of the animation
  3973. * @param endValue End value of the animation curve
  3974. * @param inTangent Start tangent of the animation curve
  3975. * @param gradient Scalar amount to interpolate
  3976. * @returns Interpolated scalar value
  3977. */
  3978. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3979. /**
  3980. * Interpolates a quaternion using a spherical linear interpolation
  3981. * @param startValue Start value of the animation curve
  3982. * @param endValue End value of the animation curve
  3983. * @param gradient Scalar amount to interpolate
  3984. * @returns Interpolated quaternion value
  3985. */
  3986. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3987. /**
  3988. * Interpolates a quaternion cubically
  3989. * @param startValue Start value of the animation curve
  3990. * @param outTangent End tangent of the animation curve
  3991. * @param endValue End value of the animation curve
  3992. * @param inTangent Start tangent of the animation curve
  3993. * @param gradient Scalar amount to interpolate
  3994. * @returns Interpolated quaternion value
  3995. */
  3996. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3997. /**
  3998. * Interpolates a Vector3 linearl
  3999. * @param startValue Start value of the animation curve
  4000. * @param endValue End value of the animation curve
  4001. * @param gradient Scalar amount to interpolate
  4002. * @returns Interpolated scalar value
  4003. */
  4004. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4005. /**
  4006. * Interpolates a Vector3 cubically
  4007. * @param startValue Start value of the animation curve
  4008. * @param outTangent End tangent of the animation
  4009. * @param endValue End value of the animation curve
  4010. * @param inTangent Start tangent of the animation curve
  4011. * @param gradient Scalar amount to interpolate
  4012. * @returns InterpolatedVector3 value
  4013. */
  4014. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4015. /**
  4016. * Interpolates a Vector2 linearly
  4017. * @param startValue Start value of the animation curve
  4018. * @param endValue End value of the animation curve
  4019. * @param gradient Scalar amount to interpolate
  4020. * @returns Interpolated Vector2 value
  4021. */
  4022. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4023. /**
  4024. * Interpolates a Vector2 cubically
  4025. * @param startValue Start value of the animation curve
  4026. * @param outTangent End tangent of the animation
  4027. * @param endValue End value of the animation curve
  4028. * @param inTangent Start tangent of the animation curve
  4029. * @param gradient Scalar amount to interpolate
  4030. * @returns Interpolated Vector2 value
  4031. */
  4032. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4033. /**
  4034. * Interpolates a size linearly
  4035. * @param startValue Start value of the animation curve
  4036. * @param endValue End value of the animation curve
  4037. * @param gradient Scalar amount to interpolate
  4038. * @returns Interpolated Size value
  4039. */
  4040. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4041. /**
  4042. * Interpolates a Color3 linearly
  4043. * @param startValue Start value of the animation curve
  4044. * @param endValue End value of the animation curve
  4045. * @param gradient Scalar amount to interpolate
  4046. * @returns Interpolated Color3 value
  4047. */
  4048. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4049. /**
  4050. * @hidden Internal use only
  4051. */
  4052. _getKeyValue(value: any): any;
  4053. /**
  4054. * @hidden Internal use only
  4055. */
  4056. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4057. /**
  4058. * Defines the function to use to interpolate matrices
  4059. * @param startValue defines the start matrix
  4060. * @param endValue defines the end matrix
  4061. * @param gradient defines the gradient between both matrices
  4062. * @param result defines an optional target matrix where to store the interpolation
  4063. * @returns the interpolated matrix
  4064. */
  4065. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4066. /**
  4067. * Makes a copy of the animation
  4068. * @returns Cloned animation
  4069. */
  4070. clone(): Animation;
  4071. /**
  4072. * Sets the key frames of the animation
  4073. * @param values The animation key frames to set
  4074. */
  4075. setKeys(values: Array<IAnimationKey>): void;
  4076. /**
  4077. * Serializes the animation to an object
  4078. * @returns Serialized object
  4079. */
  4080. serialize(): any;
  4081. /**
  4082. * Float animation type
  4083. */
  4084. private static _ANIMATIONTYPE_FLOAT;
  4085. /**
  4086. * Vector3 animation type
  4087. */
  4088. private static _ANIMATIONTYPE_VECTOR3;
  4089. /**
  4090. * Quaternion animation type
  4091. */
  4092. private static _ANIMATIONTYPE_QUATERNION;
  4093. /**
  4094. * Matrix animation type
  4095. */
  4096. private static _ANIMATIONTYPE_MATRIX;
  4097. /**
  4098. * Color3 animation type
  4099. */
  4100. private static _ANIMATIONTYPE_COLOR3;
  4101. /**
  4102. * Vector2 animation type
  4103. */
  4104. private static _ANIMATIONTYPE_VECTOR2;
  4105. /**
  4106. * Size animation type
  4107. */
  4108. private static _ANIMATIONTYPE_SIZE;
  4109. /**
  4110. * Relative Loop Mode
  4111. */
  4112. private static _ANIMATIONLOOPMODE_RELATIVE;
  4113. /**
  4114. * Cycle Loop Mode
  4115. */
  4116. private static _ANIMATIONLOOPMODE_CYCLE;
  4117. /**
  4118. * Constant Loop Mode
  4119. */
  4120. private static _ANIMATIONLOOPMODE_CONSTANT;
  4121. /**
  4122. * Get the float animation type
  4123. */
  4124. static readonly ANIMATIONTYPE_FLOAT: number;
  4125. /**
  4126. * Get the Vector3 animation type
  4127. */
  4128. static readonly ANIMATIONTYPE_VECTOR3: number;
  4129. /**
  4130. * Get the Vector2 animation type
  4131. */
  4132. static readonly ANIMATIONTYPE_VECTOR2: number;
  4133. /**
  4134. * Get the Size animation type
  4135. */
  4136. static readonly ANIMATIONTYPE_SIZE: number;
  4137. /**
  4138. * Get the Quaternion animation type
  4139. */
  4140. static readonly ANIMATIONTYPE_QUATERNION: number;
  4141. /**
  4142. * Get the Matrix animation type
  4143. */
  4144. static readonly ANIMATIONTYPE_MATRIX: number;
  4145. /**
  4146. * Get the Color3 animation type
  4147. */
  4148. static readonly ANIMATIONTYPE_COLOR3: number;
  4149. /**
  4150. * Get the Relative Loop Mode
  4151. */
  4152. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4153. /**
  4154. * Get the Cycle Loop Mode
  4155. */
  4156. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4157. /**
  4158. * Get the Constant Loop Mode
  4159. */
  4160. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4161. /** @hidden */
  4162. static _UniversalLerp(left: any, right: any, amount: number): any;
  4163. /**
  4164. * Parses an animation object and creates an animation
  4165. * @param parsedAnimation Parsed animation object
  4166. * @returns Animation object
  4167. */
  4168. static Parse(parsedAnimation: any): Animation;
  4169. /**
  4170. * Appends the serialized animations from the source animations
  4171. * @param source Source containing the animations
  4172. * @param destination Target to store the animations
  4173. */
  4174. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * This class defines the direct association between an animation and a target
  4180. */
  4181. class TargetedAnimation {
  4182. animation: Animation;
  4183. target: any;
  4184. }
  4185. /**
  4186. * Use this class to create coordinated animations on multiple targets
  4187. */
  4188. class AnimationGroup implements IDisposable {
  4189. name: string;
  4190. private _scene;
  4191. private _targetedAnimations;
  4192. private _animatables;
  4193. private _from;
  4194. private _to;
  4195. private _isStarted;
  4196. private _speedRatio;
  4197. onAnimationEndObservable: Observable<TargetedAnimation>;
  4198. /**
  4199. * This observable will notify when all animations have ended.
  4200. */
  4201. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4202. /**
  4203. * This observable will notify when all animations have paused.
  4204. */
  4205. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4206. /**
  4207. * Gets the first frame
  4208. */
  4209. readonly from: number;
  4210. /**
  4211. * Gets the last frame
  4212. */
  4213. readonly to: number;
  4214. /**
  4215. * Define if the animations are started
  4216. */
  4217. readonly isStarted: boolean;
  4218. /**
  4219. * Gets or sets the speed ratio to use for all animations
  4220. */
  4221. /**
  4222. * Gets or sets the speed ratio to use for all animations
  4223. */
  4224. speedRatio: number;
  4225. /**
  4226. * Gets the targeted animations for this animation group
  4227. */
  4228. readonly targetedAnimations: Array<TargetedAnimation>;
  4229. /**
  4230. * returning the list of animatables controlled by this animation group.
  4231. */
  4232. readonly animatables: Array<Animatable>;
  4233. constructor(name: string, scene?: Nullable<Scene>);
  4234. /**
  4235. * Add an animation (with its target) in the group
  4236. * @param animation defines the animation we want to add
  4237. * @param target defines the target of the animation
  4238. * @returns the {BABYLON.TargetedAnimation} object
  4239. */
  4240. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4241. /**
  4242. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4243. * It can add constant keys at begin or end
  4244. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4245. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4246. */
  4247. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4248. /**
  4249. * Start all animations on given targets
  4250. * @param loop defines if animations must loop
  4251. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4252. * @param from defines the from key (optional)
  4253. * @param to defines the to key (optional)
  4254. * @returns the current animation group
  4255. */
  4256. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4257. /**
  4258. * Pause all animations
  4259. */
  4260. pause(): AnimationGroup;
  4261. /**
  4262. * Play all animations to initial state
  4263. * This function will start() the animations if they were not started or will restart() them if they were paused
  4264. * @param loop defines if animations must loop
  4265. */
  4266. play(loop?: boolean): AnimationGroup;
  4267. /**
  4268. * Reset all animations to initial state
  4269. */
  4270. reset(): AnimationGroup;
  4271. /**
  4272. * Restart animations from key 0
  4273. */
  4274. restart(): AnimationGroup;
  4275. /**
  4276. * Stop all animations
  4277. */
  4278. stop(): AnimationGroup;
  4279. /**
  4280. * Set animation weight for all animatables
  4281. * @param weight defines the weight to use
  4282. * @return the animationGroup
  4283. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4284. */
  4285. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4286. /**
  4287. * Synchronize and normalize all animatables with a source animatable
  4288. * @param root defines the root animatable to synchronize with
  4289. * @return the animationGroup
  4290. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4291. */
  4292. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4293. /**
  4294. * Goes to a specific frame in this animation group
  4295. * @param frame the frame number to go to
  4296. * @return the animationGroup
  4297. */
  4298. goToFrame(frame: number): AnimationGroup;
  4299. /**
  4300. * Dispose all associated resources
  4301. */
  4302. dispose(): void;
  4303. private _checkAnimationGroupEnded;
  4304. }
  4305. }
  4306. declare module BABYLON {
  4307. /**
  4308. * Class used to override all child animations of a given target
  4309. */
  4310. class AnimationPropertiesOverride {
  4311. /**
  4312. * Gets or sets a value indicating if animation blending must be used
  4313. */
  4314. enableBlending: boolean;
  4315. /**
  4316. * Gets or sets the blending speed to use when enableBlending is true
  4317. */
  4318. blendingSpeed: number;
  4319. /**
  4320. * Gets or sets the default loop mode to use
  4321. */
  4322. loopMode: number;
  4323. }
  4324. }
  4325. declare module BABYLON {
  4326. interface IEasingFunction {
  4327. ease(gradient: number): number;
  4328. }
  4329. class EasingFunction implements IEasingFunction {
  4330. private static _EASINGMODE_EASEIN;
  4331. private static _EASINGMODE_EASEOUT;
  4332. private static _EASINGMODE_EASEINOUT;
  4333. static readonly EASINGMODE_EASEIN: number;
  4334. static readonly EASINGMODE_EASEOUT: number;
  4335. static readonly EASINGMODE_EASEINOUT: number;
  4336. private _easingMode;
  4337. setEasingMode(easingMode: number): void;
  4338. getEasingMode(): number;
  4339. easeInCore(gradient: number): number;
  4340. ease(gradient: number): number;
  4341. }
  4342. class CircleEase extends EasingFunction implements IEasingFunction {
  4343. easeInCore(gradient: number): number;
  4344. }
  4345. class BackEase extends EasingFunction implements IEasingFunction {
  4346. amplitude: number;
  4347. constructor(amplitude?: number);
  4348. easeInCore(gradient: number): number;
  4349. }
  4350. class BounceEase extends EasingFunction implements IEasingFunction {
  4351. bounces: number;
  4352. bounciness: number;
  4353. constructor(bounces?: number, bounciness?: number);
  4354. easeInCore(gradient: number): number;
  4355. }
  4356. class CubicEase extends EasingFunction implements IEasingFunction {
  4357. easeInCore(gradient: number): number;
  4358. }
  4359. class ElasticEase extends EasingFunction implements IEasingFunction {
  4360. oscillations: number;
  4361. springiness: number;
  4362. constructor(oscillations?: number, springiness?: number);
  4363. easeInCore(gradient: number): number;
  4364. }
  4365. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4366. exponent: number;
  4367. constructor(exponent?: number);
  4368. easeInCore(gradient: number): number;
  4369. }
  4370. class PowerEase extends EasingFunction implements IEasingFunction {
  4371. power: number;
  4372. constructor(power?: number);
  4373. easeInCore(gradient: number): number;
  4374. }
  4375. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4376. easeInCore(gradient: number): number;
  4377. }
  4378. class QuarticEase extends EasingFunction implements IEasingFunction {
  4379. easeInCore(gradient: number): number;
  4380. }
  4381. class QuinticEase extends EasingFunction implements IEasingFunction {
  4382. easeInCore(gradient: number): number;
  4383. }
  4384. class SineEase extends EasingFunction implements IEasingFunction {
  4385. easeInCore(gradient: number): number;
  4386. }
  4387. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4388. x1: number;
  4389. y1: number;
  4390. x2: number;
  4391. y2: number;
  4392. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4393. easeInCore(gradient: number): number;
  4394. }
  4395. }
  4396. declare module BABYLON {
  4397. /**
  4398. * Defines a runtime animation
  4399. */
  4400. class RuntimeAnimation {
  4401. private _events;
  4402. /**
  4403. * The current frame of the runtime animation
  4404. */
  4405. private _currentFrame;
  4406. /**
  4407. * The animation used by the runtime animation
  4408. */
  4409. private _animation;
  4410. /**
  4411. * The target of the runtime animation
  4412. */
  4413. private _target;
  4414. /**
  4415. * The initiating animatable
  4416. */
  4417. private _host;
  4418. /**
  4419. * The original value of the runtime animation
  4420. */
  4421. private _originalValue;
  4422. /**
  4423. * The original blend value of the runtime animation
  4424. */
  4425. private _originalBlendValue;
  4426. /**
  4427. * The offsets cache of the runtime animation
  4428. */
  4429. private _offsetsCache;
  4430. /**
  4431. * The high limits cache of the runtime animation
  4432. */
  4433. private _highLimitsCache;
  4434. /**
  4435. * Specifies if the runtime animation has been stopped
  4436. */
  4437. private _stopped;
  4438. /**
  4439. * The blending factor of the runtime animation
  4440. */
  4441. private _blendingFactor;
  4442. /**
  4443. * The BabylonJS scene
  4444. */
  4445. private _scene;
  4446. /**
  4447. * The current value of the runtime animation
  4448. */
  4449. private _currentValue;
  4450. /** @hidden */
  4451. _workValue: any;
  4452. /**
  4453. * The active target of the runtime animation
  4454. */
  4455. private _activeTarget;
  4456. /**
  4457. * The target path of the runtime animation
  4458. */
  4459. private _targetPath;
  4460. /**
  4461. * The weight of the runtime animation
  4462. */
  4463. private _weight;
  4464. /**
  4465. * The ratio offset of the runtime animation
  4466. */
  4467. private _ratioOffset;
  4468. /**
  4469. * The previous delay of the runtime animation
  4470. */
  4471. private _previousDelay;
  4472. /**
  4473. * The previous ratio of the runtime animation
  4474. */
  4475. private _previousRatio;
  4476. /**
  4477. * Gets the current frame of the runtime animation
  4478. */
  4479. readonly currentFrame: number;
  4480. /**
  4481. * Gets the weight of the runtime animation
  4482. */
  4483. readonly weight: number;
  4484. /**
  4485. * Gets the current value of the runtime animation
  4486. */
  4487. readonly currentValue: any;
  4488. /**
  4489. * Gets the target path of the runtime animation
  4490. */
  4491. readonly targetPath: string;
  4492. /**
  4493. * Gets the actual target of the runtime animation
  4494. */
  4495. readonly target: any;
  4496. /**
  4497. * Create a new RuntimeAnimation object
  4498. * @param target defines the target of the animation
  4499. * @param animation defines the source animation object
  4500. * @param scene defines the hosting scene
  4501. * @param host defines the initiating Animatable
  4502. */
  4503. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4504. /**
  4505. * Gets the animation from the runtime animation
  4506. */
  4507. readonly animation: Animation;
  4508. /**
  4509. * Resets the runtime animation to the beginning
  4510. * @param restoreOriginal defines whether to restore the target property to the original value
  4511. */
  4512. reset(restoreOriginal?: boolean): void;
  4513. /**
  4514. * Specifies if the runtime animation is stopped
  4515. * @returns Boolean specifying if the runtime animation is stopped
  4516. */
  4517. isStopped(): boolean;
  4518. /**
  4519. * Disposes of the runtime animation
  4520. */
  4521. dispose(): void;
  4522. /**
  4523. * Interpolates the animation from the current frame
  4524. * @param currentFrame The frame to interpolate the animation to
  4525. * @param repeatCount The number of times that the animation should loop
  4526. * @param loopMode The type of looping mode to use
  4527. * @param offsetValue Animation offset value
  4528. * @param highLimitValue The high limit value
  4529. * @returns The interpolated value
  4530. */
  4531. private _interpolate;
  4532. /**
  4533. * Apply the interpolated value to the target
  4534. * @param currentValue defines the value computed by the animation
  4535. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4536. */
  4537. setValue(currentValue: any, weight?: number): void;
  4538. private _setValue;
  4539. /**
  4540. * Gets the loop pmode of the runtime animation
  4541. * @returns Loop Mode
  4542. */
  4543. private _getCorrectLoopMode;
  4544. /**
  4545. * Move the current animation to a given frame
  4546. * @param frame defines the frame to move to
  4547. */
  4548. goToFrame(frame: number): void;
  4549. /**
  4550. * @hidden Internal use only
  4551. */
  4552. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4553. /**
  4554. * Execute the current animation
  4555. * @param delay defines the delay to add to the current frame
  4556. * @param from defines the lower bound of the animation range
  4557. * @param to defines the upper bound of the animation range
  4558. * @param loop defines if the current animation must loop
  4559. * @param speedRatio defines the current speed ratio
  4560. * @param weight defines the weight of the animation (default is -1 so no weight)
  4561. * @returns a boolean indicating if the animation is running
  4562. */
  4563. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4570. */
  4571. class Analyser {
  4572. /**
  4573. * Gets or sets the smoothing
  4574. * @ignorenaming
  4575. */
  4576. SMOOTHING: number;
  4577. /**
  4578. * Gets or sets the FFT table size
  4579. * @ignorenaming
  4580. */
  4581. FFT_SIZE: number;
  4582. /**
  4583. * Gets or sets the bar graph amplitude
  4584. * @ignorenaming
  4585. */
  4586. BARGRAPHAMPLITUDE: number;
  4587. /**
  4588. * Gets or sets the position of the debug canvas
  4589. * @ignorenaming
  4590. */
  4591. DEBUGCANVASPOS: {
  4592. x: number;
  4593. y: number;
  4594. };
  4595. /**
  4596. * Gets or sets the debug canvas size
  4597. * @ignorenaming
  4598. */
  4599. DEBUGCANVASSIZE: {
  4600. width: number;
  4601. height: number;
  4602. };
  4603. private _byteFreqs;
  4604. private _byteTime;
  4605. private _floatFreqs;
  4606. private _webAudioAnalyser;
  4607. private _debugCanvas;
  4608. private _debugCanvasContext;
  4609. private _scene;
  4610. private _registerFunc;
  4611. private _audioEngine;
  4612. /**
  4613. * Creates a new analyser
  4614. * @param scene defines hosting scene
  4615. */
  4616. constructor(scene: Scene);
  4617. /**
  4618. * Get the number of data values you will have to play with for the visualization
  4619. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4620. * @returns a number
  4621. */
  4622. getFrequencyBinCount(): number;
  4623. /**
  4624. * Gets the current frequency data as a byte array
  4625. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4626. * @returns a Uint8Array
  4627. */
  4628. getByteFrequencyData(): Uint8Array;
  4629. /**
  4630. * Gets the current waveform as a byte array
  4631. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4632. * @returns a Uint8Array
  4633. */
  4634. getByteTimeDomainData(): Uint8Array;
  4635. /**
  4636. * Gets the current frequency data as a float array
  4637. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4638. * @returns a Float32Array
  4639. */
  4640. getFloatFrequencyData(): Float32Array;
  4641. /**
  4642. * Renders the debug canvas
  4643. */
  4644. drawDebugCanvas(): void;
  4645. /**
  4646. * Stops rendering the debug canvas and removes it
  4647. */
  4648. stopDebugCanvas(): void;
  4649. /**
  4650. * Connects two audio nodes
  4651. * @param inputAudioNode defines first node to connect
  4652. * @param outputAudioNode defines second node to connect
  4653. */
  4654. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4655. /**
  4656. * Releases all associated resources
  4657. */
  4658. dispose(): void;
  4659. }
  4660. }
  4661. declare module BABYLON {
  4662. class AudioEngine {
  4663. private _audioContext;
  4664. private _audioContextInitialized;
  4665. canUseWebAudio: boolean;
  4666. masterGain: GainNode;
  4667. private _connectedAnalyser;
  4668. WarnedWebAudioUnsupported: boolean;
  4669. unlocked: boolean;
  4670. onAudioUnlocked: () => any;
  4671. isMP3supported: boolean;
  4672. isOGGsupported: boolean;
  4673. readonly audioContext: Nullable<AudioContext>;
  4674. constructor();
  4675. private _unlockiOSaudio;
  4676. private _initializeAudioContext;
  4677. dispose(): void;
  4678. getGlobalVolume(): number;
  4679. setGlobalVolume(newVolume: number): void;
  4680. connectToAnalyser(analyser: Analyser): void;
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. class Sound {
  4685. name: string;
  4686. autoplay: boolean;
  4687. loop: boolean;
  4688. useCustomAttenuation: boolean;
  4689. soundTrackId: number;
  4690. spatialSound: boolean;
  4691. refDistance: number;
  4692. rolloffFactor: number;
  4693. maxDistance: number;
  4694. distanceModel: string;
  4695. private _panningModel;
  4696. onended: () => any;
  4697. /**
  4698. * Observable event when the current playing sound finishes.
  4699. */
  4700. onEndedObservable: Observable<Sound>;
  4701. private _playbackRate;
  4702. private _streaming;
  4703. private _startTime;
  4704. private _startOffset;
  4705. private _position;
  4706. /** @hidden */
  4707. _positionInEmitterSpace: boolean;
  4708. private _localDirection;
  4709. private _volume;
  4710. private _isReadyToPlay;
  4711. isPlaying: boolean;
  4712. isPaused: boolean;
  4713. private _isDirectional;
  4714. private _readyToPlayCallback;
  4715. private _audioBuffer;
  4716. private _soundSource;
  4717. private _streamingSource;
  4718. private _soundPanner;
  4719. private _soundGain;
  4720. private _inputAudioNode;
  4721. private _outputAudioNode;
  4722. private _coneInnerAngle;
  4723. private _coneOuterAngle;
  4724. private _coneOuterGain;
  4725. private _scene;
  4726. private _connectedMesh;
  4727. private _customAttenuationFunction;
  4728. private _registerFunc;
  4729. private _isOutputConnected;
  4730. private _htmlAudioElement;
  4731. private _urlType;
  4732. /**
  4733. * Create a sound and attach it to a scene
  4734. * @param name Name of your sound
  4735. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4736. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4737. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4738. */
  4739. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4740. dispose(): void;
  4741. isReady(): boolean;
  4742. private _soundLoaded;
  4743. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4744. updateOptions(options: any): void;
  4745. private _createSpatialParameters;
  4746. private _updateSpatialParameters;
  4747. switchPanningModelToHRTF(): void;
  4748. switchPanningModelToEqualPower(): void;
  4749. private _switchPanningModel;
  4750. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4751. /**
  4752. * Transform this sound into a directional source
  4753. * @param coneInnerAngle Size of the inner cone in degree
  4754. * @param coneOuterAngle Size of the outer cone in degree
  4755. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4756. */
  4757. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4758. /**
  4759. * Gets or sets the inner angle for the directional cone.
  4760. */
  4761. /**
  4762. * Gets or sets the inner angle for the directional cone.
  4763. */
  4764. directionalConeInnerAngle: number;
  4765. /**
  4766. * Gets or sets the outer angle for the directional cone.
  4767. */
  4768. /**
  4769. * Gets or sets the outer angle for the directional cone.
  4770. */
  4771. directionalConeOuterAngle: number;
  4772. setPosition(newPosition: Vector3): void;
  4773. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4774. private _updateDirection;
  4775. updateDistanceFromListener(): void;
  4776. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4777. /**
  4778. * Play the sound
  4779. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4780. * @param offset (optional) Start the sound setting it at a specific time
  4781. */
  4782. play(time?: number, offset?: number): void;
  4783. private _onended;
  4784. /**
  4785. * Stop the sound
  4786. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4787. */
  4788. stop(time?: number): void;
  4789. pause(): void;
  4790. setVolume(newVolume: number, time?: number): void;
  4791. setPlaybackRate(newPlaybackRate: number): void;
  4792. getVolume(): number;
  4793. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4794. detachFromMesh(): void;
  4795. private _onRegisterAfterWorldMatrixUpdate;
  4796. clone(): Nullable<Sound>;
  4797. getAudioBuffer(): AudioBuffer | null;
  4798. serialize(): any;
  4799. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4800. }
  4801. }
  4802. declare module BABYLON {
  4803. class SoundTrack {
  4804. private _outputAudioNode;
  4805. private _scene;
  4806. id: number;
  4807. soundCollection: Array<Sound>;
  4808. private _isMainTrack;
  4809. private _connectedAnalyser;
  4810. private _options;
  4811. private _isInitialized;
  4812. constructor(scene: Scene, options?: any);
  4813. private _initializeSoundTrackAudioGraph;
  4814. dispose(): void;
  4815. AddSound(sound: Sound): void;
  4816. RemoveSound(sound: Sound): void;
  4817. setVolume(newVolume: number): void;
  4818. switchPanningModelToHRTF(): void;
  4819. switchPanningModelToEqualPower(): void;
  4820. connectToAnalyser(analyser: Analyser): void;
  4821. }
  4822. }
  4823. declare module BABYLON {
  4824. /**
  4825. * Wraps one or more Sound objects and selects one with random weight for playback.
  4826. */
  4827. class WeightedSound {
  4828. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4829. loop: boolean;
  4830. private _coneInnerAngle;
  4831. private _coneOuterAngle;
  4832. private _volume;
  4833. /** A Sound is currently playing. */
  4834. isPlaying: boolean;
  4835. /** A Sound is currently paused. */
  4836. isPaused: boolean;
  4837. private _sounds;
  4838. private _weights;
  4839. private _currentIndex?;
  4840. /**
  4841. * Creates a new WeightedSound from the list of sounds given.
  4842. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4843. * @param sounds Array of Sounds that will be selected from.
  4844. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4845. */
  4846. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4847. /**
  4848. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4849. */
  4850. /**
  4851. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4852. */
  4853. directionalConeInnerAngle: number;
  4854. /**
  4855. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4856. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4857. */
  4858. /**
  4859. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4860. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4861. */
  4862. directionalConeOuterAngle: number;
  4863. /**
  4864. * Playback volume.
  4865. */
  4866. /**
  4867. * Playback volume.
  4868. */
  4869. volume: number;
  4870. private _onended;
  4871. /**
  4872. * Suspend playback
  4873. */
  4874. pause(): void;
  4875. /**
  4876. * Stop playback
  4877. */
  4878. stop(): void;
  4879. /**
  4880. * Start playback.
  4881. * @param startOffset Position the clip head at a specific time in seconds.
  4882. */
  4883. play(startOffset?: number): void;
  4884. }
  4885. }
  4886. declare module BABYLON {
  4887. /**
  4888. * Interface used to define a behavior
  4889. */
  4890. interface Behavior<T> {
  4891. /** gets or sets behavior's name */
  4892. name: string;
  4893. /**
  4894. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4895. */
  4896. init(): void;
  4897. /**
  4898. * Called when the behavior is attached to a target
  4899. * @param target defines the target where the behavior is attached to
  4900. */
  4901. attach(target: T): void;
  4902. /**
  4903. * Called when the behavior is detached from its target
  4904. */
  4905. detach(): void;
  4906. }
  4907. /**
  4908. * Interface implemented by classes supporting behaviors
  4909. */
  4910. interface IBehaviorAware<T> {
  4911. /**
  4912. * Attach a behavior
  4913. * @param behavior defines the behavior to attach
  4914. * @returns the current host
  4915. */
  4916. addBehavior(behavior: Behavior<T>): T;
  4917. /**
  4918. * Remove a behavior from the current object
  4919. * @param behavior defines the behavior to detach
  4920. * @returns the current host
  4921. */
  4922. removeBehavior(behavior: Behavior<T>): T;
  4923. /**
  4924. * Gets a behavior using its name to search
  4925. * @param name defines the name to search
  4926. * @returns the behavior or null if not found
  4927. */
  4928. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /**
  4933. * Class used to store bone information
  4934. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4935. */
  4936. class Bone extends Node {
  4937. /**
  4938. * defines the bone name
  4939. */
  4940. name: string;
  4941. private static _tmpVecs;
  4942. private static _tmpQuat;
  4943. private static _tmpMats;
  4944. /**
  4945. * Gets the list of child bones
  4946. */
  4947. children: Bone[];
  4948. /** Gets the animations associated with this bone */
  4949. animations: Animation[];
  4950. /**
  4951. * Gets or sets bone length
  4952. */
  4953. length: number;
  4954. /**
  4955. * @hidden Internal only
  4956. * Set this value to map this bone to a different index in the transform matrices
  4957. * Set this value to -1 to exclude the bone from the transform matrices
  4958. */
  4959. _index: Nullable<number>;
  4960. private _skeleton;
  4961. private _localMatrix;
  4962. private _restPose;
  4963. private _baseMatrix;
  4964. private _absoluteTransform;
  4965. private _invertedAbsoluteTransform;
  4966. private _parent;
  4967. private _scalingDeterminant;
  4968. private _worldTransform;
  4969. private _localScaling;
  4970. private _localRotation;
  4971. private _localPosition;
  4972. private _needToDecompose;
  4973. private _needToCompose;
  4974. /** @hidden */
  4975. /** @hidden */
  4976. _matrix: Matrix;
  4977. /**
  4978. * Create a new bone
  4979. * @param name defines the bone name
  4980. * @param skeleton defines the parent skeleton
  4981. * @param parentBone defines the parent (can be null if the bone is the root)
  4982. * @param localMatrix defines the local matrix
  4983. * @param restPose defines the rest pose matrix
  4984. * @param baseMatrix defines the base matrix
  4985. * @param index defines index of the bone in the hiearchy
  4986. */
  4987. constructor(
  4988. /**
  4989. * defines the bone name
  4990. */
  4991. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4992. /**
  4993. * Gets the parent skeleton
  4994. * @returns a skeleton
  4995. */
  4996. getSkeleton(): Skeleton;
  4997. /**
  4998. * Gets parent bone
  4999. * @returns a bone or null if the bone is the root of the bone hierarchy
  5000. */
  5001. getParent(): Nullable<Bone>;
  5002. /**
  5003. * Sets the parent bone
  5004. * @param parent defines the parent (can be null if the bone is the root)
  5005. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5006. */
  5007. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5008. /**
  5009. * Gets the local matrix
  5010. * @returns a matrix
  5011. */
  5012. getLocalMatrix(): Matrix;
  5013. /**
  5014. * Gets the base matrix (initial matrix which remains unchanged)
  5015. * @returns a matrix
  5016. */
  5017. getBaseMatrix(): Matrix;
  5018. /**
  5019. * Gets the rest pose matrix
  5020. * @returns a matrix
  5021. */
  5022. getRestPose(): Matrix;
  5023. /**
  5024. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5025. */
  5026. getWorldMatrix(): Matrix;
  5027. /**
  5028. * Sets the local matrix to rest pose matrix
  5029. */
  5030. returnToRest(): void;
  5031. /**
  5032. * Gets the inverse of the absolute transform matrix.
  5033. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5034. * @returns a matrix
  5035. */
  5036. getInvertedAbsoluteTransform(): Matrix;
  5037. /**
  5038. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5039. * @returns a matrix
  5040. */
  5041. getAbsoluteTransform(): Matrix;
  5042. /** Gets or sets current position (in local space) */
  5043. position: Vector3;
  5044. /** Gets or sets current rotation (in local space) */
  5045. rotation: Vector3;
  5046. /** Gets or sets current rotation quaternion (in local space) */
  5047. rotationQuaternion: Quaternion;
  5048. /** Gets or sets current scaling (in local space) */
  5049. scaling: Vector3;
  5050. /**
  5051. * Gets the animation properties override
  5052. */
  5053. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5054. private _decompose;
  5055. private _compose;
  5056. /**
  5057. * Update the base and local matrices
  5058. * @param matrix defines the new base or local matrix
  5059. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5060. * @param updateLocalMatrix defines if the local matrix should be updated
  5061. */
  5062. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5063. /** @hidden */
  5064. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5065. /**
  5066. * Flag the bone as dirty (Forcing it to update everything)
  5067. */
  5068. markAsDirty(): void;
  5069. private _markAsDirtyAndCompose;
  5070. private _markAsDirtyAndDecompose;
  5071. /**
  5072. * Copy an animation range from another bone
  5073. * @param source defines the source bone
  5074. * @param rangeName defines the range name to copy
  5075. * @param frameOffset defines the frame offset
  5076. * @param rescaleAsRequired defines if rescaling must be applied if required
  5077. * @param skelDimensionsRatio defines the scaling ratio
  5078. * @returns true if operation was successful
  5079. */
  5080. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5081. /**
  5082. * Translate the bone in local or world space
  5083. * @param vec The amount to translate the bone
  5084. * @param space The space that the translation is in
  5085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5086. */
  5087. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5088. /**
  5089. * Set the postion of the bone in local or world space
  5090. * @param position The position to set the bone
  5091. * @param space The space that the position is in
  5092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5093. */
  5094. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5095. /**
  5096. * Set the absolute position of the bone (world space)
  5097. * @param position The position to set the bone
  5098. * @param mesh The mesh that this bone is attached to
  5099. */
  5100. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5101. /**
  5102. * Scale the bone on the x, y and z axes (in local space)
  5103. * @param x The amount to scale the bone on the x axis
  5104. * @param y The amount to scale the bone on the y axis
  5105. * @param z The amount to scale the bone on the z axis
  5106. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5107. */
  5108. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5109. /**
  5110. * Set the bone scaling in local space
  5111. * @param scale defines the scaling vector
  5112. */
  5113. setScale(scale: Vector3): void;
  5114. /**
  5115. * Gets the current scaling in local space
  5116. * @returns the current scaling vector
  5117. */
  5118. getScale(): Vector3;
  5119. /**
  5120. * Gets the current scaling in local space and stores it in a target vector
  5121. * @param result defines the target vector
  5122. */
  5123. getScaleToRef(result: Vector3): void;
  5124. /**
  5125. * Set the yaw, pitch, and roll of the bone in local or world space
  5126. * @param yaw The rotation of the bone on the y axis
  5127. * @param pitch The rotation of the bone on the x axis
  5128. * @param roll The rotation of the bone on the z axis
  5129. * @param space The space that the axes of rotation are in
  5130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5131. */
  5132. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5133. /**
  5134. * Add a rotation to the bone on an axis in local or world space
  5135. * @param axis The axis to rotate the bone on
  5136. * @param amount The amount to rotate the bone
  5137. * @param space The space that the axis is in
  5138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5139. */
  5140. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5141. /**
  5142. * Set the rotation of the bone to a particular axis angle in local or world space
  5143. * @param axis The axis to rotate the bone on
  5144. * @param angle The angle that the bone should be rotated to
  5145. * @param space The space that the axis is in
  5146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5147. */
  5148. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5149. /**
  5150. * Set the euler rotation of the bone in local of world space
  5151. * @param rotation The euler rotation that the bone should be set to
  5152. * @param space The space that the rotation is in
  5153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5154. */
  5155. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5156. /**
  5157. * Set the quaternion rotation of the bone in local of world space
  5158. * @param quat The quaternion rotation that the bone should be set to
  5159. * @param space The space that the rotation is in
  5160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5161. */
  5162. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5163. /**
  5164. * Set the rotation matrix of the bone in local of world space
  5165. * @param rotMat The rotation matrix that the bone should be set to
  5166. * @param space The space that the rotation is in
  5167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5168. */
  5169. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5170. private _rotateWithMatrix;
  5171. private _getNegativeRotationToRef;
  5172. /**
  5173. * Get the position of the bone in local or world space
  5174. * @param space The space that the returned position is in
  5175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5176. * @returns The position of the bone
  5177. */
  5178. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5179. /**
  5180. * Copy the position of the bone to a vector3 in local or world space
  5181. * @param space The space that the returned position is in
  5182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5183. * @param result The vector3 to copy the position to
  5184. */
  5185. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5186. /**
  5187. * Get the absolute position of the bone (world space)
  5188. * @param mesh The mesh that this bone is attached to
  5189. * @returns The absolute position of the bone
  5190. */
  5191. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5192. /**
  5193. * Copy the absolute position of the bone (world space) to the result param
  5194. * @param mesh The mesh that this bone is attached to
  5195. * @param result The vector3 to copy the absolute position to
  5196. */
  5197. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5198. /**
  5199. * Compute the absolute transforms of this bone and its children
  5200. */
  5201. computeAbsoluteTransforms(): void;
  5202. /**
  5203. * Get the world direction from an axis that is in the local space of the bone
  5204. * @param localAxis The local direction that is used to compute the world direction
  5205. * @param mesh The mesh that this bone is attached to
  5206. * @returns The world direction
  5207. */
  5208. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5209. /**
  5210. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5211. * @param localAxis The local direction that is used to compute the world direction
  5212. * @param mesh The mesh that this bone is attached to
  5213. * @param result The vector3 that the world direction will be copied to
  5214. */
  5215. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5216. /**
  5217. * Get the euler rotation of the bone in local or world space
  5218. * @param space The space that the rotation should be in
  5219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5220. * @returns The euler rotation
  5221. */
  5222. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5223. /**
  5224. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5225. * @param space The space that the rotation should be in
  5226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5227. * @param result The vector3 that the rotation should be copied to
  5228. */
  5229. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5230. /**
  5231. * Get the quaternion rotation of the bone in either local or world space
  5232. * @param space The space that the rotation should be in
  5233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5234. * @returns The quaternion rotation
  5235. */
  5236. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5237. /**
  5238. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5239. * @param space The space that the rotation should be in
  5240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5241. * @param result The quaternion that the rotation should be copied to
  5242. */
  5243. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5244. /**
  5245. * Get the rotation matrix of the bone in local or world space
  5246. * @param space The space that the rotation should be in
  5247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5248. * @returns The rotation matrix
  5249. */
  5250. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5251. /**
  5252. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5253. * @param space The space that the rotation should be in
  5254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5255. * @param result The quaternion that the rotation should be copied to
  5256. */
  5257. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5258. /**
  5259. * Get the world position of a point that is in the local space of the bone
  5260. * @param position The local position
  5261. * @param mesh The mesh that this bone is attached to
  5262. * @returns The world position
  5263. */
  5264. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5265. /**
  5266. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5267. * @param position The local position
  5268. * @param mesh The mesh that this bone is attached to
  5269. * @param result The vector3 that the world position should be copied to
  5270. */
  5271. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5272. /**
  5273. * Get the local position of a point that is in world space
  5274. * @param position The world position
  5275. * @param mesh The mesh that this bone is attached to
  5276. * @returns The local position
  5277. */
  5278. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5279. /**
  5280. * Get the local position of a point that is in world space and copy it to the result param
  5281. * @param position The world position
  5282. * @param mesh The mesh that this bone is attached to
  5283. * @param result The vector3 that the local position should be copied to
  5284. */
  5285. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5286. }
  5287. }
  5288. declare module BABYLON {
  5289. /**
  5290. * Class used to apply inverse kinematics to bones
  5291. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5292. */
  5293. class BoneIKController {
  5294. private static _tmpVecs;
  5295. private static _tmpQuat;
  5296. private static _tmpMats;
  5297. /**
  5298. * Gets or sets the target mesh
  5299. */
  5300. targetMesh: AbstractMesh;
  5301. /** Gets or sets the mesh used as pole */
  5302. poleTargetMesh: AbstractMesh;
  5303. /**
  5304. * Gets or sets the bone used as pole
  5305. */
  5306. poleTargetBone: Nullable<Bone>;
  5307. /**
  5308. * Gets or sets the target position
  5309. */
  5310. targetPosition: Vector3;
  5311. /**
  5312. * Gets or sets the pole target position
  5313. */
  5314. poleTargetPosition: Vector3;
  5315. /**
  5316. * Gets or sets the pole target local offset
  5317. */
  5318. poleTargetLocalOffset: Vector3;
  5319. /**
  5320. * Gets or sets the pole angle
  5321. */
  5322. poleAngle: number;
  5323. /**
  5324. * Gets or sets the mesh associated with the controller
  5325. */
  5326. mesh: AbstractMesh;
  5327. /**
  5328. * 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)
  5329. */
  5330. slerpAmount: number;
  5331. private _bone1Quat;
  5332. private _bone1Mat;
  5333. private _bone2Ang;
  5334. private _bone1;
  5335. private _bone2;
  5336. private _bone1Length;
  5337. private _bone2Length;
  5338. private _maxAngle;
  5339. private _maxReach;
  5340. private _rightHandedSystem;
  5341. private _bendAxis;
  5342. private _slerping;
  5343. private _adjustRoll;
  5344. /**
  5345. * Gets or sets maximum allowed angle
  5346. */
  5347. maxAngle: number;
  5348. /**
  5349. * Creates a new BoneIKController
  5350. * @param mesh defines the mesh to control
  5351. * @param bone defines the bone to control
  5352. * @param options defines options to set up the controller
  5353. */
  5354. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5355. targetMesh?: AbstractMesh;
  5356. poleTargetMesh?: AbstractMesh;
  5357. poleTargetBone?: Bone;
  5358. poleTargetLocalOffset?: Vector3;
  5359. poleAngle?: number;
  5360. bendAxis?: Vector3;
  5361. maxAngle?: number;
  5362. slerpAmount?: number;
  5363. });
  5364. private _setMaxAngle;
  5365. /**
  5366. * Force the controller to update the bones
  5367. */
  5368. update(): void;
  5369. }
  5370. }
  5371. declare module BABYLON {
  5372. /**
  5373. * Class used to make a bone look toward a point in space
  5374. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5375. */
  5376. class BoneLookController {
  5377. private static _tmpVecs;
  5378. private static _tmpQuat;
  5379. private static _tmpMats;
  5380. /**
  5381. * The target Vector3 that the bone will look at
  5382. */
  5383. target: Vector3;
  5384. /**
  5385. * The mesh that the bone is attached to
  5386. */
  5387. mesh: AbstractMesh;
  5388. /**
  5389. * The bone that will be looking to the target
  5390. */
  5391. bone: Bone;
  5392. /**
  5393. * The up axis of the coordinate system that is used when the bone is rotated
  5394. */
  5395. upAxis: Vector3;
  5396. /**
  5397. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5398. */
  5399. upAxisSpace: Space;
  5400. /**
  5401. * Used to make an adjustment to the yaw of the bone
  5402. */
  5403. adjustYaw: number;
  5404. /**
  5405. * Used to make an adjustment to the pitch of the bone
  5406. */
  5407. adjustPitch: number;
  5408. /**
  5409. * Used to make an adjustment to the roll of the bone
  5410. */
  5411. adjustRoll: number;
  5412. /**
  5413. * 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)
  5414. */
  5415. slerpAmount: number;
  5416. private _minYaw;
  5417. private _maxYaw;
  5418. private _minPitch;
  5419. private _maxPitch;
  5420. private _minYawSin;
  5421. private _minYawCos;
  5422. private _maxYawSin;
  5423. private _maxYawCos;
  5424. private _midYawConstraint;
  5425. private _minPitchTan;
  5426. private _maxPitchTan;
  5427. private _boneQuat;
  5428. private _slerping;
  5429. private _transformYawPitch;
  5430. private _transformYawPitchInv;
  5431. private _firstFrameSkipped;
  5432. private _yawRange;
  5433. private _fowardAxis;
  5434. /**
  5435. * Gets or sets the minimum yaw angle that the bone can look to
  5436. */
  5437. minYaw: number;
  5438. /**
  5439. * Gets or sets the maximum yaw angle that the bone can look to
  5440. */
  5441. maxYaw: number;
  5442. /**
  5443. * Gets or sets the minimum pitch angle that the bone can look to
  5444. */
  5445. minPitch: number;
  5446. /**
  5447. * Gets or sets the maximum pitch angle that the bone can look to
  5448. */
  5449. maxPitch: number;
  5450. /**
  5451. * Create a BoneLookController
  5452. * @param mesh the mesh that the bone belongs to
  5453. * @param bone the bone that will be looking to the target
  5454. * @param target the target Vector3 to look at
  5455. * @param settings optional settings:
  5456. * * maxYaw: the maximum angle the bone will yaw to
  5457. * * minYaw: the minimum angle the bone will yaw to
  5458. * * maxPitch: the maximum angle the bone will pitch to
  5459. * * minPitch: the minimum angle the bone will yaw to
  5460. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5461. * * upAxis: the up axis of the coordinate system
  5462. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5463. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5464. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5465. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5466. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5467. * * adjustRoll: used to make an adjustment to the roll of the bone
  5468. **/
  5469. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5470. maxYaw?: number;
  5471. minYaw?: number;
  5472. maxPitch?: number;
  5473. minPitch?: number;
  5474. slerpAmount?: number;
  5475. upAxis?: Vector3;
  5476. upAxisSpace?: Space;
  5477. yawAxis?: Vector3;
  5478. pitchAxis?: Vector3;
  5479. adjustYaw?: number;
  5480. adjustPitch?: number;
  5481. adjustRoll?: number;
  5482. });
  5483. /**
  5484. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5485. */
  5486. update(): void;
  5487. private _getAngleDiff;
  5488. private _getAngleBetween;
  5489. private _isAngleBetween;
  5490. }
  5491. }
  5492. declare module BABYLON {
  5493. /**
  5494. * Class used to handle skinning animations
  5495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5496. */
  5497. class Skeleton implements IAnimatable {
  5498. /** defines the skeleton name */
  5499. name: string;
  5500. /** defines the skeleton Id */
  5501. id: string;
  5502. /**
  5503. * Gets the list of child bones
  5504. */
  5505. bones: Bone[];
  5506. /**
  5507. * Gets an estimate of the dimension of the skeleton at rest
  5508. */
  5509. dimensionsAtRest: Vector3;
  5510. /**
  5511. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5512. */
  5513. needInitialSkinMatrix: boolean;
  5514. /**
  5515. * Gets the list of animations attached to this skeleton
  5516. */
  5517. animations: Array<Animation>;
  5518. private _scene;
  5519. private _isDirty;
  5520. private _transformMatrices;
  5521. private _meshesWithPoseMatrix;
  5522. private _animatables;
  5523. private _identity;
  5524. private _synchronizedWithMesh;
  5525. private _ranges;
  5526. private _lastAbsoluteTransformsUpdateId;
  5527. /**
  5528. * Specifies if the skeleton should be serialized
  5529. */
  5530. doNotSerialize: boolean;
  5531. private _animationPropertiesOverride;
  5532. /**
  5533. * Gets or sets the animation properties override
  5534. */
  5535. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5536. /**
  5537. * An observable triggered before computing the skeleton's matrices
  5538. */
  5539. onBeforeComputeObservable: Observable<Skeleton>;
  5540. /**
  5541. * Creates a new skeleton
  5542. * @param name defines the skeleton name
  5543. * @param id defines the skeleton Id
  5544. * @param scene defines the hosting scene
  5545. */
  5546. constructor(
  5547. /** defines the skeleton name */
  5548. name: string,
  5549. /** defines the skeleton Id */
  5550. id: string, scene: Scene);
  5551. /**
  5552. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5553. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5554. * @returns a Float32Array containing matrices data
  5555. */
  5556. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5557. /**
  5558. * Gets the current hosting scene
  5559. * @returns a scene object
  5560. */
  5561. getScene(): Scene;
  5562. /**
  5563. * Gets a string representing the current skeleton data
  5564. * @param fullDetails defines a boolean indicating if we want a verbose version
  5565. * @returns a string representing the current skeleton data
  5566. */
  5567. toString(fullDetails?: boolean): string;
  5568. /**
  5569. * Get bone's index searching by name
  5570. * @param name defines bone's name to search for
  5571. * @return the indice of the bone. Returns -1 if not found
  5572. */
  5573. getBoneIndexByName(name: string): number;
  5574. /**
  5575. * Creater a new animation range
  5576. * @param name defines the name of the range
  5577. * @param from defines the start key
  5578. * @param to defines the end key
  5579. */
  5580. createAnimationRange(name: string, from: number, to: number): void;
  5581. /**
  5582. * Delete a specific animation range
  5583. * @param name defines the name of the range
  5584. * @param deleteFrames defines if frames must be removed as well
  5585. */
  5586. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5587. /**
  5588. * Gets a specific animation range
  5589. * @param name defines the name of the range to look for
  5590. * @returns the requested animation range or null if not found
  5591. */
  5592. getAnimationRange(name: string): Nullable<AnimationRange>;
  5593. /**
  5594. * Gets the list of all animation ranges defined on this skeleton
  5595. * @returns an array
  5596. */
  5597. getAnimationRanges(): Nullable<AnimationRange>[];
  5598. /**
  5599. * Copy animation range from a source skeleton.
  5600. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5601. * @param source defines the source skeleton
  5602. * @param name defines the name of the range to copy
  5603. * @param rescaleAsRequired defines if rescaling must be applied if required
  5604. * @returns true if operation was successful
  5605. */
  5606. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5607. /**
  5608. * Forces the skeleton to go to rest pose
  5609. */
  5610. returnToRest(): void;
  5611. private _getHighestAnimationFrame;
  5612. /**
  5613. * Begin a specific animation range
  5614. * @param name defines the name of the range to start
  5615. * @param loop defines if looping must be turned on (false by default)
  5616. * @param speedRatio defines the speed ratio to apply (1 by default)
  5617. * @param onAnimationEnd defines a callback which will be called when animation will end
  5618. * @returns a new animatable
  5619. */
  5620. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5621. /** @hidden */
  5622. _markAsDirty(): void;
  5623. /** @hidden */
  5624. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5625. /** @hidden */
  5626. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5627. /** @hidden */
  5628. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5629. /**
  5630. * Build all resources required to render a skeleton
  5631. */
  5632. prepare(): void;
  5633. /**
  5634. * Gets the list of animatables currently running for this skeleton
  5635. * @returns an array of animatables
  5636. */
  5637. getAnimatables(): IAnimatable[];
  5638. /**
  5639. * Clone the current skeleton
  5640. * @param name defines the name of the new skeleton
  5641. * @param id defines the id of the enw skeleton
  5642. * @returns the new skeleton
  5643. */
  5644. clone(name: string, id: string): Skeleton;
  5645. /**
  5646. * Enable animation blending for this skeleton
  5647. * @param blendingSpeed defines the blending speed to apply
  5648. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5649. */
  5650. enableBlending(blendingSpeed?: number): void;
  5651. /**
  5652. * Releases all resources associated with the current skeleton
  5653. */
  5654. dispose(): void;
  5655. /**
  5656. * Serialize the skeleton in a JSON object
  5657. * @returns a JSON object
  5658. */
  5659. serialize(): any;
  5660. /**
  5661. * Creates a new skeleton from serialized data
  5662. * @param parsedSkeleton defines the serialized data
  5663. * @param scene defines the hosting scene
  5664. * @returns a new skeleton
  5665. */
  5666. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5667. /**
  5668. * Compute all node absolute transforms
  5669. * @param forceUpdate defines if computation must be done even if cache is up to date
  5670. */
  5671. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5672. /**
  5673. * Gets the root pose matrix
  5674. * @returns a matrix
  5675. */
  5676. getPoseMatrix(): Nullable<Matrix>;
  5677. /**
  5678. * Sorts bones per internal index
  5679. */
  5680. sortBones(): void;
  5681. private _sortBones;
  5682. }
  5683. }
  5684. declare module BABYLON {
  5685. class ArcRotateCamera extends TargetCamera {
  5686. alpha: number;
  5687. beta: number;
  5688. radius: number;
  5689. protected _target: Vector3;
  5690. protected _targetHost: Nullable<AbstractMesh>;
  5691. target: Vector3;
  5692. inertialAlphaOffset: number;
  5693. inertialBetaOffset: number;
  5694. inertialRadiusOffset: number;
  5695. lowerAlphaLimit: Nullable<number>;
  5696. upperAlphaLimit: Nullable<number>;
  5697. lowerBetaLimit: number;
  5698. upperBetaLimit: number;
  5699. lowerRadiusLimit: Nullable<number>;
  5700. upperRadiusLimit: Nullable<number>;
  5701. inertialPanningX: number;
  5702. inertialPanningY: number;
  5703. pinchToPanMaxDistance: number;
  5704. panningDistanceLimit: Nullable<number>;
  5705. panningOriginTarget: Vector3;
  5706. panningInertia: number;
  5707. angularSensibilityX: number;
  5708. angularSensibilityY: number;
  5709. pinchPrecision: number;
  5710. pinchDeltaPercentage: number;
  5711. panningSensibility: number;
  5712. keysUp: number[];
  5713. keysDown: number[];
  5714. keysLeft: number[];
  5715. keysRight: number[];
  5716. wheelPrecision: number;
  5717. wheelDeltaPercentage: number;
  5718. zoomOnFactor: number;
  5719. targetScreenOffset: Vector2;
  5720. allowUpsideDown: boolean;
  5721. /** @hidden */
  5722. _viewMatrix: Matrix;
  5723. /** @hidden */
  5724. _useCtrlForPanning: boolean;
  5725. /** @hidden */
  5726. _panningMouseButton: number;
  5727. inputs: ArcRotateCameraInputsManager;
  5728. /** @hidden */
  5729. _reset: () => void;
  5730. panningAxis: Vector3;
  5731. protected _localDirection: Vector3;
  5732. protected _transformedDirection: Vector3;
  5733. private _bouncingBehavior;
  5734. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5735. useBouncingBehavior: boolean;
  5736. private _framingBehavior;
  5737. readonly framingBehavior: Nullable<FramingBehavior>;
  5738. useFramingBehavior: boolean;
  5739. private _autoRotationBehavior;
  5740. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5741. useAutoRotationBehavior: boolean;
  5742. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5743. onCollide: (collidedMesh: AbstractMesh) => void;
  5744. checkCollisions: boolean;
  5745. collisionRadius: Vector3;
  5746. protected _collider: Collider;
  5747. protected _previousPosition: Vector3;
  5748. protected _collisionVelocity: Vector3;
  5749. protected _newPosition: Vector3;
  5750. protected _previousAlpha: number;
  5751. protected _previousBeta: number;
  5752. protected _previousRadius: number;
  5753. protected _collisionTriggered: boolean;
  5754. protected _targetBoundingCenter: Nullable<Vector3>;
  5755. private _computationVector;
  5756. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5757. /** @hidden */
  5758. _initCache(): void;
  5759. /** @hidden */
  5760. _updateCache(ignoreParentClass?: boolean): void;
  5761. protected _getTargetPosition(): Vector3;
  5762. /**
  5763. * Store current camera state (fov, position, etc..)
  5764. */
  5765. private _storedAlpha;
  5766. private _storedBeta;
  5767. private _storedRadius;
  5768. private _storedTarget;
  5769. storeState(): Camera;
  5770. /**
  5771. * @hidden
  5772. * Restored camera state. You must call storeState() first
  5773. */
  5774. _restoreStateValues(): boolean;
  5775. /** @hidden */
  5776. _isSynchronizedViewMatrix(): boolean;
  5777. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5778. detachControl(element: HTMLElement): void;
  5779. /** @hidden */
  5780. _checkInputs(): void;
  5781. protected _checkLimits(): void;
  5782. rebuildAnglesAndRadius(): void;
  5783. setPosition(position: Vector3): void;
  5784. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5785. /** @hidden */
  5786. _getViewMatrix(): Matrix;
  5787. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5788. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5789. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5790. min: Vector3;
  5791. max: Vector3;
  5792. distance: number;
  5793. }, doNotUpdateMaxZ?: boolean): void;
  5794. /**
  5795. * @override
  5796. * Override Camera.createRigCamera
  5797. */
  5798. createRigCamera(name: string, cameraIndex: number): Camera;
  5799. /**
  5800. * @hidden
  5801. * @override
  5802. * Override Camera._updateRigCameras
  5803. */
  5804. _updateRigCameras(): void;
  5805. dispose(): void;
  5806. getClassName(): string;
  5807. }
  5808. }
  5809. declare module BABYLON {
  5810. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5811. constructor(camera: ArcRotateCamera);
  5812. addMouseWheel(): ArcRotateCameraInputsManager;
  5813. addPointers(): ArcRotateCameraInputsManager;
  5814. addKeyboard(): ArcRotateCameraInputsManager;
  5815. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5816. }
  5817. }
  5818. declare module BABYLON {
  5819. class Camera extends Node {
  5820. inputs: CameraInputsManager<Camera>;
  5821. private static _PERSPECTIVE_CAMERA;
  5822. private static _ORTHOGRAPHIC_CAMERA;
  5823. private static _FOVMODE_VERTICAL_FIXED;
  5824. private static _FOVMODE_HORIZONTAL_FIXED;
  5825. private static _RIG_MODE_NONE;
  5826. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5827. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5828. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5829. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5830. private static _RIG_MODE_VR;
  5831. private static _RIG_MODE_WEBVR;
  5832. static readonly PERSPECTIVE_CAMERA: number;
  5833. static readonly ORTHOGRAPHIC_CAMERA: number;
  5834. /**
  5835. * This is the default FOV mode for perspective cameras.
  5836. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5837. *
  5838. */
  5839. static readonly FOVMODE_VERTICAL_FIXED: number;
  5840. /**
  5841. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5842. *
  5843. */
  5844. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5845. static readonly RIG_MODE_NONE: number;
  5846. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5847. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5848. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5849. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5850. static readonly RIG_MODE_VR: number;
  5851. static readonly RIG_MODE_WEBVR: number;
  5852. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5853. static UseAlternateWebVRRendering: boolean;
  5854. position: Vector3;
  5855. /**
  5856. * The vector the camera should consider as up.
  5857. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5858. */
  5859. upVector: Vector3;
  5860. orthoLeft: Nullable<number>;
  5861. orthoRight: Nullable<number>;
  5862. orthoBottom: Nullable<number>;
  5863. orthoTop: Nullable<number>;
  5864. /**
  5865. * FOV is set in Radians. (default is 0.8)
  5866. */
  5867. fov: number;
  5868. minZ: number;
  5869. maxZ: number;
  5870. inertia: number;
  5871. mode: number;
  5872. isIntermediate: boolean;
  5873. viewport: Viewport;
  5874. /**
  5875. * Restricts the camera to viewing objects with the same layerMask.
  5876. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5877. */
  5878. layerMask: number;
  5879. /**
  5880. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5881. */
  5882. fovMode: number;
  5883. cameraRigMode: number;
  5884. interaxialDistance: number;
  5885. isStereoscopicSideBySide: boolean;
  5886. /** @hidden */
  5887. _cameraRigParams: any;
  5888. /** @hidden */
  5889. _rigCameras: Camera[];
  5890. /** @hidden */
  5891. _rigPostProcess: Nullable<PostProcess>;
  5892. protected _webvrViewMatrix: Matrix;
  5893. /** @hidden */
  5894. _skipRendering: boolean;
  5895. /** @hidden */
  5896. _alternateCamera: Camera;
  5897. customRenderTargets: RenderTargetTexture[];
  5898. onViewMatrixChangedObservable: Observable<Camera>;
  5899. onProjectionMatrixChangedObservable: Observable<Camera>;
  5900. onAfterCheckInputsObservable: Observable<Camera>;
  5901. onRestoreStateObservable: Observable<Camera>;
  5902. private _computedViewMatrix;
  5903. _projectionMatrix: Matrix;
  5904. private _doNotComputeProjectionMatrix;
  5905. private _worldMatrix;
  5906. _postProcesses: Nullable<PostProcess>[];
  5907. private _transformMatrix;
  5908. _activeMeshes: SmartArray<AbstractMesh>;
  5909. protected _globalPosition: Vector3;
  5910. private _frustumPlanes;
  5911. private _refreshFrustumPlanes;
  5912. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5913. private _storedFov;
  5914. private _stateStored;
  5915. /**
  5916. * Store current camera state (fov, position, etc..)
  5917. */
  5918. storeState(): Camera;
  5919. /**
  5920. * Restores the camera state values if it has been stored. You must call storeState() first
  5921. */
  5922. protected _restoreStateValues(): boolean;
  5923. /**
  5924. * Restored camera state. You must call storeState() first
  5925. */
  5926. restoreState(): boolean;
  5927. getClassName(): string;
  5928. /**
  5929. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5930. */
  5931. toString(fullDetails?: boolean): string;
  5932. readonly globalPosition: Vector3;
  5933. getActiveMeshes(): SmartArray<AbstractMesh>;
  5934. isActiveMesh(mesh: Mesh): boolean;
  5935. /**
  5936. * Is this camera ready to be used/rendered
  5937. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5938. * @return true if the camera is ready
  5939. */
  5940. isReady(completeCheck?: boolean): boolean;
  5941. /** @hidden */
  5942. _initCache(): void;
  5943. /** @hidden */
  5944. _updateCache(ignoreParentClass?: boolean): void;
  5945. /** @hidden */
  5946. _isSynchronized(): boolean;
  5947. /** @hidden */
  5948. _isSynchronizedViewMatrix(): boolean;
  5949. /** @hidden */
  5950. _isSynchronizedProjectionMatrix(): boolean;
  5951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5952. detachControl(element: HTMLElement): void;
  5953. update(): void;
  5954. /** @hidden */
  5955. _checkInputs(): void;
  5956. readonly rigCameras: Camera[];
  5957. readonly rigPostProcess: Nullable<PostProcess>;
  5958. /**
  5959. * Internal, gets the first post proces.
  5960. * @returns the first post process to be run on this camera.
  5961. */
  5962. _getFirstPostProcess(): Nullable<PostProcess>;
  5963. private _cascadePostProcessesToRigCams;
  5964. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5965. detachPostProcess(postProcess: PostProcess): void;
  5966. getWorldMatrix(): Matrix;
  5967. /** @hidden */
  5968. _getViewMatrix(): Matrix;
  5969. getViewMatrix(force?: boolean): Matrix;
  5970. freezeProjectionMatrix(projection?: Matrix): void;
  5971. unfreezeProjectionMatrix(): void;
  5972. getProjectionMatrix(force?: boolean): Matrix;
  5973. /**
  5974. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5975. * @returns a Matrix
  5976. */
  5977. getTransformationMatrix(): Matrix;
  5978. private updateFrustumPlanes;
  5979. isInFrustum(target: ICullable): boolean;
  5980. isCompletelyInFrustum(target: ICullable): boolean;
  5981. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5982. /**
  5983. * Releases resources associated with this node.
  5984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5986. */
  5987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5988. readonly leftCamera: Nullable<FreeCamera>;
  5989. readonly rightCamera: Nullable<FreeCamera>;
  5990. getLeftTarget(): Nullable<Vector3>;
  5991. getRightTarget(): Nullable<Vector3>;
  5992. setCameraRigMode(mode: number, rigParams: any): void;
  5993. private _getVRProjectionMatrix;
  5994. protected _updateCameraRotationMatrix(): void;
  5995. protected _updateWebVRCameraRotationMatrix(): void;
  5996. /**
  5997. * This function MUST be overwritten by the different WebVR cameras available.
  5998. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5999. */
  6000. protected _getWebVRProjectionMatrix(): Matrix;
  6001. /**
  6002. * This function MUST be overwritten by the different WebVR cameras available.
  6003. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6004. */
  6005. protected _getWebVRViewMatrix(): Matrix;
  6006. setCameraRigParameter(name: string, value: any): void;
  6007. /**
  6008. * needs to be overridden by children so sub has required properties to be copied
  6009. */
  6010. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6011. /**
  6012. * May need to be overridden by children
  6013. * @hidden
  6014. */
  6015. _updateRigCameras(): void;
  6016. /** @hidden */
  6017. _setupInputs(): void;
  6018. serialize(): any;
  6019. clone(name: string): Camera;
  6020. getDirection(localAxis: Vector3): Vector3;
  6021. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6022. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6023. computeWorldMatrix(): Matrix;
  6024. static Parse(parsedCamera: any, scene: Scene): Camera;
  6025. }
  6026. }
  6027. declare module BABYLON {
  6028. var CameraInputTypes: {};
  6029. interface ICameraInput<TCamera extends Camera> {
  6030. camera: Nullable<TCamera>;
  6031. getClassName(): string;
  6032. getSimpleName(): string;
  6033. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6034. detachControl: (element: Nullable<HTMLElement>) => void;
  6035. checkInputs?: () => void;
  6036. }
  6037. interface CameraInputsMap<TCamera extends Camera> {
  6038. [name: string]: ICameraInput<TCamera>;
  6039. [idx: number]: ICameraInput<TCamera>;
  6040. }
  6041. class CameraInputsManager<TCamera extends Camera> {
  6042. attached: CameraInputsMap<TCamera>;
  6043. attachedElement: Nullable<HTMLElement>;
  6044. noPreventDefault: boolean;
  6045. camera: TCamera;
  6046. checkInputs: () => void;
  6047. constructor(camera: TCamera);
  6048. /**
  6049. * Add an input method to a camera
  6050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6051. * @param input camera input method
  6052. */
  6053. add(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Remove a specific input method from a camera
  6056. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6057. * @param inputToRemove camera input method
  6058. */
  6059. remove(inputToRemove: ICameraInput<TCamera>): void;
  6060. removeByType(inputType: string): void;
  6061. private _addCheckInputs;
  6062. attachInput(input: ICameraInput<TCamera>): void;
  6063. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6064. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6065. rebuildInputCheck(): void;
  6066. /**
  6067. * Remove all attached input methods from a camera
  6068. */
  6069. clear(): void;
  6070. serialize(serializedCamera: any): void;
  6071. parse(parsedCamera: any): void;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. /**
  6076. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6077. * being tilted forward or back and left or right.
  6078. */
  6079. class DeviceOrientationCamera extends FreeCamera {
  6080. private _initialQuaternion;
  6081. private _quaternionCache;
  6082. /**
  6083. * Creates a new device orientation camera
  6084. * @param name The name of the camera
  6085. * @param position The start position camera
  6086. * @param scene The scene the camera belongs to
  6087. */
  6088. constructor(name: string, position: Vector3, scene: Scene);
  6089. /**
  6090. * Gets the current instance class name ("DeviceOrientationCamera").
  6091. * This helps avoiding instanceof at run time.
  6092. * @returns the class name
  6093. */
  6094. getClassName(): string;
  6095. /**
  6096. * @hidden
  6097. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6098. */
  6099. _checkInputs(): void;
  6100. /**
  6101. * Reset the camera to its default orientation on the specified axis only.
  6102. * @param axis The axis to reset
  6103. */
  6104. resetToCurrentRotation(axis?: Axis): void;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. class FollowCamera extends TargetCamera {
  6109. radius: number;
  6110. rotationOffset: number;
  6111. heightOffset: number;
  6112. cameraAcceleration: number;
  6113. maxCameraSpeed: number;
  6114. lockedTarget: Nullable<AbstractMesh>;
  6115. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6116. private getRadians;
  6117. private follow;
  6118. /** @hidden */
  6119. _checkInputs(): void;
  6120. getClassName(): string;
  6121. }
  6122. class ArcFollowCamera extends TargetCamera {
  6123. alpha: number;
  6124. beta: number;
  6125. radius: number;
  6126. target: Nullable<AbstractMesh>;
  6127. private _cartesianCoordinates;
  6128. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6129. private follow;
  6130. /** @hidden */
  6131. _checkInputs(): void;
  6132. getClassName(): string;
  6133. }
  6134. }
  6135. declare module BABYLON {
  6136. class FreeCamera extends TargetCamera {
  6137. ellipsoid: Vector3;
  6138. ellipsoidOffset: Vector3;
  6139. checkCollisions: boolean;
  6140. applyGravity: boolean;
  6141. inputs: FreeCameraInputsManager;
  6142. /**
  6143. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6144. * Higher values reduce sensitivity.
  6145. */
  6146. /**
  6147. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6148. * Higher values reduce sensitivity.
  6149. */
  6150. angularSensibility: number;
  6151. keysUp: number[];
  6152. keysDown: number[];
  6153. keysLeft: number[];
  6154. keysRight: number[];
  6155. onCollide: (collidedMesh: AbstractMesh) => void;
  6156. private _collider;
  6157. private _needMoveForGravity;
  6158. private _oldPosition;
  6159. private _diffPosition;
  6160. private _newPosition;
  6161. /** @hidden */
  6162. _localDirection: Vector3;
  6163. /** @hidden */
  6164. _transformedDirection: Vector3;
  6165. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6167. detachControl(element: HTMLElement): void;
  6168. private _collisionMask;
  6169. collisionMask: number;
  6170. /** @hidden */
  6171. _collideWithWorld(displacement: Vector3): void;
  6172. private _onCollisionPositionChange;
  6173. /** @hidden */
  6174. _checkInputs(): void;
  6175. /** @hidden */
  6176. _decideIfNeedsToMove(): boolean;
  6177. /** @hidden */
  6178. _updatePosition(): void;
  6179. dispose(): void;
  6180. getClassName(): string;
  6181. }
  6182. }
  6183. declare module BABYLON {
  6184. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6185. constructor(camera: FreeCamera);
  6186. addKeyboard(): FreeCameraInputsManager;
  6187. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6188. addDeviceOrientation(): FreeCameraInputsManager;
  6189. addTouch(): FreeCameraInputsManager;
  6190. addVirtualJoystick(): FreeCameraInputsManager;
  6191. }
  6192. }
  6193. declare module BABYLON {
  6194. class GamepadCamera extends UniversalCamera {
  6195. gamepadAngularSensibility: number;
  6196. gamepadMoveSensibility: number;
  6197. constructor(name: string, position: Vector3, scene: Scene);
  6198. getClassName(): string;
  6199. }
  6200. }
  6201. declare module BABYLON {
  6202. class TargetCamera extends Camera {
  6203. cameraDirection: Vector3;
  6204. cameraRotation: Vector2;
  6205. rotation: Vector3;
  6206. rotationQuaternion: Quaternion;
  6207. speed: number;
  6208. noRotationConstraint: boolean;
  6209. lockedTarget: any;
  6210. /** @hidden */
  6211. _currentTarget: Vector3;
  6212. /** @hidden */
  6213. _viewMatrix: Matrix;
  6214. /** @hidden */
  6215. _camMatrix: Matrix;
  6216. /** @hidden */
  6217. _cameraTransformMatrix: Matrix;
  6218. /** @hidden */
  6219. _cameraRotationMatrix: Matrix;
  6220. private _rigCamTransformMatrix;
  6221. /** @hidden */
  6222. _referencePoint: Vector3;
  6223. /** @hidden */
  6224. _transformedReferencePoint: Vector3;
  6225. protected _globalCurrentTarget: Vector3;
  6226. protected _globalCurrentUpVector: Vector3;
  6227. /** @hidden */
  6228. _reset: () => void;
  6229. private _defaultUp;
  6230. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6231. getFrontPosition(distance: number): Vector3;
  6232. /** @hidden */
  6233. _getLockedTargetPosition(): Nullable<Vector3>;
  6234. /**
  6235. * Store current camera state (fov, position, etc..)
  6236. */
  6237. private _storedPosition;
  6238. private _storedRotation;
  6239. private _storedRotationQuaternion;
  6240. storeState(): Camera;
  6241. /**
  6242. * Restored camera state. You must call storeState() first
  6243. * @returns whether it was successful or not
  6244. * @hidden
  6245. */
  6246. _restoreStateValues(): boolean;
  6247. /** @hidden */
  6248. _initCache(): void;
  6249. /** @hidden */
  6250. _updateCache(ignoreParentClass?: boolean): void;
  6251. /** @hidden */
  6252. _isSynchronizedViewMatrix(): boolean;
  6253. /** @hidden */
  6254. _computeLocalCameraSpeed(): number;
  6255. /** @hidden */
  6256. setTarget(target: Vector3): void;
  6257. /**
  6258. * Return the current target position of the camera. This value is expressed in local space.
  6259. */
  6260. getTarget(): Vector3;
  6261. /** @hidden */
  6262. _decideIfNeedsToMove(): boolean;
  6263. /** @hidden */
  6264. _updatePosition(): void;
  6265. /** @hidden */
  6266. _checkInputs(): void;
  6267. protected _updateCameraRotationMatrix(): void;
  6268. /**
  6269. * 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)
  6270. * @returns the current camera
  6271. */
  6272. private _rotateUpVectorWithCameraRotationMatrix;
  6273. private _cachedRotationZ;
  6274. /** @hidden */
  6275. _getViewMatrix(): Matrix;
  6276. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6277. /**
  6278. * @override
  6279. * Override Camera.createRigCamera
  6280. */
  6281. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6282. /**
  6283. * @hidden
  6284. * @override
  6285. * Override Camera._updateRigCameras
  6286. */
  6287. _updateRigCameras(): void;
  6288. private _getRigCamPosition;
  6289. getClassName(): string;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. class TouchCamera extends FreeCamera {
  6294. touchAngularSensibility: number;
  6295. touchMoveSensibility: number;
  6296. constructor(name: string, position: Vector3, scene: Scene);
  6297. getClassName(): string;
  6298. /** @hidden */
  6299. _setupInputs(): void;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. class UniversalCamera extends TouchCamera {
  6304. gamepadAngularSensibility: number;
  6305. gamepadMoveSensibility: number;
  6306. constructor(name: string, position: Vector3, scene: Scene);
  6307. getClassName(): string;
  6308. }
  6309. }
  6310. declare module BABYLON {
  6311. class VirtualJoysticksCamera extends FreeCamera {
  6312. constructor(name: string, position: Vector3, scene: Scene);
  6313. getClassName(): string;
  6314. }
  6315. }
  6316. interface VRDisplay extends EventTarget {
  6317. /**
  6318. * Dictionary of capabilities describing the VRDisplay.
  6319. */
  6320. readonly capabilities: VRDisplayCapabilities;
  6321. /**
  6322. * z-depth defining the far plane of the eye view frustum
  6323. * enables mapping of values in the render target depth
  6324. * attachment to scene coordinates. Initially set to 10000.0.
  6325. */
  6326. depthFar: number;
  6327. /**
  6328. * z-depth defining the near plane of the eye view frustum
  6329. * enables mapping of values in the render target depth
  6330. * attachment to scene coordinates. Initially set to 0.01.
  6331. */
  6332. depthNear: number;
  6333. /**
  6334. * An identifier for this distinct VRDisplay. Used as an
  6335. * association point in the Gamepad API.
  6336. */
  6337. readonly displayId: number;
  6338. /**
  6339. * A display name, a user-readable name identifying it.
  6340. */
  6341. readonly displayName: string;
  6342. readonly isConnected: boolean;
  6343. readonly isPresenting: boolean;
  6344. /**
  6345. * If this VRDisplay supports room-scale experiences, the optional
  6346. * stage attribute contains details on the room-scale parameters.
  6347. */
  6348. readonly stageParameters: VRStageParameters | null;
  6349. /**
  6350. * Passing the value returned by `requestAnimationFrame` to
  6351. * `cancelAnimationFrame` will unregister the callback.
  6352. */
  6353. cancelAnimationFrame(handle: number): void;
  6354. /**
  6355. * Stops presenting to the VRDisplay.
  6356. */
  6357. exitPresent(): Promise<void>;
  6358. getEyeParameters(whichEye: string): VREyeParameters;
  6359. /**
  6360. * Populates the passed VRFrameData with the information required to render
  6361. * the current frame.
  6362. */
  6363. getFrameData(frameData: VRFrameData): boolean;
  6364. /**
  6365. * Get the layers currently being presented.
  6366. */
  6367. getLayers(): VRLayer[];
  6368. /**
  6369. * Return a VRPose containing the future predicted pose of the VRDisplay
  6370. * when the current frame will be presented. The value returned will not
  6371. * change until JavaScript has returned control to the browser.
  6372. *
  6373. * The VRPose will contain the position, orientation, velocity,
  6374. * and acceleration of each of these properties.
  6375. */
  6376. getPose(): VRPose;
  6377. /**
  6378. * Return the current instantaneous pose of the VRDisplay, with no
  6379. * prediction applied.
  6380. */
  6381. getImmediatePose(): VRPose;
  6382. /**
  6383. * The callback passed to `requestAnimationFrame` will be called
  6384. * any time a new frame should be rendered. When the VRDisplay is
  6385. * presenting the callback will be called at the native refresh
  6386. * rate of the HMD. When not presenting this function acts
  6387. * identically to how window.requestAnimationFrame acts. Content should
  6388. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6389. * asynchronously from other displays and at differing refresh rates.
  6390. */
  6391. requestAnimationFrame(callback: FrameRequestCallback): number;
  6392. /**
  6393. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6394. * Repeat calls while already presenting will update the VRLayers being displayed.
  6395. */
  6396. requestPresent(layers: VRLayer[]): Promise<void>;
  6397. /**
  6398. * Reset the pose for this display, treating its current position and
  6399. * orientation as the "origin/zero" values. VRPose.position,
  6400. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6401. * updated when calling resetPose(). This should be called in only
  6402. * sitting-space experiences.
  6403. */
  6404. resetPose(): void;
  6405. /**
  6406. * The VRLayer provided to the VRDisplay will be captured and presented
  6407. * in the HMD. Calling this function has the same effect on the source
  6408. * canvas as any other operation that uses its source image, and canvases
  6409. * created without preserveDrawingBuffer set to true will be cleared.
  6410. */
  6411. submitFrame(pose?: VRPose): void;
  6412. }
  6413. declare var VRDisplay: {
  6414. prototype: VRDisplay;
  6415. new (): VRDisplay;
  6416. };
  6417. interface VRLayer {
  6418. leftBounds?: number[] | Float32Array | null;
  6419. rightBounds?: number[] | Float32Array | null;
  6420. source?: HTMLCanvasElement | null;
  6421. }
  6422. interface VRDisplayCapabilities {
  6423. readonly canPresent: boolean;
  6424. readonly hasExternalDisplay: boolean;
  6425. readonly hasOrientation: boolean;
  6426. readonly hasPosition: boolean;
  6427. readonly maxLayers: number;
  6428. }
  6429. interface VREyeParameters {
  6430. /** @deprecated */
  6431. readonly fieldOfView: VRFieldOfView;
  6432. readonly offset: Float32Array;
  6433. readonly renderHeight: number;
  6434. readonly renderWidth: number;
  6435. }
  6436. interface VRFieldOfView {
  6437. readonly downDegrees: number;
  6438. readonly leftDegrees: number;
  6439. readonly rightDegrees: number;
  6440. readonly upDegrees: number;
  6441. }
  6442. interface VRFrameData {
  6443. readonly leftProjectionMatrix: Float32Array;
  6444. readonly leftViewMatrix: Float32Array;
  6445. readonly pose: VRPose;
  6446. readonly rightProjectionMatrix: Float32Array;
  6447. readonly rightViewMatrix: Float32Array;
  6448. readonly timestamp: number;
  6449. }
  6450. interface VRPose {
  6451. readonly angularAcceleration: Float32Array | null;
  6452. readonly angularVelocity: Float32Array | null;
  6453. readonly linearAcceleration: Float32Array | null;
  6454. readonly linearVelocity: Float32Array | null;
  6455. readonly orientation: Float32Array | null;
  6456. readonly position: Float32Array | null;
  6457. readonly timestamp: number;
  6458. }
  6459. interface VRStageParameters {
  6460. sittingToStandingTransform?: Float32Array;
  6461. sizeX?: number;
  6462. sizeY?: number;
  6463. }
  6464. interface Navigator {
  6465. getVRDisplays(): Promise<VRDisplay[]>;
  6466. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6467. }
  6468. interface Window {
  6469. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6470. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6471. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6472. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6473. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6474. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6475. }
  6476. interface Gamepad {
  6477. readonly displayId: number;
  6478. }
  6479. declare module BABYLON {
  6480. class Collider {
  6481. /** Define if a collision was found */
  6482. collisionFound: boolean;
  6483. /**
  6484. * Define last intersection point in local space
  6485. */
  6486. intersectionPoint: Vector3;
  6487. /**
  6488. * Define last collided mesh
  6489. */
  6490. collidedMesh: Nullable<AbstractMesh>;
  6491. private _collisionPoint;
  6492. private _planeIntersectionPoint;
  6493. private _tempVector;
  6494. private _tempVector2;
  6495. private _tempVector3;
  6496. private _tempVector4;
  6497. private _edge;
  6498. private _baseToVertex;
  6499. private _destinationPoint;
  6500. private _slidePlaneNormal;
  6501. private _displacementVector;
  6502. /** @hidden */
  6503. _radius: Vector3;
  6504. /** @hidden */
  6505. _retry: number;
  6506. private _velocity;
  6507. private _basePoint;
  6508. private _epsilon;
  6509. /** @hidden */
  6510. _velocityWorldLength: number;
  6511. /** @hidden */
  6512. _basePointWorld: Vector3;
  6513. private _velocityWorld;
  6514. private _normalizedVelocity;
  6515. /** @hidden */
  6516. _initialVelocity: Vector3;
  6517. /** @hidden */
  6518. _initialPosition: Vector3;
  6519. private _nearestDistance;
  6520. private _collisionMask;
  6521. collisionMask: number;
  6522. /**
  6523. * Gets the plane normal used to compute the sliding response (in local space)
  6524. */
  6525. readonly slidePlaneNormal: Vector3;
  6526. /** @hidden */
  6527. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6528. /** @hidden */
  6529. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6530. /** @hidden */
  6531. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6532. /** @hidden */
  6533. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6534. /** @hidden */
  6535. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6536. /** @hidden */
  6537. _getResponse(pos: Vector3, vel: Vector3): void;
  6538. }
  6539. }
  6540. declare module BABYLON {
  6541. var CollisionWorker: string;
  6542. interface ICollisionCoordinator {
  6543. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6544. init(scene: Scene): void;
  6545. destroy(): void;
  6546. onMeshAdded(mesh: AbstractMesh): void;
  6547. onMeshUpdated(mesh: AbstractMesh): void;
  6548. onMeshRemoved(mesh: AbstractMesh): void;
  6549. onGeometryAdded(geometry: Geometry): void;
  6550. onGeometryUpdated(geometry: Geometry): void;
  6551. onGeometryDeleted(geometry: Geometry): void;
  6552. }
  6553. interface SerializedMesh {
  6554. id: string;
  6555. name: string;
  6556. uniqueId: number;
  6557. geometryId: Nullable<string>;
  6558. sphereCenter: Array<number>;
  6559. sphereRadius: number;
  6560. boxMinimum: Array<number>;
  6561. boxMaximum: Array<number>;
  6562. worldMatrixFromCache: any;
  6563. subMeshes: Array<SerializedSubMesh>;
  6564. checkCollisions: boolean;
  6565. }
  6566. interface SerializedSubMesh {
  6567. position: number;
  6568. verticesStart: number;
  6569. verticesCount: number;
  6570. indexStart: number;
  6571. indexCount: number;
  6572. hasMaterial: boolean;
  6573. sphereCenter: Array<number>;
  6574. sphereRadius: number;
  6575. boxMinimum: Array<number>;
  6576. boxMaximum: Array<number>;
  6577. }
  6578. /**
  6579. * Interface describing the value associated with a geometry
  6580. */
  6581. interface SerializedGeometry {
  6582. /**
  6583. * Defines the unique ID of the geometry
  6584. */
  6585. id: string;
  6586. /**
  6587. * Defines the array containing the positions
  6588. */
  6589. positions: Float32Array;
  6590. /**
  6591. * Defines the array containing the indices
  6592. */
  6593. indices: Uint32Array;
  6594. /**
  6595. * Defines the array containing the normals
  6596. */
  6597. normals: Float32Array;
  6598. }
  6599. interface BabylonMessage {
  6600. taskType: WorkerTaskType;
  6601. payload: InitPayload | CollidePayload | UpdatePayload;
  6602. }
  6603. interface SerializedColliderToWorker {
  6604. position: Array<number>;
  6605. velocity: Array<number>;
  6606. radius: Array<number>;
  6607. }
  6608. /** Defines supported task for worker process */
  6609. enum WorkerTaskType {
  6610. /** Initialization */
  6611. INIT = 0,
  6612. /** Update of geometry */
  6613. UPDATE = 1,
  6614. /** Evaluate collision */
  6615. COLLIDE = 2
  6616. }
  6617. interface WorkerReply {
  6618. error: WorkerReplyType;
  6619. taskType: WorkerTaskType;
  6620. payload?: any;
  6621. }
  6622. interface CollisionReplyPayload {
  6623. newPosition: Array<number>;
  6624. collisionId: number;
  6625. collidedMeshUniqueId: number;
  6626. }
  6627. interface InitPayload {
  6628. }
  6629. interface CollidePayload {
  6630. collisionId: number;
  6631. collider: SerializedColliderToWorker;
  6632. maximumRetry: number;
  6633. excludedMeshUniqueId: Nullable<number>;
  6634. }
  6635. interface UpdatePayload {
  6636. updatedMeshes: {
  6637. [n: number]: SerializedMesh;
  6638. };
  6639. updatedGeometries: {
  6640. [s: string]: SerializedGeometry;
  6641. };
  6642. removedMeshes: Array<number>;
  6643. removedGeometries: Array<string>;
  6644. }
  6645. /** Defines kind of replies returned by worker */
  6646. enum WorkerReplyType {
  6647. /** Success */
  6648. SUCCESS = 0,
  6649. /** Unkown error */
  6650. UNKNOWN_ERROR = 1
  6651. }
  6652. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6653. private _scene;
  6654. private _scaledPosition;
  6655. private _scaledVelocity;
  6656. private _collisionsCallbackArray;
  6657. private _init;
  6658. private _runningUpdated;
  6659. private _worker;
  6660. private _addUpdateMeshesList;
  6661. private _addUpdateGeometriesList;
  6662. private _toRemoveMeshesArray;
  6663. private _toRemoveGeometryArray;
  6664. constructor();
  6665. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6666. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6667. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6668. init(scene: Scene): void;
  6669. destroy(): void;
  6670. onMeshAdded(mesh: AbstractMesh): void;
  6671. onMeshUpdated: (transformNode: TransformNode) => void;
  6672. onMeshRemoved(mesh: AbstractMesh): void;
  6673. onGeometryAdded(geometry: Geometry): void;
  6674. onGeometryUpdated: (geometry: Geometry) => void;
  6675. onGeometryDeleted(geometry: Geometry): void;
  6676. private _afterRender;
  6677. private _onMessageFromWorker;
  6678. }
  6679. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6680. private _scene;
  6681. private _scaledPosition;
  6682. private _scaledVelocity;
  6683. private _finalPosition;
  6684. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6685. init(scene: Scene): void;
  6686. destroy(): void;
  6687. onMeshAdded(mesh: AbstractMesh): void;
  6688. onMeshUpdated(mesh: AbstractMesh): void;
  6689. onMeshRemoved(mesh: AbstractMesh): void;
  6690. onGeometryAdded(geometry: Geometry): void;
  6691. onGeometryUpdated(geometry: Geometry): void;
  6692. onGeometryDeleted(geometry: Geometry): void;
  6693. private _collideWithWorld;
  6694. }
  6695. }
  6696. declare function importScripts(...urls: string[]): void;
  6697. declare const safePostMessage: any;
  6698. declare module BABYLON {
  6699. var WorkerIncluded: boolean;
  6700. class CollisionCache {
  6701. private _meshes;
  6702. private _geometries;
  6703. getMeshes(): {
  6704. [n: number]: SerializedMesh;
  6705. };
  6706. getGeometries(): {
  6707. [s: number]: SerializedGeometry;
  6708. };
  6709. getMesh(id: any): SerializedMesh;
  6710. addMesh(mesh: SerializedMesh): void;
  6711. removeMesh(uniqueId: number): void;
  6712. getGeometry(id: string): SerializedGeometry;
  6713. addGeometry(geometry: SerializedGeometry): void;
  6714. removeGeometry(id: string): void;
  6715. }
  6716. class CollideWorker {
  6717. collider: Collider;
  6718. private _collisionCache;
  6719. private finalPosition;
  6720. private collisionsScalingMatrix;
  6721. private collisionTranformationMatrix;
  6722. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6723. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6724. private checkCollision;
  6725. private processCollisionsForSubMeshes;
  6726. private collideForSubMesh;
  6727. private checkSubmeshCollision;
  6728. }
  6729. interface ICollisionDetector {
  6730. onInit(payload: InitPayload): void;
  6731. onUpdate(payload: UpdatePayload): void;
  6732. onCollision(payload: CollidePayload): void;
  6733. }
  6734. class CollisionDetectorTransferable implements ICollisionDetector {
  6735. private _collisionCache;
  6736. onInit(payload: InitPayload): void;
  6737. onUpdate(payload: UpdatePayload): void;
  6738. onCollision(payload: CollidePayload): void;
  6739. }
  6740. }
  6741. declare module BABYLON {
  6742. class IntersectionInfo {
  6743. bu: Nullable<number>;
  6744. bv: Nullable<number>;
  6745. distance: number;
  6746. faceId: number;
  6747. subMeshId: number;
  6748. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6749. }
  6750. /**
  6751. * Information about the result of picking within a scene
  6752. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6753. */
  6754. class PickingInfo {
  6755. /**
  6756. * If the pick collided with an object
  6757. */
  6758. hit: boolean;
  6759. /**
  6760. * Distance away where the pick collided
  6761. */
  6762. distance: number;
  6763. /**
  6764. * The location of pick collision
  6765. */
  6766. pickedPoint: Nullable<Vector3>;
  6767. /**
  6768. * The mesh corresponding the the pick collision
  6769. */
  6770. pickedMesh: Nullable<AbstractMesh>;
  6771. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6772. bu: number;
  6773. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6774. bv: number;
  6775. /** The id of the face on the mesh that was picked */
  6776. faceId: number;
  6777. /** Id of the the submesh that was picked */
  6778. subMeshId: number;
  6779. /** If a sprite was picked, this will be the sprite the pick collided with */
  6780. pickedSprite: Nullable<Sprite>;
  6781. /**
  6782. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6783. */
  6784. originMesh: Nullable<AbstractMesh>;
  6785. /**
  6786. * The ray that was used to perform the picking.
  6787. */
  6788. ray: Nullable<Ray>;
  6789. /**
  6790. * Gets the normal correspodning to the face the pick collided with
  6791. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6792. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6793. * @returns The normal correspodning to the face the pick collided with
  6794. */
  6795. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6796. /**
  6797. * Gets the texture coordinates of where the pick occured
  6798. * @returns the vector containing the coordnates of the texture
  6799. */
  6800. getTextureCoordinates(): Nullable<Vector2>;
  6801. }
  6802. }
  6803. declare module BABYLON {
  6804. class BoundingBox implements ICullable {
  6805. vectors: Vector3[];
  6806. center: Vector3;
  6807. centerWorld: Vector3;
  6808. extendSize: Vector3;
  6809. extendSizeWorld: Vector3;
  6810. directions: Vector3[];
  6811. vectorsWorld: Vector3[];
  6812. minimumWorld: Vector3;
  6813. maximumWorld: Vector3;
  6814. minimum: Vector3;
  6815. maximum: Vector3;
  6816. private _worldMatrix;
  6817. /**
  6818. * Creates a new bounding box
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. */
  6822. constructor(min: Vector3, max: Vector3);
  6823. /**
  6824. * Recreates the entire bounding box from scratch
  6825. * @param min defines the new minimum vector (in local space)
  6826. * @param max defines the new maximum vector (in local space)
  6827. */
  6828. reConstruct(min: Vector3, max: Vector3): void;
  6829. /**
  6830. * Scale the current bounding box by applying a scale factor
  6831. * @param factor defines the scale factor to apply
  6832. * @returns the current bounding box
  6833. */
  6834. scale(factor: number): BoundingBox;
  6835. getWorldMatrix(): Matrix;
  6836. setWorldMatrix(matrix: Matrix): BoundingBox;
  6837. /** @hidden */
  6838. _update(world: Matrix): void;
  6839. isInFrustum(frustumPlanes: Plane[]): boolean;
  6840. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6841. intersectsPoint(point: Vector3): boolean;
  6842. intersectsSphere(sphere: BoundingSphere): boolean;
  6843. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6844. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6845. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6846. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6847. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6848. }
  6849. }
  6850. declare module BABYLON {
  6851. interface ICullable {
  6852. isInFrustum(frustumPlanes: Plane[]): boolean;
  6853. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6854. }
  6855. class BoundingInfo implements ICullable {
  6856. minimum: Vector3;
  6857. maximum: Vector3;
  6858. boundingBox: BoundingBox;
  6859. boundingSphere: BoundingSphere;
  6860. private _isLocked;
  6861. constructor(minimum: Vector3, maximum: Vector3);
  6862. isLocked: boolean;
  6863. update(world: Matrix): void;
  6864. /**
  6865. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6866. * @param center New center of the bounding info
  6867. * @param extend New extend of the bounding info
  6868. */
  6869. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6870. /**
  6871. * Scale the current bounding info by applying a scale factor
  6872. * @param factor defines the scale factor to apply
  6873. * @returns the current bounding info
  6874. */
  6875. scale(factor: number): BoundingInfo;
  6876. /**
  6877. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6878. * @param frustumPlanes defines the frustum to test
  6879. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6880. * @returns true if the bounding info is in the frustum planes
  6881. */
  6882. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6883. /**
  6884. * Gets the world distance between the min and max points of the bounding box
  6885. */
  6886. readonly diagonalLength: number;
  6887. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6888. /** @hidden */
  6889. _checkCollision(collider: Collider): boolean;
  6890. intersectsPoint(point: Vector3): boolean;
  6891. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6892. }
  6893. }
  6894. declare module BABYLON {
  6895. class BoundingSphere {
  6896. center: Vector3;
  6897. radius: number;
  6898. centerWorld: Vector3;
  6899. radiusWorld: number;
  6900. minimum: Vector3;
  6901. maximum: Vector3;
  6902. /**
  6903. * Creates a new bounding sphere
  6904. * @param min defines the minimum vector (in local space)
  6905. * @param max defines the maximum vector (in local space)
  6906. */
  6907. constructor(min: Vector3, max: Vector3);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. */
  6913. reConstruct(min: Vector3, max: Vector3): void;
  6914. /**
  6915. * Scale the current bounding sphere by applying a scale factor
  6916. * @param factor defines the scale factor to apply
  6917. * @returns the current bounding box
  6918. */
  6919. scale(factor: number): BoundingSphere;
  6920. /** @hidden */
  6921. _update(world: Matrix): void;
  6922. isInFrustum(frustumPlanes: Plane[]): boolean;
  6923. intersectsPoint(point: Vector3): boolean;
  6924. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6925. }
  6926. }
  6927. declare module BABYLON {
  6928. class Ray {
  6929. origin: Vector3;
  6930. direction: Vector3;
  6931. length: number;
  6932. private _edge1;
  6933. private _edge2;
  6934. private _pvec;
  6935. private _tvec;
  6936. private _qvec;
  6937. private _tmpRay;
  6938. constructor(origin: Vector3, direction: Vector3, length?: number);
  6939. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6940. intersectsBox(box: BoundingBox): boolean;
  6941. intersectsSphere(sphere: BoundingSphere): boolean;
  6942. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6943. intersectsPlane(plane: Plane): Nullable<number>;
  6944. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6945. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6946. private _comparePickingInfo;
  6947. private static smallnum;
  6948. private static rayl;
  6949. /**
  6950. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6951. * @param sega the first point of the segment to test the intersection against
  6952. * @param segb the second point of the segment to test the intersection against
  6953. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6954. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6955. */
  6956. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6957. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6958. static Zero(): Ray;
  6959. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6960. /**
  6961. * 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
  6962. * transformed to the given world matrix.
  6963. * @param origin The origin point
  6964. * @param end The end point
  6965. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6966. */
  6967. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6968. static Transform(ray: Ray, matrix: Matrix): Ray;
  6969. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * Interface for attribute information associated with buffer instanciation
  6975. */
  6976. class InstancingAttributeInfo {
  6977. /**
  6978. * Index/offset of the attribute in the vertex shader
  6979. */
  6980. index: number;
  6981. /**
  6982. * size of the attribute, 1, 2, 3 or 4
  6983. */
  6984. attributeSize: number;
  6985. /**
  6986. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6987. * default is FLOAT
  6988. */
  6989. attribyteType: number;
  6990. /**
  6991. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6992. */
  6993. normalized: boolean;
  6994. /**
  6995. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6996. */
  6997. offset: number;
  6998. /**
  6999. * Name of the GLSL attribute, for debugging purpose only
  7000. */
  7001. attributeName: string;
  7002. }
  7003. /**
  7004. * Define options used to create a render target texture
  7005. */
  7006. class RenderTargetCreationOptions {
  7007. /**
  7008. * Specifies is mipmaps must be generated
  7009. */
  7010. generateMipMaps?: boolean;
  7011. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7012. generateDepthBuffer?: boolean;
  7013. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7014. generateStencilBuffer?: boolean;
  7015. /** Defines texture type (int by default) */
  7016. type?: number;
  7017. /** Defines sampling mode (trilinear by default) */
  7018. samplingMode?: number;
  7019. /** Defines format (RGBA by default) */
  7020. format?: number;
  7021. }
  7022. /**
  7023. * Define options used to create a depth texture
  7024. */
  7025. class DepthTextureCreationOptions {
  7026. /** Specifies whether or not a stencil should be allocated in the texture */
  7027. generateStencil?: boolean;
  7028. /** Specifies whether or not bilinear filtering is enable on the texture */
  7029. bilinearFiltering?: boolean;
  7030. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7031. comparisonFunction?: number;
  7032. /** Specifies if the created texture is a cube texture */
  7033. isCube?: boolean;
  7034. }
  7035. /**
  7036. * Class used to describe the capabilities of the engine relatively to the current browser
  7037. */
  7038. class EngineCapabilities {
  7039. /** Maximum textures units per fragment shader */
  7040. maxTexturesImageUnits: number;
  7041. /** Maximum texture units per vertex shader */
  7042. maxVertexTextureImageUnits: number;
  7043. /** Maximum textures units in the entire pipeline */
  7044. maxCombinedTexturesImageUnits: number;
  7045. /** Maximum texture size */
  7046. maxTextureSize: number;
  7047. /** Maximum cube texture size */
  7048. maxCubemapTextureSize: number;
  7049. /** Maximum render texture size */
  7050. maxRenderTextureSize: number;
  7051. /** Maximum number of vertex attributes */
  7052. maxVertexAttribs: number;
  7053. /** Maximum number of varyings */
  7054. maxVaryingVectors: number;
  7055. /** Maximum number of uniforms per vertex shader */
  7056. maxVertexUniformVectors: number;
  7057. /** Maximum number of uniforms per fragment shader */
  7058. maxFragmentUniformVectors: number;
  7059. /** Defines if standard derivates (dx/dy) are supported */
  7060. standardDerivatives: boolean;
  7061. /** Defines if s3tc texture compression is supported */
  7062. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7063. /** Defines if pvrtc texture compression is supported */
  7064. pvrtc: any;
  7065. /** Defines if etc1 texture compression is supported */
  7066. etc1: any;
  7067. /** Defines if etc2 texture compression is supported */
  7068. etc2: any;
  7069. /** Defines if astc texture compression is supported */
  7070. astc: any;
  7071. /** Defines if float textures are supported */
  7072. textureFloat: boolean;
  7073. /** Defines if vertex array objects are supported */
  7074. vertexArrayObject: boolean;
  7075. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7076. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7077. /** Gets the maximum level of anisotropy supported */
  7078. maxAnisotropy: number;
  7079. /** Defines if instancing is supported */
  7080. instancedArrays: boolean;
  7081. /** Defines if 32 bits indices are supported */
  7082. uintIndices: boolean;
  7083. /** Defines if high precision shaders are supported */
  7084. highPrecisionShaderSupported: boolean;
  7085. /** Defines if depth reading in the fragment shader is supported */
  7086. fragmentDepthSupported: boolean;
  7087. /** Defines if float texture linear filtering is supported*/
  7088. textureFloatLinearFiltering: boolean;
  7089. /** Defines if rendering to float textures is supported */
  7090. textureFloatRender: boolean;
  7091. /** Defines if half float textures are supported*/
  7092. textureHalfFloat: boolean;
  7093. /** Defines if half float texture linear filtering is supported*/
  7094. textureHalfFloatLinearFiltering: boolean;
  7095. /** Defines if rendering to half float textures is supported */
  7096. textureHalfFloatRender: boolean;
  7097. /** Defines if textureLOD shader command is supported */
  7098. textureLOD: boolean;
  7099. /** Defines if draw buffers extension is supported */
  7100. drawBuffersExtension: boolean;
  7101. /** Defines if depth textures are supported */
  7102. depthTextureExtension: boolean;
  7103. /** Defines if float color buffer are supported */
  7104. colorBufferFloat: boolean;
  7105. /** Gets disjoint timer query extension (null if not supported) */
  7106. timerQuery: EXT_disjoint_timer_query;
  7107. /** Defines if timestamp can be used with timer query */
  7108. canUseTimestampForTimerQuery: boolean;
  7109. }
  7110. /** Interface defining initialization parameters for Engine class */
  7111. interface EngineOptions extends WebGLContextAttributes {
  7112. /**
  7113. * Defines if the engine should no exceed a specified device ratio
  7114. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7115. */
  7116. limitDeviceRatio?: number;
  7117. /**
  7118. * Defines if webvr should be enabled automatically
  7119. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7120. */
  7121. autoEnableWebVR?: boolean;
  7122. /**
  7123. * Defines if webgl2 should be turned off even if supported
  7124. * @see http://doc.babylonjs.com/features/webgl2
  7125. */
  7126. disableWebGL2Support?: boolean;
  7127. /**
  7128. * Defines if webaudio should be initialized as well
  7129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7130. */
  7131. audioEngine?: boolean;
  7132. /**
  7133. * Defines if animations should run using a deterministic lock step
  7134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7135. */
  7136. deterministicLockstep?: boolean;
  7137. /** Defines the maximum steps to use with deterministic lock step mode */
  7138. lockstepMaxSteps?: number;
  7139. /**
  7140. * Defines that engine should ignore context lost events
  7141. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7142. */
  7143. doNotHandleContextLost?: boolean;
  7144. }
  7145. /**
  7146. * Defines the interface used by display changed events
  7147. */
  7148. interface IDisplayChangedEventArgs {
  7149. /** Gets the vrDisplay object (if any) */
  7150. vrDisplay: Nullable<any>;
  7151. /** Gets a boolean indicating if webVR is supported */
  7152. vrSupported: boolean;
  7153. }
  7154. /**
  7155. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7156. */
  7157. class Engine {
  7158. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7159. static ExceptionList: ({
  7160. key: string;
  7161. capture: string;
  7162. captureConstraint: number;
  7163. targets: string[];
  7164. } | {
  7165. key: string;
  7166. capture: null;
  7167. captureConstraint: null;
  7168. targets: string[];
  7169. })[];
  7170. /** Gets the list of created engines */
  7171. static Instances: Engine[];
  7172. /**
  7173. * Gets the latest created engine
  7174. */
  7175. static readonly LastCreatedEngine: Nullable<Engine>;
  7176. /**
  7177. * Gets the latest created scene
  7178. */
  7179. static readonly LastCreatedScene: Nullable<Scene>;
  7180. /**
  7181. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7182. * @param flag defines which part of the materials must be marked as dirty
  7183. * @param predicate defines a predicate used to filter which materials should be affected
  7184. */
  7185. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7186. /**
  7187. * Hidden
  7188. */
  7189. static _TextureLoaders: IInternalTextureLoader[];
  7190. /** Defines that alpha blending is disabled */
  7191. static readonly ALPHA_DISABLE: number;
  7192. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7193. static readonly ALPHA_ADD: number;
  7194. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7195. static readonly ALPHA_COMBINE: number;
  7196. /** Defines that alpha blending to DEST - SRC * DEST */
  7197. static readonly ALPHA_SUBTRACT: number;
  7198. /** Defines that alpha blending to SRC * DEST */
  7199. static readonly ALPHA_MULTIPLY: number;
  7200. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7201. static readonly ALPHA_MAXIMIZED: number;
  7202. /** Defines that alpha blending to SRC + DEST */
  7203. static readonly ALPHA_ONEONE: number;
  7204. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7205. static readonly ALPHA_PREMULTIPLIED: number;
  7206. /**
  7207. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7208. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7209. */
  7210. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7211. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7212. static readonly ALPHA_INTERPOLATE: number;
  7213. /**
  7214. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7215. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7216. */
  7217. static readonly ALPHA_SCREENMODE: number;
  7218. /** Defines that the ressource is not delayed*/
  7219. static readonly DELAYLOADSTATE_NONE: number;
  7220. /** Defines that the ressource was successfully delay loaded */
  7221. static readonly DELAYLOADSTATE_LOADED: number;
  7222. /** Defines that the ressource is currently delay loading */
  7223. static readonly DELAYLOADSTATE_LOADING: number;
  7224. /** Defines that the ressource is delayed and has not started loading */
  7225. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7227. static readonly NEVER: number;
  7228. /** 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 */
  7229. static readonly ALWAYS: number;
  7230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7231. static readonly LESS: number;
  7232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7233. static readonly EQUAL: number;
  7234. /** 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 */
  7235. static readonly LEQUAL: number;
  7236. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7237. static readonly GREATER: number;
  7238. /** 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 */
  7239. static readonly GEQUAL: number;
  7240. /** 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 */
  7241. static readonly NOTEQUAL: number;
  7242. /** Passed to stencilOperation to specify that stencil value must be kept */
  7243. static readonly KEEP: number;
  7244. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7245. static readonly REPLACE: number;
  7246. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7247. static readonly INCR: number;
  7248. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7249. static readonly DECR: number;
  7250. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7251. static readonly INVERT: number;
  7252. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7253. static readonly INCR_WRAP: number;
  7254. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7255. static readonly DECR_WRAP: number;
  7256. /** Texture is not repeating outside of 0..1 UVs */
  7257. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7258. /** Texture is repeating outside of 0..1 UVs */
  7259. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7260. /** Texture is repeating and mirrored */
  7261. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7262. /** ALPHA */
  7263. static readonly TEXTUREFORMAT_ALPHA: number;
  7264. /** LUMINANCE */
  7265. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7266. /** LUMINANCE_ALPHA */
  7267. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7268. /** RGB */
  7269. static readonly TEXTUREFORMAT_RGB: number;
  7270. /** RGBA */
  7271. static readonly TEXTUREFORMAT_RGBA: number;
  7272. /** RED */
  7273. static readonly TEXTUREFORMAT_RED: number;
  7274. /** RED (2nd reference) */
  7275. static readonly TEXTUREFORMAT_R: number;
  7276. /** RG */
  7277. static readonly TEXTUREFORMAT_RG: number;
  7278. /** RED_INTEGER */
  7279. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7280. /** RED_INTEGER (2nd reference) */
  7281. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7282. /** RG_INTEGER */
  7283. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7284. /** RGB_INTEGER */
  7285. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7286. /** RGBA_INTEGER */
  7287. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7288. /** UNSIGNED_BYTE */
  7289. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7290. /** UNSIGNED_BYTE (2nd reference) */
  7291. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7292. /** FLOAT */
  7293. static readonly TEXTURETYPE_FLOAT: number;
  7294. /** HALF_FLOAT */
  7295. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7296. /** BYTE */
  7297. static readonly TEXTURETYPE_BYTE: number;
  7298. /** SHORT */
  7299. static readonly TEXTURETYPE_SHORT: number;
  7300. /** UNSIGNED_SHORT */
  7301. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7302. /** INT */
  7303. static readonly TEXTURETYPE_INT: number;
  7304. /** UNSIGNED_INT */
  7305. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7306. /** UNSIGNED_SHORT_4_4_4_4 */
  7307. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7308. /** UNSIGNED_SHORT_5_5_5_1 */
  7309. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7310. /** UNSIGNED_SHORT_5_6_5 */
  7311. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7312. /** UNSIGNED_INT_2_10_10_10_REV */
  7313. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7314. /** UNSIGNED_INT_24_8 */
  7315. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7316. /** UNSIGNED_INT_10F_11F_11F_REV */
  7317. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7318. /** UNSIGNED_INT_5_9_9_9_REV */
  7319. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7320. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7321. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7322. /** nearest is mag = nearest and min = nearest and mip = linear */
  7323. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7324. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7325. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7326. /** Trilinear is mag = linear and min = linear and mip = linear */
  7327. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7328. /** nearest is mag = nearest and min = nearest and mip = linear */
  7329. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7330. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7331. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7332. /** Trilinear is mag = linear and min = linear and mip = linear */
  7333. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7334. /** mag = nearest and min = nearest and mip = nearest */
  7335. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7336. /** mag = nearest and min = linear and mip = nearest */
  7337. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7338. /** mag = nearest and min = linear and mip = linear */
  7339. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7340. /** mag = nearest and min = linear and mip = none */
  7341. static readonly TEXTURE_NEAREST_LINEAR: number;
  7342. /** mag = nearest and min = nearest and mip = none */
  7343. static readonly TEXTURE_NEAREST_NEAREST: number;
  7344. /** mag = linear and min = nearest and mip = nearest */
  7345. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7346. /** mag = linear and min = nearest and mip = linear */
  7347. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7348. /** mag = linear and min = linear and mip = none */
  7349. static readonly TEXTURE_LINEAR_LINEAR: number;
  7350. /** mag = linear and min = nearest and mip = none */
  7351. static readonly TEXTURE_LINEAR_NEAREST: number;
  7352. /** Explicit coordinates mode */
  7353. static readonly TEXTURE_EXPLICIT_MODE: number;
  7354. /** Spherical coordinates mode */
  7355. static readonly TEXTURE_SPHERICAL_MODE: number;
  7356. /** Planar coordinates mode */
  7357. static readonly TEXTURE_PLANAR_MODE: number;
  7358. /** Cubic coordinates mode */
  7359. static readonly TEXTURE_CUBIC_MODE: number;
  7360. /** Projection coordinates mode */
  7361. static readonly TEXTURE_PROJECTION_MODE: number;
  7362. /** Skybox coordinates mode */
  7363. static readonly TEXTURE_SKYBOX_MODE: number;
  7364. /** Inverse Cubic coordinates mode */
  7365. static readonly TEXTURE_INVCUBIC_MODE: number;
  7366. /** Equirectangular coordinates mode */
  7367. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7368. /** Equirectangular Fixed coordinates mode */
  7369. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7370. /** Equirectangular Fixed Mirrored coordinates mode */
  7371. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7372. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7373. static readonly SCALEMODE_FLOOR: number;
  7374. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7375. static readonly SCALEMODE_NEAREST: number;
  7376. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7377. static readonly SCALEMODE_CEILING: number;
  7378. /**
  7379. * Returns the current version of the framework
  7380. */
  7381. static readonly Version: string;
  7382. /**
  7383. * Gets or sets the epsilon value used by collision engine
  7384. */
  7385. static CollisionsEpsilon: number;
  7386. /**
  7387. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7388. */
  7389. static CodeRepository: string;
  7390. /**
  7391. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7392. */
  7393. static ShadersRepository: string;
  7394. /**
  7395. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7396. */
  7397. forcePOTTextures: boolean;
  7398. /**
  7399. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7400. */
  7401. isFullscreen: boolean;
  7402. /**
  7403. * Gets a boolean indicating if the pointer is currently locked
  7404. */
  7405. isPointerLock: boolean;
  7406. /**
  7407. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7408. */
  7409. cullBackFaces: boolean;
  7410. /**
  7411. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7412. */
  7413. renderEvenInBackground: boolean;
  7414. /**
  7415. * Gets or sets a boolean indicating that cache can be kept between frames
  7416. */
  7417. preventCacheWipeBetweenFrames: boolean;
  7418. /**
  7419. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7420. **/
  7421. enableOfflineSupport: boolean;
  7422. /**
  7423. * 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)
  7424. **/
  7425. disableManifestCheck: boolean;
  7426. /**
  7427. * Gets the list of created scenes
  7428. */
  7429. scenes: Scene[];
  7430. /**
  7431. * Gets the list of created postprocesses
  7432. */
  7433. postProcesses: PostProcess[];
  7434. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7435. validateShaderPrograms: boolean;
  7436. /**
  7437. * Observable event triggered each time the rendering canvas is resized
  7438. */
  7439. onResizeObservable: Observable<Engine>;
  7440. /**
  7441. * Observable event triggered each time the canvas loses focus
  7442. */
  7443. onCanvasBlurObservable: Observable<Engine>;
  7444. /**
  7445. * Observable event triggered each time the canvas gains focus
  7446. */
  7447. onCanvasFocusObservable: Observable<Engine>;
  7448. /**
  7449. * Observable event triggered each time the canvas receives pointerout event
  7450. */
  7451. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7452. /**
  7453. * Observable event triggered before each texture is initialized
  7454. */
  7455. onBeforeTextureInitObservable: Observable<Texture>;
  7456. private _vrDisplay;
  7457. private _vrSupported;
  7458. private _oldSize;
  7459. private _oldHardwareScaleFactor;
  7460. private _vrExclusivePointerMode;
  7461. private _webVRInitPromise;
  7462. /**
  7463. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7464. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7465. */
  7466. readonly isInVRExclusivePointerMode: boolean;
  7467. /**
  7468. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7469. */
  7470. disableUniformBuffers: boolean;
  7471. /** @hidden */
  7472. _uniformBuffers: UniformBuffer[];
  7473. /**
  7474. * Gets a boolean indicating that the engine supports uniform buffers
  7475. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7476. */
  7477. readonly supportsUniformBuffers: boolean;
  7478. /**
  7479. * Observable raised when the engine begins a new frame
  7480. */
  7481. onBeginFrameObservable: Observable<Engine>;
  7482. /**
  7483. * Observable raised when the engine ends the current frame
  7484. */
  7485. onEndFrameObservable: Observable<Engine>;
  7486. /**
  7487. * Observable raised when the engine is about to compile a shader
  7488. */
  7489. onBeforeShaderCompilationObservable: Observable<Engine>;
  7490. /**
  7491. * Observable raised when the engine has jsut compiled a shader
  7492. */
  7493. onAfterShaderCompilationObservable: Observable<Engine>;
  7494. /** @hidden */
  7495. _gl: WebGLRenderingContext;
  7496. private _renderingCanvas;
  7497. private _windowIsBackground;
  7498. private _webGLVersion;
  7499. /**
  7500. * Gets a boolean indicating that only power of 2 textures are supported
  7501. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7502. */
  7503. readonly needPOTTextures: boolean;
  7504. /** @hidden */
  7505. _badOS: boolean;
  7506. /** @hidden */
  7507. _badDesktopOS: boolean;
  7508. /**
  7509. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7510. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7511. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7512. */
  7513. disableTextureBindingOptimization: boolean;
  7514. /**
  7515. * Gets the audio engine
  7516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7517. * @ignorenaming
  7518. */
  7519. static audioEngine: AudioEngine;
  7520. private _onFocus;
  7521. private _onBlur;
  7522. private _onCanvasPointerOut;
  7523. private _onCanvasBlur;
  7524. private _onCanvasFocus;
  7525. private _onFullscreenChange;
  7526. private _onPointerLockChange;
  7527. private _onVRDisplayPointerRestricted;
  7528. private _onVRDisplayPointerUnrestricted;
  7529. private _onVrDisplayConnect;
  7530. private _onVrDisplayDisconnect;
  7531. private _onVrDisplayPresentChange;
  7532. /**
  7533. * Observable signaled when VR display mode changes
  7534. */
  7535. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7536. /**
  7537. * Observable signaled when VR request present is complete
  7538. */
  7539. onVRRequestPresentComplete: Observable<boolean>;
  7540. /**
  7541. * Observable signaled when VR request present starts
  7542. */
  7543. onVRRequestPresentStart: Observable<Engine>;
  7544. private _hardwareScalingLevel;
  7545. /** @hidden */
  7546. protected _caps: EngineCapabilities;
  7547. private _pointerLockRequested;
  7548. private _isStencilEnable;
  7549. private _colorWrite;
  7550. private _loadingScreen;
  7551. /** @hidden */
  7552. _drawCalls: PerfCounter;
  7553. /** @hidden */
  7554. _textureCollisions: PerfCounter;
  7555. private _glVersion;
  7556. private _glRenderer;
  7557. private _glVendor;
  7558. private _videoTextureSupported;
  7559. private _renderingQueueLaunched;
  7560. private _activeRenderLoops;
  7561. private _deterministicLockstep;
  7562. private _lockstepMaxSteps;
  7563. /**
  7564. * Observable signaled when a context lost event is raised
  7565. */
  7566. onContextLostObservable: Observable<Engine>;
  7567. /**
  7568. * Observable signaled when a context restored event is raised
  7569. */
  7570. onContextRestoredObservable: Observable<Engine>;
  7571. private _onContextLost;
  7572. private _onContextRestored;
  7573. private _contextWasLost;
  7574. private _doNotHandleContextLost;
  7575. /**
  7576. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7578. */
  7579. doNotHandleContextLost: boolean;
  7580. private _performanceMonitor;
  7581. private _fps;
  7582. private _deltaTime;
  7583. /**
  7584. * Turn this value on if you want to pause FPS computation when in background
  7585. */
  7586. disablePerformanceMonitorInBackground: boolean;
  7587. /**
  7588. * Gets the performance monitor attached to this engine
  7589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7590. */
  7591. readonly performanceMonitor: PerformanceMonitor;
  7592. /** @hidden */
  7593. protected _depthCullingState: _DepthCullingState;
  7594. /** @hidden */
  7595. protected _stencilState: _StencilState;
  7596. /** @hidden */
  7597. protected _alphaState: _AlphaState;
  7598. /** @hidden */
  7599. protected _alphaMode: number;
  7600. protected _internalTexturesCache: InternalTexture[];
  7601. /** @hidden */
  7602. protected _activeChannel: number;
  7603. private _currentTextureChannel;
  7604. /** @hidden */
  7605. protected _boundTexturesCache: {
  7606. [key: string]: Nullable<InternalTexture>;
  7607. };
  7608. /** @hidden */
  7609. protected _currentEffect: Nullable<Effect>;
  7610. /** @hidden */
  7611. protected _currentProgram: Nullable<WebGLProgram>;
  7612. private _compiledEffects;
  7613. private _vertexAttribArraysEnabled;
  7614. /** @hidden */
  7615. protected _cachedViewport: Nullable<Viewport>;
  7616. private _cachedVertexArrayObject;
  7617. /** @hidden */
  7618. protected _cachedVertexBuffers: any;
  7619. /** @hidden */
  7620. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7621. /** @hidden */
  7622. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7623. /** @hidden */
  7624. protected _currentRenderTarget: Nullable<InternalTexture>;
  7625. private _uintIndicesCurrentlySet;
  7626. private _currentBoundBuffer;
  7627. /** @hidden */
  7628. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7629. private _currentBufferPointers;
  7630. private _currentInstanceLocations;
  7631. private _currentInstanceBuffers;
  7632. private _textureUnits;
  7633. private _firstBoundInternalTextureTracker;
  7634. private _lastBoundInternalTextureTracker;
  7635. private _workingCanvas;
  7636. private _workingContext;
  7637. private _rescalePostProcess;
  7638. private _dummyFramebuffer;
  7639. private _externalData;
  7640. private _bindedRenderFunction;
  7641. private _vaoRecordInProgress;
  7642. private _mustWipeVertexAttributes;
  7643. private _emptyTexture;
  7644. private _emptyCubeTexture;
  7645. private _emptyTexture3D;
  7646. private _frameHandler;
  7647. private _nextFreeTextureSlots;
  7648. private _maxSimultaneousTextures;
  7649. private _activeRequests;
  7650. private _texturesSupported;
  7651. private _textureFormatInUse;
  7652. /**
  7653. * Gets the list of texture formats supported
  7654. */
  7655. readonly texturesSupported: Array<string>;
  7656. /**
  7657. * Gets the list of texture formats in use
  7658. */
  7659. readonly textureFormatInUse: Nullable<string>;
  7660. /**
  7661. * Gets the current viewport
  7662. */
  7663. readonly currentViewport: Nullable<Viewport>;
  7664. /**
  7665. * Gets the default empty texture
  7666. */
  7667. readonly emptyTexture: InternalTexture;
  7668. /**
  7669. * Gets the default empty 3D texture
  7670. */
  7671. readonly emptyTexture3D: InternalTexture;
  7672. /**
  7673. * Gets the default empty cube texture
  7674. */
  7675. readonly emptyCubeTexture: InternalTexture;
  7676. /**
  7677. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7678. */
  7679. readonly premultipliedAlpha: boolean;
  7680. /**
  7681. * Creates a new engine
  7682. * @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
  7683. * @param antialias defines enable antialiasing (default: false)
  7684. * @param options defines further options to be sent to the getContext() function
  7685. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7686. */
  7687. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7688. private _rebuildInternalTextures;
  7689. private _rebuildEffects;
  7690. private _rebuildBuffers;
  7691. private _initGLContext;
  7692. /**
  7693. * Gets version of the current webGL context
  7694. */
  7695. readonly webGLVersion: number;
  7696. /**
  7697. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7698. */
  7699. readonly isStencilEnable: boolean;
  7700. private _prepareWorkingCanvas;
  7701. /**
  7702. * Reset the texture cache to empty state
  7703. */
  7704. resetTextureCache(): void;
  7705. /**
  7706. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7708. * @returns true if engine is in deterministic lock step mode
  7709. */
  7710. isDeterministicLockStep(): boolean;
  7711. /**
  7712. * Gets the max steps when engine is running in deterministic lock step
  7713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7714. * @returns the max steps
  7715. */
  7716. getLockstepMaxSteps(): number;
  7717. /**
  7718. * Gets an object containing information about the current webGL context
  7719. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7720. */
  7721. getGlInfo(): {
  7722. vendor: string;
  7723. renderer: string;
  7724. version: string;
  7725. };
  7726. /**
  7727. * Gets current aspect ratio
  7728. * @param camera defines the camera to use to get the aspect ratio
  7729. * @param useScreen defines if screen size must be used (or the current render target if any)
  7730. * @returns a number defining the aspect ratio
  7731. */
  7732. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7733. /**
  7734. * Gets current screen aspect ratio
  7735. * @returns a number defining the aspect ratio
  7736. */
  7737. getScreenAspectRatio(): number;
  7738. /**
  7739. * Gets the current render width
  7740. * @param useScreen defines if screen size must be used (or the current render target if any)
  7741. * @returns a number defining the current render width
  7742. */
  7743. getRenderWidth(useScreen?: boolean): number;
  7744. /**
  7745. * Gets the current render height
  7746. * @param useScreen defines if screen size must be used (or the current render target if any)
  7747. * @returns a number defining the current render height
  7748. */
  7749. getRenderHeight(useScreen?: boolean): number;
  7750. /**
  7751. * Gets the HTML canvas attached with the current webGL context
  7752. * @returns a HTML canvas
  7753. */
  7754. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7755. /**
  7756. * Gets the client rect of the HTML canvas attached with the current webGL context
  7757. * @returns a client rectanglee
  7758. */
  7759. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7760. /**
  7761. * Defines the hardware scaling level.
  7762. * By default the hardware scaling level is computed from the window device ratio.
  7763. * 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.
  7764. * @param level defines the level to use
  7765. */
  7766. setHardwareScalingLevel(level: number): void;
  7767. /**
  7768. * Gets the current hardware scaling level.
  7769. * By default the hardware scaling level is computed from the window device ratio.
  7770. * 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.
  7771. * @returns a number indicating the current hardware scaling level
  7772. */
  7773. getHardwareScalingLevel(): number;
  7774. /**
  7775. * Gets the list of loaded textures
  7776. * @returns an array containing all loaded textures
  7777. */
  7778. getLoadedTexturesCache(): InternalTexture[];
  7779. /**
  7780. * Gets the object containing all engine capabilities
  7781. * @returns the EngineCapabilities object
  7782. */
  7783. getCaps(): EngineCapabilities;
  7784. /** @hidden */
  7785. readonly drawCalls: number;
  7786. /** @hidden */
  7787. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7788. /**
  7789. * Gets the current depth function
  7790. * @returns a number defining the depth function
  7791. */
  7792. getDepthFunction(): Nullable<number>;
  7793. /**
  7794. * Sets the current depth function
  7795. * @param depthFunc defines the function to use
  7796. */
  7797. setDepthFunction(depthFunc: number): void;
  7798. /**
  7799. * Sets the current depth function to GREATER
  7800. */
  7801. setDepthFunctionToGreater(): void;
  7802. /**
  7803. * Sets the current depth function to GEQUAL
  7804. */
  7805. setDepthFunctionToGreaterOrEqual(): void;
  7806. /**
  7807. * Sets the current depth function to LESS
  7808. */
  7809. setDepthFunctionToLess(): void;
  7810. /**
  7811. * Sets the current depth function to LEQUAL
  7812. */
  7813. setDepthFunctionToLessOrEqual(): void;
  7814. /**
  7815. * Gets a boolean indicating if stencil buffer is enabled
  7816. * @returns the current stencil buffer state
  7817. */
  7818. getStencilBuffer(): boolean;
  7819. /**
  7820. * Enable or disable the stencil buffer
  7821. * @param enable defines if the stencil buffer must be enabled or disabled
  7822. */
  7823. setStencilBuffer(enable: boolean): void;
  7824. /**
  7825. * Gets the current stencil mask
  7826. * @returns a number defining the new stencil mask to use
  7827. */
  7828. getStencilMask(): number;
  7829. /**
  7830. * Sets the current stencil mask
  7831. * @param mask defines the new stencil mask to use
  7832. */
  7833. setStencilMask(mask: number): void;
  7834. /**
  7835. * Gets the current stencil function
  7836. * @returns a number defining the stencil function to use
  7837. */
  7838. getStencilFunction(): number;
  7839. /**
  7840. * Gets the current stencil reference value
  7841. * @returns a number defining the stencil reference value to use
  7842. */
  7843. getStencilFunctionReference(): number;
  7844. /**
  7845. * Gets the current stencil mask
  7846. * @returns a number defining the stencil mask to use
  7847. */
  7848. getStencilFunctionMask(): number;
  7849. /**
  7850. * Sets the current stencil function
  7851. * @param stencilFunc defines the new stencil function to use
  7852. */
  7853. setStencilFunction(stencilFunc: number): void;
  7854. /**
  7855. * Sets the current stencil reference
  7856. * @param reference defines the new stencil reference to use
  7857. */
  7858. setStencilFunctionReference(reference: number): void;
  7859. /**
  7860. * Sets the current stencil mask
  7861. * @param mask defines the new stencil mask to use
  7862. */
  7863. setStencilFunctionMask(mask: number): void;
  7864. /**
  7865. * Gets the current stencil operation when stencil fails
  7866. * @returns a number defining stencil operation to use when stencil fails
  7867. */
  7868. getStencilOperationFail(): number;
  7869. /**
  7870. * Gets the current stencil operation when depth fails
  7871. * @returns a number defining stencil operation to use when depth fails
  7872. */
  7873. getStencilOperationDepthFail(): number;
  7874. /**
  7875. * Gets the current stencil operation when stencil passes
  7876. * @returns a number defining stencil operation to use when stencil passes
  7877. */
  7878. getStencilOperationPass(): number;
  7879. /**
  7880. * Sets the stencil operation to use when stencil fails
  7881. * @param operation defines the stencil operation to use when stencil fails
  7882. */
  7883. setStencilOperationFail(operation: number): void;
  7884. /**
  7885. * Sets the stencil operation to use when depth fails
  7886. * @param operation defines the stencil operation to use when depth fails
  7887. */
  7888. setStencilOperationDepthFail(operation: number): void;
  7889. /**
  7890. * Sets the stencil operation to use when stencil passes
  7891. * @param operation defines the stencil operation to use when stencil passes
  7892. */
  7893. setStencilOperationPass(operation: number): void;
  7894. /**
  7895. * Sets a boolean indicating if the dithering state is enabled or disabled
  7896. * @param value defines the dithering state
  7897. */
  7898. setDitheringState(value: boolean): void;
  7899. /**
  7900. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7901. * @param value defines the rasterizer state
  7902. */
  7903. setRasterizerState(value: boolean): void;
  7904. /**
  7905. * stop executing a render loop function and remove it from the execution array
  7906. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7907. */
  7908. stopRenderLoop(renderFunction?: () => void): void;
  7909. /** @hidden */
  7910. _renderLoop(): void;
  7911. /**
  7912. * Register and execute a render loop. The engine can have more than one render function
  7913. * @param renderFunction defines the function to continuously execute
  7914. */
  7915. runRenderLoop(renderFunction: () => void): void;
  7916. /**
  7917. * Toggle full screen mode
  7918. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7919. * @param options defines an option object to be sent to the requestFullscreen function
  7920. */
  7921. switchFullscreen(requestPointerLock: boolean): void;
  7922. /**
  7923. * Clear the current render buffer or the current render target (if any is set up)
  7924. * @param color defines the color to use
  7925. * @param backBuffer defines if the back buffer must be cleared
  7926. * @param depth defines if the depth buffer must be cleared
  7927. * @param stencil defines if the stencil buffer must be cleared
  7928. */
  7929. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7930. /**
  7931. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7932. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7933. * @param y defines the y-coordinate of the corner of the clear rectangle
  7934. * @param width defines the width of the clear rectangle
  7935. * @param height defines the height of the clear rectangle
  7936. * @param clearColor defines the clear color
  7937. */
  7938. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7939. private _viewportCached;
  7940. /** @hidden */
  7941. _viewport(x: number, y: number, width: number, height: number): void;
  7942. /**
  7943. * Set the WebGL's viewport
  7944. * @param viewport defines the viewport element to be used
  7945. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7946. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7947. */
  7948. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7949. /**
  7950. * Directly set the WebGL Viewport
  7951. * @param x defines the x coordinate of the viewport (in screen space)
  7952. * @param y defines the y coordinate of the viewport (in screen space)
  7953. * @param width defines the width of the viewport (in screen space)
  7954. * @param height defines the height of the viewport (in screen space)
  7955. * @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
  7956. */
  7957. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7958. /**
  7959. * Begin a new frame
  7960. */
  7961. beginFrame(): void;
  7962. /**
  7963. * Enf the current frame
  7964. */
  7965. endFrame(): void;
  7966. /**
  7967. * Resize the view according to the canvas' size
  7968. */
  7969. resize(): void;
  7970. /**
  7971. * Force a specific size of the canvas
  7972. * @param width defines the new canvas' width
  7973. * @param height defines the new canvas' height
  7974. */
  7975. setSize(width: number, height: number): void;
  7976. /**
  7977. * Gets a boolean indicating if a webVR device was detected
  7978. * @returns true if a webVR device was detected
  7979. */
  7980. isVRDevicePresent(): boolean;
  7981. /**
  7982. * Gets the current webVR device
  7983. * @returns the current webVR device (or null)
  7984. */
  7985. getVRDevice(): any;
  7986. /**
  7987. * Initializes a webVR display and starts listening to display change events
  7988. * The onVRDisplayChangedObservable will be notified upon these changes
  7989. * @returns The onVRDisplayChangedObservable
  7990. */
  7991. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7992. /**
  7993. * Initializes a webVR display and starts listening to display change events
  7994. * The onVRDisplayChangedObservable will be notified upon these changes
  7995. * @returns A promise containing a VRDisplay and if vr is supported
  7996. */
  7997. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7998. /**
  7999. * Call this function to switch to webVR mode
  8000. * Will do nothing if webVR is not supported or if there is no webVR device
  8001. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8002. */
  8003. enableVR(): void;
  8004. /**
  8005. * Call this function to leave webVR mode
  8006. * Will do nothing if webVR is not supported or if there is no webVR device
  8007. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8008. */
  8009. disableVR(): void;
  8010. private _onVRFullScreenTriggered;
  8011. private _getVRDisplaysAsync;
  8012. /**
  8013. * Binds the frame buffer to the specified texture.
  8014. * @param texture The texture to render to or null for the default canvas
  8015. * @param faceIndex The face of the texture to render to in case of cube texture
  8016. * @param requiredWidth The width of the target to render to
  8017. * @param requiredHeight The height of the target to render to
  8018. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8019. * @param depthStencilTexture The depth stencil texture to use to render
  8020. * @param lodLevel defines le lod level to bind to the frame buffer
  8021. */
  8022. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8023. private bindUnboundFramebuffer;
  8024. /**
  8025. * Unbind the current render target texture from the webGL context
  8026. * @param texture defines the render target texture to unbind
  8027. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8028. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8029. */
  8030. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8031. /**
  8032. * Unbind a list of render target textures from the webGL context
  8033. * This is used only when drawBuffer extension or webGL2 are active
  8034. * @param textures defines the render target textures to unbind
  8035. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8036. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8037. */
  8038. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8039. /**
  8040. * Force the mipmap generation for the given render target texture
  8041. * @param texture defines the render target texture to use
  8042. */
  8043. generateMipMapsForCubemap(texture: InternalTexture): void;
  8044. /**
  8045. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8046. */
  8047. flushFramebuffer(): void;
  8048. /**
  8049. * Unbind the current render target and bind the default framebuffer
  8050. */
  8051. restoreDefaultFramebuffer(): void;
  8052. /**
  8053. * Create an uniform buffer
  8054. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8055. * @param elements defines the content of the uniform buffer
  8056. * @returns the webGL uniform buffer
  8057. */
  8058. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8059. /**
  8060. * Create a dynamic uniform buffer
  8061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8062. * @param elements defines the content of the uniform buffer
  8063. * @returns the webGL uniform buffer
  8064. */
  8065. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8066. /**
  8067. * Update an existing uniform buffer
  8068. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8069. * @param uniformBuffer defines the target uniform buffer
  8070. * @param elements defines the content to update
  8071. * @param offset defines the offset in the uniform buffer where update should start
  8072. * @param count defines the size of the data to update
  8073. */
  8074. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8075. private _resetVertexBufferBinding;
  8076. /**
  8077. * Creates a vertex buffer
  8078. * @param data the data for the vertex buffer
  8079. * @returns the new WebGL static buffer
  8080. */
  8081. createVertexBuffer(data: DataArray): WebGLBuffer;
  8082. /**
  8083. * Creates a dynamic vertex buffer
  8084. * @param data the data for the dynamic vertex buffer
  8085. * @returns the new WebGL dynamic buffer
  8086. */
  8087. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8088. /**
  8089. * Update a dynamic index buffer
  8090. * @param indexBuffer defines the target index buffer
  8091. * @param indices defines the data to update
  8092. * @param offset defines the offset in the target index buffer where update should start
  8093. */
  8094. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8095. /**
  8096. * Updates a dynamic vertex buffer.
  8097. * @param vertexBuffer the vertex buffer to update
  8098. * @param data the data used to update the vertex buffer
  8099. * @param byteOffset the byte offset of the data
  8100. * @param byteLength the byte length of the data
  8101. */
  8102. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8103. private _resetIndexBufferBinding;
  8104. /**
  8105. * Creates a new index buffer
  8106. * @param indices defines the content of the index buffer
  8107. * @param updatable defines if the index buffer must be updatable
  8108. * @returns a new webGL buffer
  8109. */
  8110. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8111. /**
  8112. * Bind a webGL buffer to the webGL context
  8113. * @param buffer defines the buffer to bind
  8114. */
  8115. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8116. /**
  8117. * Bind an uniform buffer to the current webGL context
  8118. * @param buffer defines the buffer to bind
  8119. */
  8120. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8121. /**
  8122. * Bind a buffer to the current webGL context at a given location
  8123. * @param buffer defines the buffer to bind
  8124. * @param location defines the index where to bind the buffer
  8125. */
  8126. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8127. /**
  8128. * Bind a specific block at a given index in a specific shader program
  8129. * @param shaderProgram defines the shader program
  8130. * @param blockName defines the block name
  8131. * @param index defines the index where to bind the block
  8132. */
  8133. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8134. private bindIndexBuffer;
  8135. private bindBuffer;
  8136. /**
  8137. * update the bound buffer with the given data
  8138. * @param data defines the data to update
  8139. */
  8140. updateArrayBuffer(data: Float32Array): void;
  8141. private _vertexAttribPointer;
  8142. private _bindIndexBufferWithCache;
  8143. private _bindVertexBuffersAttributes;
  8144. /**
  8145. * Records a vertex array object
  8146. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8147. * @param vertexBuffers defines the list of vertex buffers to store
  8148. * @param indexBuffer defines the index buffer to store
  8149. * @param effect defines the effect to store
  8150. * @returns the new vertex array object
  8151. */
  8152. recordVertexArrayObject(vertexBuffers: {
  8153. [key: string]: VertexBuffer;
  8154. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8155. /**
  8156. * Bind a specific vertex array object
  8157. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8158. * @param vertexArrayObject defines the vertex array object to bind
  8159. * @param indexBuffer defines the index buffer to bind
  8160. */
  8161. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8162. /**
  8163. * Bind webGl buffers directly to the webGL context
  8164. * @param vertexBuffer defines the vertex buffer to bind
  8165. * @param indexBuffer defines the index buffer to bind
  8166. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8167. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8168. * @param effect defines the effect associated with the vertex buffer
  8169. */
  8170. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8171. private _unbindVertexArrayObject;
  8172. /**
  8173. * Bind a list of vertex buffers to the webGL context
  8174. * @param vertexBuffers defines the list of vertex buffers to bind
  8175. * @param indexBuffer defines the index buffer to bind
  8176. * @param effect defines the effect associated with the vertex buffers
  8177. */
  8178. bindBuffers(vertexBuffers: {
  8179. [key: string]: Nullable<VertexBuffer>;
  8180. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8181. /**
  8182. * Unbind all instance attributes
  8183. */
  8184. unbindInstanceAttributes(): void;
  8185. /**
  8186. * Release and free the memory of a vertex array object
  8187. * @param vao defines the vertex array object to delete
  8188. */
  8189. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8190. /** @hidden */
  8191. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8192. /**
  8193. * Creates a webGL buffer to use with instanciation
  8194. * @param capacity defines the size of the buffer
  8195. * @returns the webGL buffer
  8196. */
  8197. createInstancesBuffer(capacity: number): WebGLBuffer;
  8198. /**
  8199. * Delete a webGL buffer used with instanciation
  8200. * @param buffer defines the webGL buffer to delete
  8201. */
  8202. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8203. /**
  8204. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8205. * @param instancesBuffer defines the webGL buffer to update and bind
  8206. * @param data defines the data to store in the buffer
  8207. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8208. */
  8209. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8210. /**
  8211. * Apply all cached states (depth, culling, stencil and alpha)
  8212. */
  8213. applyStates(): void;
  8214. /**
  8215. * Send a draw order
  8216. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8217. * @param indexStart defines the starting index
  8218. * @param indexCount defines the number of index to draw
  8219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8220. */
  8221. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8222. /**
  8223. * Draw a list of points
  8224. * @param verticesStart defines the index of first vertex to draw
  8225. * @param verticesCount defines the count of vertices to draw
  8226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8227. */
  8228. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8229. /**
  8230. * Draw a list of unindexed primitives
  8231. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8232. * @param verticesStart defines the index of first vertex to draw
  8233. * @param verticesCount defines the count of vertices to draw
  8234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8235. */
  8236. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8237. /**
  8238. * Draw a list of indexed primitives
  8239. * @param fillMode defines the primitive to use
  8240. * @param indexStart defines the starting index
  8241. * @param indexCount defines the number of index to draw
  8242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8243. */
  8244. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8245. /**
  8246. * Draw a list of unindexed primitives
  8247. * @param fillMode defines the primitive to use
  8248. * @param verticesStart defines the index of first vertex to draw
  8249. * @param verticesCount defines the count of vertices to draw
  8250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8251. */
  8252. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8253. private _drawMode;
  8254. /** @hidden */
  8255. _releaseEffect(effect: Effect): void;
  8256. /** @hidden */
  8257. _deleteProgram(program: WebGLProgram): void;
  8258. /**
  8259. * Create a new effect (used to store vertex/fragment shaders)
  8260. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8261. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8262. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8263. * @param samplers defines an array of string used to represent textures
  8264. * @param defines defines the string containing the defines to use to compile the shaders
  8265. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8266. * @param onCompiled defines a function to call when the effect creation is successful
  8267. * @param onError defines a function to call when the effect creation has failed
  8268. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8269. * @returns the new Effect
  8270. */
  8271. 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;
  8272. private _compileShader;
  8273. private _compileRawShader;
  8274. /**
  8275. * Directly creates a webGL program
  8276. * @param vertexCode defines the vertex shader code to use
  8277. * @param fragmentCode defines the fragment shader code to use
  8278. * @param context defines the webGL context to use (if not set, the current one will be used)
  8279. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8280. * @returns the new webGL program
  8281. */
  8282. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8283. /**
  8284. * Creates a webGL program
  8285. * @param vertexCode defines the vertex shader code to use
  8286. * @param fragmentCode defines the fragment shader code to use
  8287. * @param defines defines the string containing the defines to use to compile the shaders
  8288. * @param context defines the webGL context to use (if not set, the current one will be used)
  8289. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8290. * @returns the new webGL program
  8291. */
  8292. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8293. private _createShaderProgram;
  8294. /**
  8295. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8296. * @param shaderProgram defines the webGL program to use
  8297. * @param uniformsNames defines the list of uniform names
  8298. * @returns an array of webGL uniform locations
  8299. */
  8300. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8301. /**
  8302. * Gets the lsit of active attributes for a given webGL program
  8303. * @param shaderProgram defines the webGL program to use
  8304. * @param attributesNames defines the list of attribute names to get
  8305. * @returns an array of indices indicating the offset of each attribute
  8306. */
  8307. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8308. /**
  8309. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8310. * @param effect defines the effect to activate
  8311. */
  8312. enableEffect(effect: Nullable<Effect>): void;
  8313. /**
  8314. * Set the value of an uniform to an array of int32
  8315. * @param uniform defines the webGL uniform location where to store the value
  8316. * @param array defines the array of int32 to store
  8317. */
  8318. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8319. /**
  8320. * Set the value of an uniform to an array of int32 (stored as vec2)
  8321. * @param uniform defines the webGL uniform location where to store the value
  8322. * @param array defines the array of int32 to store
  8323. */
  8324. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8325. /**
  8326. * Set the value of an uniform to an array of int32 (stored as vec3)
  8327. * @param uniform defines the webGL uniform location where to store the value
  8328. * @param array defines the array of int32 to store
  8329. */
  8330. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8331. /**
  8332. * Set the value of an uniform to an array of int32 (stored as vec4)
  8333. * @param uniform defines the webGL uniform location where to store the value
  8334. * @param array defines the array of int32 to store
  8335. */
  8336. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8337. /**
  8338. * Set the value of an uniform to an array of float32
  8339. * @param uniform defines the webGL uniform location where to store the value
  8340. * @param array defines the array of float32 to store
  8341. */
  8342. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8343. /**
  8344. * Set the value of an uniform to an array of float32 (stored as vec2)
  8345. * @param uniform defines the webGL uniform location where to store the value
  8346. * @param array defines the array of float32 to store
  8347. */
  8348. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8349. /**
  8350. * Set the value of an uniform to an array of float32 (stored as vec3)
  8351. * @param uniform defines the webGL uniform location where to store the value
  8352. * @param array defines the array of float32 to store
  8353. */
  8354. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8355. /**
  8356. * Set the value of an uniform to an array of float32 (stored as vec4)
  8357. * @param uniform defines the webGL uniform location where to store the value
  8358. * @param array defines the array of float32 to store
  8359. */
  8360. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8361. /**
  8362. * Set the value of an uniform to an array of number
  8363. * @param uniform defines the webGL uniform location where to store the value
  8364. * @param array defines the array of number to store
  8365. */
  8366. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8367. /**
  8368. * Set the value of an uniform to an array of number (stored as vec2)
  8369. * @param uniform defines the webGL uniform location where to store the value
  8370. * @param array defines the array of number to store
  8371. */
  8372. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8373. /**
  8374. * Set the value of an uniform to an array of number (stored as vec3)
  8375. * @param uniform defines the webGL uniform location where to store the value
  8376. * @param array defines the array of number to store
  8377. */
  8378. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8379. /**
  8380. * Set the value of an uniform to an array of number (stored as vec4)
  8381. * @param uniform defines the webGL uniform location where to store the value
  8382. * @param array defines the array of number to store
  8383. */
  8384. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8385. /**
  8386. * Set the value of an uniform to an array of float32 (stored as matrices)
  8387. * @param uniform defines the webGL uniform location where to store the value
  8388. * @param matrices defines the array of float32 to store
  8389. */
  8390. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8391. /**
  8392. * Set the value of an uniform to a matrix
  8393. * @param uniform defines the webGL uniform location where to store the value
  8394. * @param matrix defines the matrix to store
  8395. */
  8396. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8397. /**
  8398. * Set the value of an uniform to a matrix (3x3)
  8399. * @param uniform defines the webGL uniform location where to store the value
  8400. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8401. */
  8402. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8403. /**
  8404. * Set the value of an uniform to a matrix (2x2)
  8405. * @param uniform defines the webGL uniform location where to store the value
  8406. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8407. */
  8408. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8409. /**
  8410. * Set the value of an uniform to a number (int)
  8411. * @param uniform defines the webGL uniform location where to store the value
  8412. * @param value defines the int number to store
  8413. */
  8414. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8415. /**
  8416. * Set the value of an uniform to a number (float)
  8417. * @param uniform defines the webGL uniform location where to store the value
  8418. * @param value defines the float number to store
  8419. */
  8420. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8421. /**
  8422. * Set the value of an uniform to a vec2
  8423. * @param uniform defines the webGL uniform location where to store the value
  8424. * @param x defines the 1st component of the value
  8425. * @param y defines the 2nd component of the value
  8426. */
  8427. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8428. /**
  8429. * Set the value of an uniform to a vec3
  8430. * @param uniform defines the webGL uniform location where to store the value
  8431. * @param x defines the 1st component of the value
  8432. * @param y defines the 2nd component of the value
  8433. * @param z defines the 3rd component of the value
  8434. */
  8435. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8436. /**
  8437. * Set the value of an uniform to a boolean
  8438. * @param uniform defines the webGL uniform location where to store the value
  8439. * @param bool defines the boolean to store
  8440. */
  8441. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8442. /**
  8443. * Set the value of an uniform to a vec4
  8444. * @param uniform defines the webGL uniform location where to store the value
  8445. * @param x defines the 1st component of the value
  8446. * @param y defines the 2nd component of the value
  8447. * @param z defines the 3rd component of the value
  8448. * @param w defines the 4th component of the value
  8449. */
  8450. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8451. /**
  8452. * Set the value of an uniform to a Color3
  8453. * @param uniform defines the webGL uniform location where to store the value
  8454. * @param color3 defines the color to store
  8455. */
  8456. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8457. /**
  8458. * Set the value of an uniform to a Color3 and an alpha value
  8459. * @param uniform defines the webGL uniform location where to store the value
  8460. * @param color3 defines the color to store
  8461. * @param alpha defines the alpha component to store
  8462. */
  8463. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8464. /**
  8465. * Sets a Color4 on a uniform variable
  8466. * @param uniform defines the uniform location
  8467. * @param color4 defines the value to be set
  8468. */
  8469. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8470. /**
  8471. * Set various states to the webGL context
  8472. * @param culling defines backface culling state
  8473. * @param zOffset defines the value to apply to zOffset (0 by default)
  8474. * @param force defines if states must be applied even if cache is up to date
  8475. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8476. */
  8477. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8478. /**
  8479. * Set the z offset to apply to current rendering
  8480. * @param value defines the offset to apply
  8481. */
  8482. setZOffset(value: number): void;
  8483. /**
  8484. * Gets the current value of the zOffset
  8485. * @returns the current zOffset state
  8486. */
  8487. getZOffset(): number;
  8488. /**
  8489. * Enable or disable depth buffering
  8490. * @param enable defines the state to set
  8491. */
  8492. setDepthBuffer(enable: boolean): void;
  8493. /**
  8494. * Gets a boolean indicating if depth writing is enabled
  8495. * @returns the current depth writing state
  8496. */
  8497. getDepthWrite(): boolean;
  8498. /**
  8499. * Enable or disable depth writing
  8500. * @param enable defines the state to set
  8501. */
  8502. setDepthWrite(enable: boolean): void;
  8503. /**
  8504. * Enable or disable color writing
  8505. * @param enable defines the state to set
  8506. */
  8507. setColorWrite(enable: boolean): void;
  8508. /**
  8509. * Gets a boolean indicating if color writing is enabled
  8510. * @returns the current color writing state
  8511. */
  8512. getColorWrite(): boolean;
  8513. /**
  8514. * Sets alpha constants used by some alpha blending modes
  8515. * @param r defines the red component
  8516. * @param g defines the green component
  8517. * @param b defines the blue component
  8518. * @param a defines the alpha component
  8519. */
  8520. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8521. /**
  8522. * Sets the current alpha mode
  8523. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8524. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8526. */
  8527. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8528. /**
  8529. * Gets the current alpha mode
  8530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8531. * @returns the current alpha mode
  8532. */
  8533. getAlphaMode(): number;
  8534. /**
  8535. * Clears the list of texture accessible through engine.
  8536. * This can help preventing texture load conflict due to name collision.
  8537. */
  8538. clearInternalTexturesCache(): void;
  8539. /**
  8540. * Force the entire cache to be cleared
  8541. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8542. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8543. */
  8544. wipeCaches(bruteForce?: boolean): void;
  8545. /**
  8546. * Set the compressed texture format to use, based on the formats you have, and the formats
  8547. * supported by the hardware / browser.
  8548. *
  8549. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8550. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8551. * to API arguments needed to compressed textures. This puts the burden on the container
  8552. * generator to house the arcane code for determining these for current & future formats.
  8553. *
  8554. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8555. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8556. *
  8557. * Note: The result of this call is not taken into account when a texture is base64.
  8558. *
  8559. * @param formatsAvailable defines the list of those format families you have created
  8560. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8561. *
  8562. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8563. * @returns The extension selected.
  8564. */
  8565. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8566. private _getSamplingParameters;
  8567. private _partialLoadImg;
  8568. private _cascadeLoadImgs;
  8569. /** @hidden */
  8570. _createTexture(): WebGLTexture;
  8571. /**
  8572. * Usually called from BABYLON.Texture.ts.
  8573. * Passed information to create a WebGLTexture
  8574. * @param urlArg defines a value which contains one of the following:
  8575. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8576. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8577. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8578. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8579. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8580. * @param scene needed for loading to the correct scene
  8581. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8582. * @param onLoad optional callback to be called upon successful completion
  8583. * @param onError optional callback to be called upon failure
  8584. * @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
  8585. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8586. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8587. * @param forcedExtension defines the extension to use to pick the right loader
  8588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8589. */
  8590. 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;
  8591. private _rescaleTexture;
  8592. /**
  8593. * Update a raw texture
  8594. * @param texture defines the texture to update
  8595. * @param data defines the data to store in the texture
  8596. * @param format defines the format of the data
  8597. * @param invertY defines if data must be stored with Y axis inverted
  8598. * @param compression defines the compression used (null by default)
  8599. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8600. */
  8601. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8602. /**
  8603. * Creates a raw texture
  8604. * @param data defines the data to store in the texture
  8605. * @param width defines the width of the texture
  8606. * @param height defines the height of the texture
  8607. * @param format defines the format of the data
  8608. * @param generateMipMaps defines if the engine should generate the mip levels
  8609. * @param invertY defines if data must be stored with Y axis inverted
  8610. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8611. * @param compression defines the compression used (null by default)
  8612. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8613. * @returns the raw texture inside an InternalTexture
  8614. */
  8615. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8616. private _unpackFlipYCached;
  8617. /**
  8618. * In case you are sharing the context with other applications, it might
  8619. * be interested to not cache the unpack flip y state to ensure a consistent
  8620. * value would be set.
  8621. */
  8622. enableUnpackFlipYCached: boolean;
  8623. /** @hidden */
  8624. _unpackFlipY(value: boolean): void;
  8625. /** @hidden */
  8626. _getUnpackAlignement(): number;
  8627. /**
  8628. * Creates a dynamic texture
  8629. * @param width defines the width of the texture
  8630. * @param height defines the height of the texture
  8631. * @param generateMipMaps defines if the engine should generate the mip levels
  8632. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8633. * @returns the dynamic texture inside an InternalTexture
  8634. */
  8635. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8636. /**
  8637. * Update the sampling mode of a given texture
  8638. * @param samplingMode defines the required sampling mode
  8639. * @param texture defines the texture to update
  8640. */
  8641. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8642. /**
  8643. * Update the content of a dynamic texture
  8644. * @param texture defines the texture to update
  8645. * @param canvas defines the canvas containing the source
  8646. * @param invertY defines if data must be stored with Y axis inverted
  8647. * @param premulAlpha defines if alpha is stored as premultiplied
  8648. * @param format defines the format of the data
  8649. */
  8650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8651. /**
  8652. * Update a video texture
  8653. * @param texture defines the texture to update
  8654. * @param video defines the video element to use
  8655. * @param invertY defines if data must be stored with Y axis inverted
  8656. */
  8657. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8658. /**
  8659. * Updates a depth texture Comparison Mode and Function.
  8660. * If the comparison Function is equal to 0, the mode will be set to none.
  8661. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8662. * @param texture The texture to set the comparison function for
  8663. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8664. */
  8665. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8666. private _setupDepthStencilTexture;
  8667. /**
  8668. * Creates a depth stencil texture.
  8669. * This is only available in WebGL 2 or with the depth texture extension available.
  8670. * @param size The size of face edge in the texture.
  8671. * @param options The options defining the texture.
  8672. * @returns The texture
  8673. */
  8674. createDepthStencilTexture(size: number | {
  8675. width: number;
  8676. height: number;
  8677. }, options: DepthTextureCreationOptions): InternalTexture;
  8678. /**
  8679. * Creates a depth stencil texture.
  8680. * This is only available in WebGL 2 or with the depth texture extension available.
  8681. * @param size The size of face edge in the texture.
  8682. * @param options The options defining the texture.
  8683. * @returns The texture
  8684. */
  8685. private _createDepthStencilTexture;
  8686. /**
  8687. * Creates a depth stencil cube texture.
  8688. * This is only available in WebGL 2.
  8689. * @param size The size of face edge in the cube texture.
  8690. * @param options The options defining the cube texture.
  8691. * @returns The cube texture
  8692. */
  8693. private _createDepthStencilCubeTexture;
  8694. /**
  8695. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8696. * @param renderTarget The render target to set the frame buffer for
  8697. */
  8698. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8699. /**
  8700. * Creates a new render target texture
  8701. * @param size defines the size of the texture
  8702. * @param options defines the options used to create the texture
  8703. * @returns a new render target texture stored in an InternalTexture
  8704. */
  8705. createRenderTargetTexture(size: number | {
  8706. width: number;
  8707. height: number;
  8708. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8709. /**
  8710. * Create a multi render target texture
  8711. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8712. * @param size defines the size of the texture
  8713. * @param options defines the creation options
  8714. * @returns the cube texture as an InternalTexture
  8715. */
  8716. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8717. private _setupFramebufferDepthAttachments;
  8718. /**
  8719. * Updates the sample count of a render target texture
  8720. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8721. * @param texture defines the texture to update
  8722. * @param samples defines the sample count to set
  8723. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8724. */
  8725. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8726. /**
  8727. * Update the sample count for a given multiple render target texture
  8728. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8729. * @param textures defines the textures to update
  8730. * @param samples defines the sample count to set
  8731. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8732. */
  8733. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8734. /** @hidden */
  8735. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8736. /** @hidden */
  8737. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8738. /** @hidden */
  8739. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8740. /** @hidden */
  8741. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8742. /**
  8743. * Creates a new render target cube texture
  8744. * @param size defines the size of the texture
  8745. * @param options defines the options used to create the texture
  8746. * @returns a new render target cube texture stored in an InternalTexture
  8747. */
  8748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8749. /**
  8750. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8751. * @param rootUrl defines the url where the file to load is located
  8752. * @param scene defines the current scene
  8753. * @param lodScale defines scale to apply to the mip map selection
  8754. * @param lodOffset defines offset to apply to the mip map selection
  8755. * @param onLoad defines an optional callback raised when the texture is loaded
  8756. * @param onError defines an optional callback raised if there is an issue to load the texture
  8757. * @param format defines the format of the data
  8758. * @param forcedExtension defines the extension to use to pick the right loader
  8759. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8760. * @returns the cube texture as an InternalTexture
  8761. */
  8762. 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;
  8763. /**
  8764. * Creates a cube texture
  8765. * @param rootUrl defines the url where the files to load is located
  8766. * @param scene defines the current scene
  8767. * @param files defines the list of files to load (1 per face)
  8768. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8769. * @param onLoad defines an optional callback raised when the texture is loaded
  8770. * @param onError defines an optional callback raised if there is an issue to load the texture
  8771. * @param format defines the format of the data
  8772. * @param forcedExtension defines the extension to use to pick the right loader
  8773. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8774. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8775. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8776. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8777. * @returns the cube texture as an InternalTexture
  8778. */
  8779. 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;
  8780. /**
  8781. * @hidden
  8782. */
  8783. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8784. /**
  8785. * Update a raw cube texture
  8786. * @param texture defines the texture to udpdate
  8787. * @param data defines the data to store
  8788. * @param format defines the data format
  8789. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8790. * @param invertY defines if data must be stored with Y axis inverted
  8791. * @param compression defines the compression used (null by default)
  8792. * @param level defines which level of the texture to update
  8793. */
  8794. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8795. /**
  8796. * Creates a new raw cube texture
  8797. * @param data defines the array of data to use to create each face
  8798. * @param size defines the size of the textures
  8799. * @param format defines the format of the data
  8800. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8801. * @param generateMipMaps defines if the engine should generate the mip levels
  8802. * @param invertY defines if data must be stored with Y axis inverted
  8803. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8804. * @param compression defines the compression used (null by default)
  8805. * @returns the cube texture as an InternalTexture
  8806. */
  8807. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8808. /**
  8809. * Creates a new raw cube texture from a specified url
  8810. * @param url defines the url where the data is located
  8811. * @param scene defines the current scene
  8812. * @param size defines the size of the textures
  8813. * @param format defines the format of the data
  8814. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8815. * @param noMipmap defines if the engine should avoid generating the mip levels
  8816. * @param callback defines a callback used to extract texture data from loaded data
  8817. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8818. * @param onLoad defines a callback called when texture is loaded
  8819. * @param onError defines a callback called if there is an error
  8820. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8821. * @param invertY defines if data must be stored with Y axis inverted
  8822. * @returns the cube texture as an InternalTexture
  8823. */
  8824. 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;
  8825. /**
  8826. * Update a raw 3D texture
  8827. * @param texture defines the texture to update
  8828. * @param data defines the data to store
  8829. * @param format defines the data format
  8830. * @param invertY defines if data must be stored with Y axis inverted
  8831. * @param compression defines the used compression (can be null)
  8832. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8833. */
  8834. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8835. /**
  8836. * Creates a new raw 3D texture
  8837. * @param data defines the data used to create the texture
  8838. * @param width defines the width of the texture
  8839. * @param height defines the height of the texture
  8840. * @param depth defines the depth of the texture
  8841. * @param format defines the format of the texture
  8842. * @param generateMipMaps defines if the engine must generate mip levels
  8843. * @param invertY defines if data must be stored with Y axis inverted
  8844. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8845. * @param compression defines the compressed used (can be null)
  8846. * @param textureType defines the compressed used (can be null)
  8847. * @returns a new raw 3D texture (stored in an InternalTexture)
  8848. */
  8849. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8850. private _prepareWebGLTextureContinuation;
  8851. private _prepareWebGLTexture;
  8852. private _convertRGBtoRGBATextureData;
  8853. /** @hidden */
  8854. _releaseFramebufferObjects(texture: InternalTexture): void;
  8855. /** @hidden */
  8856. _releaseTexture(texture: InternalTexture): void;
  8857. private setProgram;
  8858. private _boundUniforms;
  8859. /**
  8860. * Binds an effect to the webGL context
  8861. * @param effect defines the effect to bind
  8862. */
  8863. bindSamplers(effect: Effect): void;
  8864. private _moveBoundTextureOnTop;
  8865. private _getCorrectTextureChannel;
  8866. private _linkTrackers;
  8867. private _removeDesignatedSlot;
  8868. private _activateCurrentTexture;
  8869. /** @hidden */
  8870. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8871. /** @hidden */
  8872. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8873. /**
  8874. * Sets a texture to the webGL context from a postprocess
  8875. * @param channel defines the channel to use
  8876. * @param postProcess defines the source postprocess
  8877. */
  8878. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8879. /**
  8880. * Binds the output of the passed in post process to the texture channel specified
  8881. * @param channel The channel the texture should be bound to
  8882. * @param postProcess The post process which's output should be bound
  8883. */
  8884. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8885. /**
  8886. * Unbind all textures from the webGL context
  8887. */
  8888. unbindAllTextures(): void;
  8889. /**
  8890. * Sets a texture to the according uniform.
  8891. * @param channel The texture channel
  8892. * @param uniform The uniform to set
  8893. * @param texture The texture to apply
  8894. */
  8895. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8896. /**
  8897. * Sets a depth stencil texture from a render target to the according uniform.
  8898. * @param channel The texture channel
  8899. * @param uniform The uniform to set
  8900. * @param texture The render target texture containing the depth stencil texture to apply
  8901. */
  8902. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8903. private _bindSamplerUniformToChannel;
  8904. private _getTextureWrapMode;
  8905. private _setTexture;
  8906. /**
  8907. * Sets an array of texture to the webGL context
  8908. * @param channel defines the channel where the texture array must be set
  8909. * @param uniform defines the associated uniform location
  8910. * @param textures defines the array of textures to bind
  8911. */
  8912. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8913. /** @hidden */
  8914. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8915. private _setTextureParameterFloat;
  8916. private _setTextureParameterInteger;
  8917. /**
  8918. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8919. * @param x defines the x coordinate of the rectangle where pixels must be read
  8920. * @param y defines the y coordinate of the rectangle where pixels must be read
  8921. * @param width defines the width of the rectangle where pixels must be read
  8922. * @param height defines the height of the rectangle where pixels must be read
  8923. * @returns a Uint8Array containing RGBA colors
  8924. */
  8925. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8926. /**
  8927. * Add an externaly attached data from its key.
  8928. * This method call will fail and return false, if such key already exists.
  8929. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8930. * @param key the unique key that identifies the data
  8931. * @param data the data object to associate to the key for this Engine instance
  8932. * @return true if no such key were already present and the data was added successfully, false otherwise
  8933. */
  8934. addExternalData<T>(key: string, data: T): boolean;
  8935. /**
  8936. * Get an externaly attached data from its key
  8937. * @param key the unique key that identifies the data
  8938. * @return the associated data, if present (can be null), or undefined if not present
  8939. */
  8940. getExternalData<T>(key: string): T;
  8941. /**
  8942. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8943. * @param key the unique key that identifies the data
  8944. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8945. * @return the associated data, can be null if the factory returned null.
  8946. */
  8947. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8948. /**
  8949. * Remove an externaly attached data from the Engine instance
  8950. * @param key the unique key that identifies the data
  8951. * @return true if the data was successfully removed, false if it doesn't exist
  8952. */
  8953. removeExternalData(key: string): boolean;
  8954. /**
  8955. * Unbind all vertex attributes from the webGL context
  8956. */
  8957. unbindAllAttributes(): void;
  8958. /**
  8959. * 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
  8960. */
  8961. releaseEffects(): void;
  8962. /**
  8963. * Dispose and release all associated resources
  8964. */
  8965. dispose(): void;
  8966. /**
  8967. * Display the loading screen
  8968. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8969. */
  8970. displayLoadingUI(): void;
  8971. /**
  8972. * Hide the loading screen
  8973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8974. */
  8975. hideLoadingUI(): void;
  8976. /**
  8977. * Gets the current loading screen object
  8978. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8979. */
  8980. /**
  8981. * Sets the current loading screen object
  8982. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8983. */
  8984. loadingScreen: ILoadingScreen;
  8985. /**
  8986. * Sets the current loading screen text
  8987. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8988. */
  8989. loadingUIText: string;
  8990. /**
  8991. * Sets the current loading screen background color
  8992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8993. */
  8994. loadingUIBackgroundColor: string;
  8995. /**
  8996. * Attach a new callback raised when context lost event is fired
  8997. * @param callback defines the callback to call
  8998. */
  8999. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9000. /**
  9001. * Attach a new callback raised when context restored event is fired
  9002. * @param callback defines the callback to call
  9003. */
  9004. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9005. /**
  9006. * Gets the source code of the vertex shader associated with a specific webGL program
  9007. * @param program defines the program to use
  9008. * @returns a string containing the source code of the vertex shader associated with the program
  9009. */
  9010. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9011. /**
  9012. * Gets the source code of the fragment shader associated with a specific webGL program
  9013. * @param program defines the program to use
  9014. * @returns a string containing the source code of the fragment shader associated with the program
  9015. */
  9016. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9017. /**
  9018. * Get the current error code of the webGL context
  9019. * @returns the error code
  9020. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9021. */
  9022. getError(): number;
  9023. /**
  9024. * Gets the current framerate
  9025. * @returns a number representing the framerate
  9026. */
  9027. getFps(): number;
  9028. /**
  9029. * Gets the time spent between current and previous frame
  9030. * @returns a number representing the delta time in ms
  9031. */
  9032. getDeltaTime(): number;
  9033. private _measureFps;
  9034. /** @hidden */
  9035. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9036. private _canRenderToFloatFramebuffer;
  9037. private _canRenderToHalfFloatFramebuffer;
  9038. private _canRenderToFramebuffer;
  9039. /** @hidden */
  9040. _getWebGLTextureType(type: number): number;
  9041. private _getInternalFormat;
  9042. /** @hidden */
  9043. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9044. /** @hidden */
  9045. _getRGBAMultiSampleBufferFormat(type: number): number;
  9046. /** @hidden */
  9047. _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;
  9048. /** @hidden */
  9049. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9050. private _partialLoadFile;
  9051. private _cascadeLoadFiles;
  9052. /**
  9053. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9054. * @returns true if the engine can be created
  9055. * @ignorenaming
  9056. */
  9057. static isSupported(): boolean;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. class NullEngineOptions {
  9062. renderWidth: number;
  9063. renderHeight: number;
  9064. textureSize: number;
  9065. deterministicLockstep: boolean;
  9066. lockstepMaxSteps: number;
  9067. }
  9068. /**
  9069. * The null engine class provides support for headless version of babylon.js.
  9070. * This can be used in server side scenario or for testing purposes
  9071. */
  9072. class NullEngine extends Engine {
  9073. private _options;
  9074. isDeterministicLockStep(): boolean;
  9075. getLockstepMaxSteps(): number;
  9076. getHardwareScalingLevel(): number;
  9077. constructor(options?: NullEngineOptions);
  9078. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9079. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9080. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9081. getRenderWidth(useScreen?: boolean): number;
  9082. getRenderHeight(useScreen?: boolean): number;
  9083. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9084. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9085. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9086. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9087. bindSamplers(effect: Effect): void;
  9088. enableEffect(effect: Effect): void;
  9089. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9090. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9091. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9092. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9093. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9094. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9095. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9096. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9097. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9098. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9099. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9100. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9101. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9102. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9103. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9104. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9105. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9106. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9107. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9108. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9109. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9110. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9111. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9112. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9113. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9114. bindBuffers(vertexBuffers: {
  9115. [key: string]: VertexBuffer;
  9116. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9117. wipeCaches(bruteForce?: boolean): void;
  9118. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9119. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9121. /** @hidden */
  9122. _createTexture(): WebGLTexture;
  9123. /** @hidden */
  9124. _releaseTexture(texture: InternalTexture): void;
  9125. 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;
  9126. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9127. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9128. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9129. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9130. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9131. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9132. /**
  9133. * @hidden
  9134. * Get the current error code of the webGL context
  9135. * @returns the error code
  9136. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9137. */
  9138. getError(): number;
  9139. /** @hidden */
  9140. _getUnpackAlignement(): number;
  9141. /** @hidden */
  9142. _unpackFlipY(value: boolean): void;
  9143. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9144. /**
  9145. * Updates a dynamic vertex buffer.
  9146. * @param vertexBuffer the vertex buffer to update
  9147. * @param data the data used to update the vertex buffer
  9148. * @param byteOffset the byte offset of the data (optional)
  9149. * @param byteLength the byte length of the data (optional)
  9150. */
  9151. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9152. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9153. /** @hidden */
  9154. _bindTexture(channel: number, texture: InternalTexture): void;
  9155. /** @hidden */
  9156. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9157. releaseEffects(): void;
  9158. displayLoadingUI(): void;
  9159. hideLoadingUI(): void;
  9160. /** @hidden */
  9161. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9162. /** @hidden */
  9163. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9164. /** @hidden */
  9165. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9166. /** @hidden */
  9167. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9168. }
  9169. }
  9170. interface WebGLRenderingContext {
  9171. readonly RASTERIZER_DISCARD: number;
  9172. readonly DEPTH_COMPONENT24: number;
  9173. readonly TEXTURE_3D: number;
  9174. readonly TEXTURE_2D_ARRAY: number;
  9175. readonly TEXTURE_COMPARE_FUNC: number;
  9176. readonly TEXTURE_COMPARE_MODE: number;
  9177. readonly COMPARE_REF_TO_TEXTURE: number;
  9178. readonly TEXTURE_WRAP_R: number;
  9179. readonly HALF_FLOAT: number;
  9180. readonly RGB8: number;
  9181. readonly RED_INTEGER: number;
  9182. readonly RG_INTEGER: number;
  9183. readonly RGB_INTEGER: number;
  9184. readonly RGBA_INTEGER: number;
  9185. readonly R8_SNORM: number;
  9186. readonly RG8_SNORM: number;
  9187. readonly RGB8_SNORM: number;
  9188. readonly RGBA8_SNORM: number;
  9189. readonly R8I: number;
  9190. readonly RG8I: number;
  9191. readonly RGB8I: number;
  9192. readonly RGBA8I: number;
  9193. readonly R8UI: number;
  9194. readonly RG8UI: number;
  9195. readonly RGB8UI: number;
  9196. readonly RGBA8UI: number;
  9197. readonly R16I: number;
  9198. readonly RG16I: number;
  9199. readonly RGB16I: number;
  9200. readonly RGBA16I: number;
  9201. readonly R16UI: number;
  9202. readonly RG16UI: number;
  9203. readonly RGB16UI: number;
  9204. readonly RGBA16UI: number;
  9205. readonly R32I: number;
  9206. readonly RG32I: number;
  9207. readonly RGB32I: number;
  9208. readonly RGBA32I: number;
  9209. readonly R32UI: number;
  9210. readonly RG32UI: number;
  9211. readonly RGB32UI: number;
  9212. readonly RGBA32UI: number;
  9213. readonly RGB10_A2UI: number;
  9214. readonly R11F_G11F_B10F: number;
  9215. readonly RGB9_E5: number;
  9216. readonly RGB10_A2: number;
  9217. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9218. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9219. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9220. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9221. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9222. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9223. 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;
  9224. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9225. readonly TRANSFORM_FEEDBACK: number;
  9226. readonly INTERLEAVED_ATTRIBS: number;
  9227. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9228. createTransformFeedback(): WebGLTransformFeedback;
  9229. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9230. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9231. beginTransformFeedback(primitiveMode: number): void;
  9232. endTransformFeedback(): void;
  9233. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9234. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9235. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9236. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9237. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9238. }
  9239. interface ImageBitmap {
  9240. readonly width: number;
  9241. readonly height: number;
  9242. close(): void;
  9243. }
  9244. interface WebGLQuery extends WebGLObject {
  9245. }
  9246. declare var WebGLQuery: {
  9247. prototype: WebGLQuery;
  9248. new (): WebGLQuery;
  9249. };
  9250. interface WebGLSampler extends WebGLObject {
  9251. }
  9252. declare var WebGLSampler: {
  9253. prototype: WebGLSampler;
  9254. new (): WebGLSampler;
  9255. };
  9256. interface WebGLSync extends WebGLObject {
  9257. }
  9258. declare var WebGLSync: {
  9259. prototype: WebGLSync;
  9260. new (): WebGLSync;
  9261. };
  9262. interface WebGLTransformFeedback extends WebGLObject {
  9263. }
  9264. declare var WebGLTransformFeedback: {
  9265. prototype: WebGLTransformFeedback;
  9266. new (): WebGLTransformFeedback;
  9267. };
  9268. interface WebGLVertexArrayObject extends WebGLObject {
  9269. }
  9270. declare var WebGLVertexArrayObject: {
  9271. prototype: WebGLVertexArrayObject;
  9272. new (): WebGLVertexArrayObject;
  9273. };
  9274. declare module BABYLON {
  9275. class KeyboardEventTypes {
  9276. static _KEYDOWN: number;
  9277. static _KEYUP: number;
  9278. static readonly KEYDOWN: number;
  9279. static readonly KEYUP: number;
  9280. }
  9281. class KeyboardInfo {
  9282. type: number;
  9283. event: KeyboardEvent;
  9284. constructor(type: number, event: KeyboardEvent);
  9285. }
  9286. /**
  9287. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9288. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9289. */
  9290. class KeyboardInfoPre extends KeyboardInfo {
  9291. constructor(type: number, event: KeyboardEvent);
  9292. skipOnPointerObservable: boolean;
  9293. }
  9294. }
  9295. declare module BABYLON {
  9296. class PointerEventTypes {
  9297. static _POINTERDOWN: number;
  9298. static _POINTERUP: number;
  9299. static _POINTERMOVE: number;
  9300. static _POINTERWHEEL: number;
  9301. static _POINTERPICK: number;
  9302. static _POINTERTAP: number;
  9303. static _POINTERDOUBLETAP: number;
  9304. static readonly POINTERDOWN: number;
  9305. static readonly POINTERUP: number;
  9306. static readonly POINTERMOVE: number;
  9307. static readonly POINTERWHEEL: number;
  9308. static readonly POINTERPICK: number;
  9309. static readonly POINTERTAP: number;
  9310. static readonly POINTERDOUBLETAP: number;
  9311. }
  9312. class PointerInfoBase {
  9313. type: number;
  9314. event: PointerEvent | MouseWheelEvent;
  9315. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9316. }
  9317. /**
  9318. * This class is used to store pointer related info for the onPrePointerObservable event.
  9319. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9320. */
  9321. class PointerInfoPre extends PointerInfoBase {
  9322. /**
  9323. * Ray from a pointer if availible (eg. 6dof controller)
  9324. */
  9325. ray: Nullable<Ray>;
  9326. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9327. localPosition: Vector2;
  9328. skipOnPointerObservable: boolean;
  9329. }
  9330. /**
  9331. * This type contains all the data related to a pointer event in Babylon.js.
  9332. * 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.
  9333. */
  9334. class PointerInfo extends PointerInfoBase {
  9335. pickInfo: Nullable<PickingInfo>;
  9336. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9337. }
  9338. }
  9339. /**
  9340. * Module Debug contains the (visual) components to debug a scene correctly
  9341. */
  9342. declare module BABYLON.Debug {
  9343. /**
  9344. * The Axes viewer will show 3 axes in a specific point in space
  9345. */
  9346. class AxesViewer {
  9347. private _xline;
  9348. private _yline;
  9349. private _zline;
  9350. private _xmesh;
  9351. private _ymesh;
  9352. private _zmesh;
  9353. /**
  9354. * Gets the hosting scene
  9355. */
  9356. scene: Nullable<Scene>;
  9357. /**
  9358. * Gets or sets a number used to scale line length
  9359. */
  9360. scaleLines: number;
  9361. /**
  9362. * Creates a new AxesViewer
  9363. * @param scene defines the hosting scene
  9364. * @param scaleLines defines a number used to scale line length (1 by default)
  9365. */
  9366. constructor(scene: Scene, scaleLines?: number);
  9367. /**
  9368. * Force the viewer to update
  9369. * @param position defines the position of the viewer
  9370. * @param xaxis defines the x axis of the viewer
  9371. * @param yaxis defines the y axis of the viewer
  9372. * @param zaxis defines the z axis of the viewer
  9373. */
  9374. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9375. /** Releases resources */
  9376. dispose(): void;
  9377. }
  9378. }
  9379. declare module BABYLON.Debug {
  9380. /**
  9381. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9382. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9383. */
  9384. class BoneAxesViewer extends AxesViewer {
  9385. /**
  9386. * Gets or sets the target mesh where to display the axes viewer
  9387. */
  9388. mesh: Nullable<Mesh>;
  9389. /**
  9390. * Gets or sets the target bone where to display the axes viewer
  9391. */
  9392. bone: Nullable<Bone>;
  9393. /** Gets current position */
  9394. pos: Vector3;
  9395. /** Gets direction of X axis */
  9396. xaxis: Vector3;
  9397. /** Gets direction of Y axis */
  9398. yaxis: Vector3;
  9399. /** Gets direction of Z axis */
  9400. zaxis: Vector3;
  9401. /**
  9402. * Creates a new BoneAxesViewer
  9403. * @param scene defines the hosting scene
  9404. * @param bone defines the target bone
  9405. * @param mesh defines the target mesh
  9406. * @param scaleLines defines a scaling factor for line length (1 by default)
  9407. */
  9408. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9409. /**
  9410. * Force the viewer to update
  9411. */
  9412. update(): void;
  9413. /** Releases resources */
  9414. dispose(): void;
  9415. }
  9416. }
  9417. declare module BABYLON {
  9418. class DebugLayer {
  9419. private _scene;
  9420. static InspectorURL: string;
  9421. private _inspector;
  9422. private BJSINSPECTOR;
  9423. onPropertyChangedObservable: Observable<{
  9424. object: any;
  9425. property: string;
  9426. value: any;
  9427. initialValue: any;
  9428. }>;
  9429. constructor(scene: Scene);
  9430. /** Creates the inspector window. */
  9431. private _createInspector;
  9432. isVisible(): boolean;
  9433. hide(): void;
  9434. /**
  9435. *
  9436. * Launch the debugLayer.
  9437. *
  9438. * initialTab:
  9439. * | Value | Tab Name |
  9440. * | --- | --- |
  9441. * | 0 | Scene |
  9442. * | 1 | Console |
  9443. * | 2 | Stats |
  9444. * | 3 | Textures |
  9445. * | 4 | Mesh |
  9446. * | 5 | Light |
  9447. * | 6 | Material |
  9448. * | 7 | GLTF |
  9449. * | 8 | GUI |
  9450. * | 9 | Physics |
  9451. * | 10 | Camera |
  9452. * | 11 | Audio |
  9453. *
  9454. */
  9455. show(config?: {
  9456. popup?: boolean;
  9457. initialTab?: number;
  9458. parentElement?: HTMLElement;
  9459. newColors?: {
  9460. backgroundColor?: string;
  9461. backgroundColorLighter?: string;
  9462. backgroundColorLighter2?: string;
  9463. backgroundColorLighter3?: string;
  9464. color?: string;
  9465. colorTop?: string;
  9466. colorBot?: string;
  9467. };
  9468. }): void;
  9469. /**
  9470. * Gets the active tab
  9471. * @return the index of the active tab or -1 if the inspector is hidden
  9472. */
  9473. getActiveTab(): number;
  9474. }
  9475. }
  9476. declare module BABYLON.Debug {
  9477. /**
  9478. * Used to show the physics impostor around the specific mesh
  9479. */
  9480. class PhysicsViewer {
  9481. /** @hidden */
  9482. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9483. /** @hidden */
  9484. protected _meshes: Array<Nullable<AbstractMesh>>;
  9485. /** @hidden */
  9486. protected _scene: Nullable<Scene>;
  9487. /** @hidden */
  9488. protected _numMeshes: number;
  9489. /** @hidden */
  9490. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9491. private _renderFunction;
  9492. private _debugBoxMesh;
  9493. private _debugSphereMesh;
  9494. private _debugMaterial;
  9495. /**
  9496. * Creates a new PhysicsViewer
  9497. * @param scene defines the hosting scene
  9498. */
  9499. constructor(scene: Scene);
  9500. /** @hidden */
  9501. protected _updateDebugMeshes(): void;
  9502. /**
  9503. * Renders a specified physic impostor
  9504. * @param impostor defines the impostor to render
  9505. */
  9506. showImpostor(impostor: PhysicsImpostor): void;
  9507. /**
  9508. * Hides a specified physic impostor
  9509. * @param impostor defines the impostor to hide
  9510. */
  9511. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9512. private _getDebugMaterial;
  9513. private _getDebugBoxMesh;
  9514. private _getDebugSphereMesh;
  9515. private _getDebugMesh;
  9516. /** Releases all resources */
  9517. dispose(): void;
  9518. }
  9519. }
  9520. declare module BABYLON {
  9521. class RayHelper {
  9522. ray: Nullable<Ray>;
  9523. private _renderPoints;
  9524. private _renderLine;
  9525. private _renderFunction;
  9526. private _scene;
  9527. private _updateToMeshFunction;
  9528. private _attachedToMesh;
  9529. private _meshSpaceDirection;
  9530. private _meshSpaceOrigin;
  9531. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9532. constructor(ray: Ray);
  9533. show(scene: Scene, color?: Color3): void;
  9534. hide(): void;
  9535. private _render;
  9536. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9537. detachFromMesh(): void;
  9538. private _updateToMesh;
  9539. dispose(): void;
  9540. }
  9541. }
  9542. declare module BABYLON.Debug {
  9543. /**
  9544. * Class used to render a debug view of a given skeleton
  9545. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9546. */
  9547. class SkeletonViewer {
  9548. /** defines the skeleton to render */
  9549. skeleton: Skeleton;
  9550. /** defines the mesh attached to the skeleton */
  9551. mesh: AbstractMesh;
  9552. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9553. autoUpdateBonesMatrices: boolean;
  9554. /** defines the rendering group id to use with the viewer */
  9555. renderingGroupId: number;
  9556. /** Gets or sets the color used to render the skeleton */
  9557. color: Color3;
  9558. private _scene;
  9559. private _debugLines;
  9560. private _debugMesh;
  9561. private _isEnabled;
  9562. private _renderFunction;
  9563. /**
  9564. * Creates a new SkeletonViewer
  9565. * @param skeleton defines the skeleton to render
  9566. * @param mesh defines the mesh attached to the skeleton
  9567. * @param scene defines the hosting scene
  9568. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9569. * @param renderingGroupId defines the rendering group id to use with the viewer
  9570. */
  9571. constructor(
  9572. /** defines the skeleton to render */
  9573. skeleton: Skeleton,
  9574. /** defines the mesh attached to the skeleton */
  9575. mesh: AbstractMesh, scene: Scene,
  9576. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9577. autoUpdateBonesMatrices?: boolean,
  9578. /** defines the rendering group id to use with the viewer */
  9579. renderingGroupId?: number);
  9580. /** Gets or sets a boolean indicating if the viewer is enabled */
  9581. isEnabled: boolean;
  9582. private _getBonePosition;
  9583. private _getLinesForBonesWithLength;
  9584. private _getLinesForBonesNoLength;
  9585. /** Update the viewer to sync with current skeleton state */
  9586. update(): void;
  9587. /** Release associated resources */
  9588. dispose(): void;
  9589. }
  9590. }
  9591. declare module BABYLON {
  9592. class StickValues {
  9593. x: number;
  9594. y: number;
  9595. constructor(x: number, y: number);
  9596. }
  9597. interface GamepadButtonChanges {
  9598. changed: boolean;
  9599. pressChanged: boolean;
  9600. touchChanged: boolean;
  9601. valueChanged: boolean;
  9602. }
  9603. class Gamepad {
  9604. id: string;
  9605. index: number;
  9606. browserGamepad: any;
  9607. type: number;
  9608. private _leftStick;
  9609. private _rightStick;
  9610. /** @hidden */
  9611. _isConnected: boolean;
  9612. private _leftStickAxisX;
  9613. private _leftStickAxisY;
  9614. private _rightStickAxisX;
  9615. private _rightStickAxisY;
  9616. private _onleftstickchanged;
  9617. private _onrightstickchanged;
  9618. static GAMEPAD: number;
  9619. static GENERIC: number;
  9620. static XBOX: number;
  9621. static POSE_ENABLED: number;
  9622. protected _invertLeftStickY: boolean;
  9623. readonly isConnected: boolean;
  9624. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9625. onleftstickchanged(callback: (values: StickValues) => void): void;
  9626. onrightstickchanged(callback: (values: StickValues) => void): void;
  9627. leftStick: StickValues;
  9628. rightStick: StickValues;
  9629. update(): void;
  9630. dispose(): void;
  9631. }
  9632. class GenericPad extends Gamepad {
  9633. private _buttons;
  9634. private _onbuttondown;
  9635. private _onbuttonup;
  9636. onButtonDownObservable: Observable<number>;
  9637. onButtonUpObservable: Observable<number>;
  9638. onbuttondown(callback: (buttonPressed: number) => void): void;
  9639. onbuttonup(callback: (buttonReleased: number) => void): void;
  9640. constructor(id: string, index: number, browserGamepad: any);
  9641. private _setButtonValue;
  9642. update(): void;
  9643. dispose(): void;
  9644. }
  9645. }
  9646. declare module BABYLON {
  9647. class GamepadManager {
  9648. private _scene?;
  9649. private _babylonGamepads;
  9650. private _oneGamepadConnected;
  9651. /** @hidden */
  9652. _isMonitoring: boolean;
  9653. private _gamepadEventSupported;
  9654. private _gamepadSupport;
  9655. onGamepadConnectedObservable: Observable<Gamepad>;
  9656. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9657. private _onGamepadConnectedEvent;
  9658. private _onGamepadDisconnectedEvent;
  9659. constructor(_scene?: Scene | undefined);
  9660. readonly gamepads: Gamepad[];
  9661. getGamepadByType(type?: number): Nullable<Gamepad>;
  9662. dispose(): void;
  9663. private _addNewGamepad;
  9664. private _startMonitoringGamepads;
  9665. private _stopMonitoringGamepads;
  9666. /** @hidden */
  9667. _checkGamepadsStatus(): void;
  9668. private _updateGamepadObjects;
  9669. }
  9670. }
  9671. declare module BABYLON {
  9672. interface Scene {
  9673. /** @hidden */
  9674. _gamepadManager: Nullable<GamepadManager>;
  9675. /**
  9676. * Gets the gamepad manager associated with the scene
  9677. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9678. */
  9679. gamepadManager: GamepadManager;
  9680. }
  9681. interface FreeCameraInputsManager {
  9682. addGamepad(): FreeCameraInputsManager;
  9683. }
  9684. interface ArcRotateCameraInputsManager {
  9685. addGamepad(): ArcRotateCameraInputsManager;
  9686. }
  9687. /**
  9688. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9689. */
  9690. class GamepadSystemSceneComponent implements ISceneComponent {
  9691. /**
  9692. * The component name helpfull to identify the component in the list of scene components.
  9693. */
  9694. readonly name: string;
  9695. /**
  9696. * The scene the component belongs to.
  9697. */
  9698. scene: Scene;
  9699. /**
  9700. * Creates a new instance of the component for the given scene
  9701. * @param scene Defines the scene to register the component in
  9702. */
  9703. constructor(scene: Scene);
  9704. /**
  9705. * Registers the component in a given scene
  9706. */
  9707. register(): void;
  9708. /**
  9709. * Rebuilds the elements related to this component in case of
  9710. * context lost for instance.
  9711. */
  9712. rebuild(): void;
  9713. /**
  9714. * Disposes the component and the associated ressources
  9715. */
  9716. dispose(): void;
  9717. private _beforeCameraUpdate;
  9718. }
  9719. }
  9720. declare module BABYLON {
  9721. /**
  9722. * Defines supported buttons for XBox360 compatible gamepads
  9723. */
  9724. enum Xbox360Button {
  9725. /** A */
  9726. A = 0,
  9727. /** B */
  9728. B = 1,
  9729. /** X */
  9730. X = 2,
  9731. /** Y */
  9732. Y = 3,
  9733. /** Start */
  9734. Start = 4,
  9735. /** Back */
  9736. Back = 5,
  9737. /** Left button */
  9738. LB = 6,
  9739. /** Right button */
  9740. RB = 7,
  9741. /** Left stick */
  9742. LeftStick = 8,
  9743. /** Right stick */
  9744. RightStick = 9
  9745. }
  9746. /** Defines values for XBox360 DPad */
  9747. enum Xbox360Dpad {
  9748. /** Up */
  9749. Up = 0,
  9750. /** Down */
  9751. Down = 1,
  9752. /** Left */
  9753. Left = 2,
  9754. /** Right */
  9755. Right = 3
  9756. }
  9757. /**
  9758. * Defines a XBox360 gamepad
  9759. */
  9760. class Xbox360Pad extends Gamepad {
  9761. private _leftTrigger;
  9762. private _rightTrigger;
  9763. private _onlefttriggerchanged;
  9764. private _onrighttriggerchanged;
  9765. private _onbuttondown;
  9766. private _onbuttonup;
  9767. private _ondpaddown;
  9768. private _ondpadup;
  9769. /** Observable raised when a button is pressed */
  9770. onButtonDownObservable: Observable<Xbox360Button>;
  9771. /** Observable raised when a button is released */
  9772. onButtonUpObservable: Observable<Xbox360Button>;
  9773. /** Observable raised when a pad is pressed */
  9774. onPadDownObservable: Observable<Xbox360Dpad>;
  9775. /** Observable raised when a pad is released */
  9776. onPadUpObservable: Observable<Xbox360Dpad>;
  9777. private _buttonA;
  9778. private _buttonB;
  9779. private _buttonX;
  9780. private _buttonY;
  9781. private _buttonBack;
  9782. private _buttonStart;
  9783. private _buttonLB;
  9784. private _buttonRB;
  9785. private _buttonLeftStick;
  9786. private _buttonRightStick;
  9787. private _dPadUp;
  9788. private _dPadDown;
  9789. private _dPadLeft;
  9790. private _dPadRight;
  9791. private _isXboxOnePad;
  9792. /**
  9793. * Creates a new XBox360 gamepad object
  9794. * @param id defines the id of this gamepad
  9795. * @param index defines its index
  9796. * @param gamepad defines the internal HTML gamepad object
  9797. * @param xboxOne defines if it is a XBox One gamepad
  9798. */
  9799. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9800. /**
  9801. * Defines the callback to call when left trigger is pressed
  9802. * @param callback defines the callback to use
  9803. */
  9804. onlefttriggerchanged(callback: (value: number) => void): void;
  9805. /**
  9806. * Defines the callback to call when right trigger is pressed
  9807. * @param callback defines the callback to use
  9808. */
  9809. onrighttriggerchanged(callback: (value: number) => void): void;
  9810. /**
  9811. * Gets or sets left trigger value
  9812. */
  9813. leftTrigger: number;
  9814. /**
  9815. * Gets or sets right trigger value
  9816. */
  9817. rightTrigger: number;
  9818. /**
  9819. * Defines the callback to call when a button is pressed
  9820. * @param callback defines the callback to use
  9821. */
  9822. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9823. /**
  9824. * Defines the callback to call when a button is released
  9825. * @param callback defines the callback to use
  9826. */
  9827. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9828. /**
  9829. * Defines the callback to call when a pad is pressed
  9830. * @param callback defines the callback to use
  9831. */
  9832. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9833. /**
  9834. * Defines the callback to call when a pad is released
  9835. * @param callback defines the callback to use
  9836. */
  9837. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9838. private _setButtonValue;
  9839. private _setDPadValue;
  9840. /** Gets or sets value of A button */
  9841. buttonA: number;
  9842. /** Gets or sets value of B button */
  9843. buttonB: number;
  9844. /** Gets or sets value of X button */
  9845. buttonX: number;
  9846. /** Gets or sets value of Y button */
  9847. buttonY: number;
  9848. /** Gets or sets value of Start button */
  9849. buttonStart: number;
  9850. /** Gets or sets value of Back button */
  9851. buttonBack: number;
  9852. /** Gets or sets value of Left button */
  9853. buttonLB: number;
  9854. /** Gets or sets value of Right button */
  9855. buttonRB: number;
  9856. /** Gets or sets value of left stick */
  9857. buttonLeftStick: number;
  9858. /** Gets or sets value of right stick */
  9859. buttonRightStick: number;
  9860. /** Gets or sets value of DPad up */
  9861. dPadUp: number;
  9862. /** Gets or sets value of DPad down */
  9863. dPadDown: number;
  9864. /** Gets or sets value of DPad left */
  9865. dPadLeft: number;
  9866. /** Gets or sets value of DPad right */
  9867. dPadRight: number;
  9868. /**
  9869. * Force the gamepad to synchronize with device values
  9870. */
  9871. update(): void;
  9872. dispose(): void;
  9873. }
  9874. }
  9875. declare module BABYLON {
  9876. /**
  9877. * Single axis drag gizmo
  9878. */
  9879. class AxisDragGizmo extends Gizmo {
  9880. /**
  9881. * Drag behavior responsible for the gizmos dragging interactions
  9882. */
  9883. dragBehavior: PointerDragBehavior;
  9884. private _pointerObserver;
  9885. /**
  9886. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9887. */
  9888. snapDistance: number;
  9889. /**
  9890. * Event that fires each time the gizmo snaps to a new location.
  9891. * * snapDistance is the the change in distance
  9892. */
  9893. onSnapObservable: Observable<{
  9894. snapDistance: number;
  9895. }>;
  9896. /**
  9897. * Creates an AxisDragGizmo
  9898. * @param gizmoLayer The utility layer the gizmo will be added to
  9899. * @param dragAxis The axis which the gizmo will be able to drag on
  9900. * @param color The color of the gizmo
  9901. */
  9902. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9903. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9904. /**
  9905. * Disposes of the gizmo
  9906. */
  9907. dispose(): void;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /**
  9912. * Single axis scale gizmo
  9913. */
  9914. class AxisScaleGizmo extends Gizmo {
  9915. private _coloredMaterial;
  9916. /**
  9917. * Drag behavior responsible for the gizmos dragging interactions
  9918. */
  9919. dragBehavior: PointerDragBehavior;
  9920. private _pointerObserver;
  9921. /**
  9922. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9923. */
  9924. snapDistance: number;
  9925. /**
  9926. * Event that fires each time the gizmo snaps to a new location.
  9927. * * snapDistance is the the change in distance
  9928. */
  9929. onSnapObservable: Observable<{
  9930. snapDistance: number;
  9931. }>;
  9932. /**
  9933. * If the scaling operation should be done on all axis (default: false)
  9934. */
  9935. uniformScaling: boolean;
  9936. /**
  9937. * Creates an AxisScaleGizmo
  9938. * @param gizmoLayer The utility layer the gizmo will be added to
  9939. * @param dragAxis The axis which the gizmo will be able to scale on
  9940. * @param color The color of the gizmo
  9941. */
  9942. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9943. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9944. /**
  9945. * Disposes of the gizmo
  9946. */
  9947. dispose(): void;
  9948. /**
  9949. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9950. * @param mesh The mesh to replace the default mesh of the gizmo
  9951. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9952. */
  9953. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9954. }
  9955. }
  9956. declare module BABYLON {
  9957. /**
  9958. * Bounding box gizmo
  9959. */
  9960. class BoundingBoxGizmo extends Gizmo {
  9961. private _lineBoundingBox;
  9962. private _rotateSpheresParent;
  9963. private _scaleBoxesParent;
  9964. private _boundingDimensions;
  9965. private _renderObserver;
  9966. private _pointerObserver;
  9967. private _scaleDragSpeed;
  9968. private _tmpQuaternion;
  9969. private _tmpVector;
  9970. private _tmpRotationMatrix;
  9971. /**
  9972. * 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)
  9973. */
  9974. ignoreChildren: boolean;
  9975. /**
  9976. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  9977. */
  9978. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  9979. /**
  9980. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9981. */
  9982. rotationSphereSize: number;
  9983. /**
  9984. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9985. */
  9986. scaleBoxSize: number;
  9987. /**
  9988. * 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)
  9989. */
  9990. fixedDragMeshScreenSize: boolean;
  9991. /**
  9992. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9993. */
  9994. fixedDragMeshScreenSizeDistanceFactor: number;
  9995. /**
  9996. * Fired when a rotation sphere or scale box is dragged
  9997. */
  9998. onDragStartObservable: Observable<{}>;
  9999. /**
  10000. * Fired when a scale box is dragged
  10001. */
  10002. onScaleBoxDragObservable: Observable<{}>;
  10003. /**
  10004. * Fired when a scale box drag is ended
  10005. */
  10006. onScaleBoxDragEndObservable: Observable<{}>;
  10007. /**
  10008. * Fired when a rotation sphere is dragged
  10009. */
  10010. onRotationSphereDragObservable: Observable<{}>;
  10011. /**
  10012. * Fired when a rotation sphere drag is ended
  10013. */
  10014. onRotationSphereDragEndObservable: Observable<{}>;
  10015. /**
  10016. * 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)
  10017. */
  10018. scalePivot: Nullable<Vector3>;
  10019. private _anchorMesh;
  10020. private _existingMeshScale;
  10021. private static _PivotCached;
  10022. private static _OldPivotPoint;
  10023. private static _PivotTranslation;
  10024. private static _PivotTmpVector;
  10025. /** @hidden */
  10026. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  10027. /** @hidden */
  10028. static _RestorePivotPoint(mesh: AbstractMesh): void;
  10029. /**
  10030. * Creates an BoundingBoxGizmo
  10031. * @param gizmoLayer The utility layer the gizmo will be added to
  10032. * @param color The color of the gizmo
  10033. */
  10034. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10036. private _selectNode;
  10037. /**
  10038. * Updates the bounding box information for the Gizmo
  10039. */
  10040. updateBoundingBox(): void;
  10041. /**
  10042. * Enables rotation on the specified axis and disables rotation on the others
  10043. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10044. */
  10045. setEnabledRotationAxis(axis: string): void;
  10046. /**
  10047. * Disposes of the gizmo
  10048. */
  10049. dispose(): void;
  10050. /**
  10051. * 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)
  10052. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10053. * @returns the bounding box mesh with the passed in mesh as a child
  10054. */
  10055. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10056. /**
  10057. * CustomMeshes are not supported by this gizmo
  10058. * @param mesh The mesh to replace the default mesh of the gizmo
  10059. */
  10060. setCustomMesh(mesh: Mesh): void;
  10061. }
  10062. }
  10063. declare module BABYLON {
  10064. /**
  10065. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10066. */
  10067. class Gizmo implements IDisposable {
  10068. /** The utility layer the gizmo will be added to */
  10069. gizmoLayer: UtilityLayerRenderer;
  10070. /**
  10071. * The root mesh of the gizmo
  10072. */
  10073. protected _rootMesh: Mesh;
  10074. private _attachedMesh;
  10075. /**
  10076. * Ratio for the scale of the gizmo (Default: 1)
  10077. */
  10078. scaleRatio: number;
  10079. private _tmpMatrix;
  10080. /**
  10081. * If a custom mesh has been set (Default: false)
  10082. */
  10083. protected _customMeshSet: boolean;
  10084. /**
  10085. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10086. * * When set, interactions will be enabled
  10087. */
  10088. attachedMesh: Nullable<AbstractMesh>;
  10089. /**
  10090. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10091. * @param mesh The mesh to replace the default mesh of the gizmo
  10092. */
  10093. setCustomMesh(mesh: Mesh): void;
  10094. /**
  10095. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10096. */
  10097. updateGizmoRotationToMatchAttachedMesh: boolean;
  10098. /**
  10099. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10100. */
  10101. updateGizmoPositionToMatchAttachedMesh: boolean;
  10102. /**
  10103. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10104. */
  10105. protected _updateScale: boolean;
  10106. protected _interactionsEnabled: boolean;
  10107. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10108. private _beforeRenderObserver;
  10109. /**
  10110. * Creates a gizmo
  10111. * @param gizmoLayer The utility layer the gizmo will be added to
  10112. */
  10113. constructor(
  10114. /** The utility layer the gizmo will be added to */
  10115. gizmoLayer?: UtilityLayerRenderer);
  10116. private _tempVector;
  10117. /**
  10118. * @hidden
  10119. * Updates the gizmo to match the attached mesh's position/rotation
  10120. */
  10121. protected _update(): void;
  10122. /**
  10123. * Disposes of the gizmo
  10124. */
  10125. dispose(): void;
  10126. }
  10127. }
  10128. declare module BABYLON {
  10129. /**
  10130. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10131. */
  10132. class GizmoManager implements IDisposable {
  10133. private scene;
  10134. /**
  10135. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10136. */
  10137. gizmos: {
  10138. positionGizmo: Nullable<PositionGizmo>;
  10139. rotationGizmo: Nullable<RotationGizmo>;
  10140. scaleGizmo: Nullable<ScaleGizmo>;
  10141. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10142. };
  10143. private _gizmosEnabled;
  10144. private _pointerObserver;
  10145. private _attachedMesh;
  10146. private _boundingBoxColor;
  10147. private _dragBehavior;
  10148. /**
  10149. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10150. */
  10151. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10152. /**
  10153. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10154. */
  10155. usePointerToAttachGizmos: boolean;
  10156. /**
  10157. * Instatiates a gizmo manager
  10158. * @param scene the scene to overlay the gizmos on top of
  10159. */
  10160. constructor(scene: Scene);
  10161. /**
  10162. * Attaches a set of gizmos to the specified mesh
  10163. * @param mesh The mesh the gizmo's should be attached to
  10164. */
  10165. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10166. /**
  10167. * If the position gizmo is enabled
  10168. */
  10169. positionGizmoEnabled: boolean;
  10170. /**
  10171. * If the rotation gizmo is enabled
  10172. */
  10173. rotationGizmoEnabled: boolean;
  10174. /**
  10175. * If the scale gizmo is enabled
  10176. */
  10177. scaleGizmoEnabled: boolean;
  10178. /**
  10179. * If the boundingBox gizmo is enabled
  10180. */
  10181. boundingBoxGizmoEnabled: boolean;
  10182. /**
  10183. * Disposes of the gizmo manager
  10184. */
  10185. dispose(): void;
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * Single plane rotation gizmo
  10191. */
  10192. class PlaneRotationGizmo extends Gizmo {
  10193. /**
  10194. * Drag behavior responsible for the gizmos dragging interactions
  10195. */
  10196. dragBehavior: PointerDragBehavior;
  10197. private _pointerObserver;
  10198. /**
  10199. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10200. */
  10201. snapDistance: number;
  10202. /**
  10203. * Event that fires each time the gizmo snaps to a new location.
  10204. * * snapDistance is the the change in distance
  10205. */
  10206. onSnapObservable: Observable<{
  10207. snapDistance: number;
  10208. }>;
  10209. /**
  10210. * Creates a PlaneRotationGizmo
  10211. * @param gizmoLayer The utility layer the gizmo will be added to
  10212. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10213. * @param color The color of the gizmo
  10214. */
  10215. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10216. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10217. /**
  10218. * Disposes of the gizmo
  10219. */
  10220. dispose(): void;
  10221. }
  10222. }
  10223. declare module BABYLON {
  10224. /**
  10225. * Gizmo that enables dragging a mesh along 3 axis
  10226. */
  10227. class PositionGizmo extends Gizmo {
  10228. /**
  10229. * Internal gizmo used for interactions on the x axis
  10230. */
  10231. xGizmo: AxisDragGizmo;
  10232. /**
  10233. * Internal gizmo used for interactions on the y axis
  10234. */
  10235. yGizmo: AxisDragGizmo;
  10236. /**
  10237. * Internal gizmo used for interactions on the z axis
  10238. */
  10239. zGizmo: AxisDragGizmo;
  10240. attachedMesh: Nullable<AbstractMesh>;
  10241. /**
  10242. * Creates a PositionGizmo
  10243. * @param gizmoLayer The utility layer the gizmo will be added to
  10244. */
  10245. constructor(gizmoLayer?: UtilityLayerRenderer);
  10246. updateGizmoRotationToMatchAttachedMesh: boolean;
  10247. /**
  10248. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10249. */
  10250. snapDistance: number;
  10251. /**
  10252. * Ratio for the scale of the gizmo (Default: 1)
  10253. */
  10254. scaleRatio: number;
  10255. /**
  10256. * Disposes of the gizmo
  10257. */
  10258. dispose(): void;
  10259. /**
  10260. * CustomMeshes are not supported by this gizmo
  10261. * @param mesh The mesh to replace the default mesh of the gizmo
  10262. */
  10263. setCustomMesh(mesh: Mesh): void;
  10264. }
  10265. }
  10266. declare module BABYLON {
  10267. /**
  10268. * Gizmo that enables rotating a mesh along 3 axis
  10269. */
  10270. class RotationGizmo extends Gizmo {
  10271. /**
  10272. * Internal gizmo used for interactions on the x axis
  10273. */
  10274. xGizmo: PlaneRotationGizmo;
  10275. /**
  10276. * Internal gizmo used for interactions on the y axis
  10277. */
  10278. yGizmo: PlaneRotationGizmo;
  10279. /**
  10280. * Internal gizmo used for interactions on the z axis
  10281. */
  10282. zGizmo: PlaneRotationGizmo;
  10283. attachedMesh: Nullable<AbstractMesh>;
  10284. /**
  10285. * Creates a RotationGizmo
  10286. * @param gizmoLayer The utility layer the gizmo will be added to
  10287. */
  10288. constructor(gizmoLayer?: UtilityLayerRenderer);
  10289. updateGizmoRotationToMatchAttachedMesh: boolean;
  10290. /**
  10291. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10292. */
  10293. snapDistance: number;
  10294. /**
  10295. * Ratio for the scale of the gizmo (Default: 1)
  10296. */
  10297. scaleRatio: number;
  10298. /**
  10299. * Disposes of the gizmo
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * CustomMeshes are not supported by this gizmo
  10304. * @param mesh The mesh to replace the default mesh of the gizmo
  10305. */
  10306. setCustomMesh(mesh: Mesh): void;
  10307. }
  10308. }
  10309. declare module BABYLON {
  10310. /**
  10311. * Gizmo that enables scaling a mesh along 3 axis
  10312. */
  10313. class ScaleGizmo extends Gizmo {
  10314. /**
  10315. * Internal gizmo used for interactions on the x axis
  10316. */
  10317. xGizmo: AxisScaleGizmo;
  10318. /**
  10319. * Internal gizmo used for interactions on the y axis
  10320. */
  10321. yGizmo: AxisScaleGizmo;
  10322. /**
  10323. * Internal gizmo used for interactions on the z axis
  10324. */
  10325. zGizmo: AxisScaleGizmo;
  10326. /**
  10327. * @hidden
  10328. * Internal gizmo used to scale all axis equally
  10329. */
  10330. private _uniformGizmo;
  10331. attachedMesh: Nullable<AbstractMesh>;
  10332. /**
  10333. * Creates a ScaleGizmo
  10334. * @param gizmoLayer The utility layer the gizmo will be added to
  10335. */
  10336. constructor(gizmoLayer?: UtilityLayerRenderer);
  10337. updateGizmoRotationToMatchAttachedMesh: boolean;
  10338. /**
  10339. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10340. */
  10341. snapDistance: number;
  10342. /**
  10343. * Ratio for the scale of the gizmo (Default: 1)
  10344. */
  10345. scaleRatio: number;
  10346. /**
  10347. * Disposes of the gizmo
  10348. */
  10349. dispose(): void;
  10350. }
  10351. }
  10352. declare module BABYLON {
  10353. /**
  10354. * Represents the different options available during the creation of
  10355. * a Environment helper.
  10356. *
  10357. * This can control the default ground, skybox and image processing setup of your scene.
  10358. */
  10359. interface IEnvironmentHelperOptions {
  10360. /**
  10361. * Specifies wether or not to create a ground.
  10362. * True by default.
  10363. */
  10364. createGround: boolean;
  10365. /**
  10366. * Specifies the ground size.
  10367. * 15 by default.
  10368. */
  10369. groundSize: number;
  10370. /**
  10371. * The texture used on the ground for the main color.
  10372. * Comes from the BabylonJS CDN by default.
  10373. *
  10374. * Remarks: Can be either a texture or a url.
  10375. */
  10376. groundTexture: string | BaseTexture;
  10377. /**
  10378. * The color mixed in the ground texture by default.
  10379. * BabylonJS clearColor by default.
  10380. */
  10381. groundColor: Color3;
  10382. /**
  10383. * Specifies the ground opacity.
  10384. * 1 by default.
  10385. */
  10386. groundOpacity: number;
  10387. /**
  10388. * Enables the ground to receive shadows.
  10389. * True by default.
  10390. */
  10391. enableGroundShadow: boolean;
  10392. /**
  10393. * Helps preventing the shadow to be fully black on the ground.
  10394. * 0.5 by default.
  10395. */
  10396. groundShadowLevel: number;
  10397. /**
  10398. * Creates a mirror texture attach to the ground.
  10399. * false by default.
  10400. */
  10401. enableGroundMirror: boolean;
  10402. /**
  10403. * Specifies the ground mirror size ratio.
  10404. * 0.3 by default as the default kernel is 64.
  10405. */
  10406. groundMirrorSizeRatio: number;
  10407. /**
  10408. * Specifies the ground mirror blur kernel size.
  10409. * 64 by default.
  10410. */
  10411. groundMirrorBlurKernel: number;
  10412. /**
  10413. * Specifies the ground mirror visibility amount.
  10414. * 1 by default
  10415. */
  10416. groundMirrorAmount: number;
  10417. /**
  10418. * Specifies the ground mirror reflectance weight.
  10419. * This uses the standard weight of the background material to setup the fresnel effect
  10420. * of the mirror.
  10421. * 1 by default.
  10422. */
  10423. groundMirrorFresnelWeight: number;
  10424. /**
  10425. * Specifies the ground mirror Falloff distance.
  10426. * This can helps reducing the size of the reflection.
  10427. * 0 by Default.
  10428. */
  10429. groundMirrorFallOffDistance: number;
  10430. /**
  10431. * Specifies the ground mirror texture type.
  10432. * Unsigned Int by Default.
  10433. */
  10434. groundMirrorTextureType: number;
  10435. /**
  10436. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10437. * the shown objects.
  10438. */
  10439. groundYBias: number;
  10440. /**
  10441. * Specifies wether or not to create a skybox.
  10442. * True by default.
  10443. */
  10444. createSkybox: boolean;
  10445. /**
  10446. * Specifies the skybox size.
  10447. * 20 by default.
  10448. */
  10449. skyboxSize: number;
  10450. /**
  10451. * The texture used on the skybox for the main color.
  10452. * Comes from the BabylonJS CDN by default.
  10453. *
  10454. * Remarks: Can be either a texture or a url.
  10455. */
  10456. skyboxTexture: string | BaseTexture;
  10457. /**
  10458. * The color mixed in the skybox texture by default.
  10459. * BabylonJS clearColor by default.
  10460. */
  10461. skyboxColor: Color3;
  10462. /**
  10463. * The background rotation around the Y axis of the scene.
  10464. * This helps aligning the key lights of your scene with the background.
  10465. * 0 by default.
  10466. */
  10467. backgroundYRotation: number;
  10468. /**
  10469. * Compute automatically the size of the elements to best fit with the scene.
  10470. */
  10471. sizeAuto: boolean;
  10472. /**
  10473. * Default position of the rootMesh if autoSize is not true.
  10474. */
  10475. rootPosition: Vector3;
  10476. /**
  10477. * Sets up the image processing in the scene.
  10478. * true by default.
  10479. */
  10480. setupImageProcessing: boolean;
  10481. /**
  10482. * The texture used as your environment texture in the scene.
  10483. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10484. *
  10485. * Remarks: Can be either a texture or a url.
  10486. */
  10487. environmentTexture: string | BaseTexture;
  10488. /**
  10489. * The value of the exposure to apply to the scene.
  10490. * 0.6 by default if setupImageProcessing is true.
  10491. */
  10492. cameraExposure: number;
  10493. /**
  10494. * The value of the contrast to apply to the scene.
  10495. * 1.6 by default if setupImageProcessing is true.
  10496. */
  10497. cameraContrast: number;
  10498. /**
  10499. * Specifies wether or not tonemapping should be enabled in the scene.
  10500. * true by default if setupImageProcessing is true.
  10501. */
  10502. toneMappingEnabled: boolean;
  10503. }
  10504. /**
  10505. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10506. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10507. * It also helps with the default setup of your imageProcessing configuration.
  10508. */
  10509. class EnvironmentHelper {
  10510. /**
  10511. * Default ground texture URL.
  10512. */
  10513. private static _groundTextureCDNUrl;
  10514. /**
  10515. * Default skybox texture URL.
  10516. */
  10517. private static _skyboxTextureCDNUrl;
  10518. /**
  10519. * Default environment texture URL.
  10520. */
  10521. private static _environmentTextureCDNUrl;
  10522. /**
  10523. * Creates the default options for the helper.
  10524. */
  10525. private static _getDefaultOptions;
  10526. private _rootMesh;
  10527. /**
  10528. * Gets the root mesh created by the helper.
  10529. */
  10530. readonly rootMesh: Mesh;
  10531. private _skybox;
  10532. /**
  10533. * Gets the skybox created by the helper.
  10534. */
  10535. readonly skybox: Nullable<Mesh>;
  10536. private _skyboxTexture;
  10537. /**
  10538. * Gets the skybox texture created by the helper.
  10539. */
  10540. readonly skyboxTexture: Nullable<BaseTexture>;
  10541. private _skyboxMaterial;
  10542. /**
  10543. * Gets the skybox material created by the helper.
  10544. */
  10545. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10546. private _ground;
  10547. /**
  10548. * Gets the ground mesh created by the helper.
  10549. */
  10550. readonly ground: Nullable<Mesh>;
  10551. private _groundTexture;
  10552. /**
  10553. * Gets the ground texture created by the helper.
  10554. */
  10555. readonly groundTexture: Nullable<BaseTexture>;
  10556. private _groundMirror;
  10557. /**
  10558. * Gets the ground mirror created by the helper.
  10559. */
  10560. readonly groundMirror: Nullable<MirrorTexture>;
  10561. /**
  10562. * Gets the ground mirror render list to helps pushing the meshes
  10563. * you wish in the ground reflection.
  10564. */
  10565. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10566. private _groundMaterial;
  10567. /**
  10568. * Gets the ground material created by the helper.
  10569. */
  10570. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10571. /**
  10572. * Stores the creation options.
  10573. */
  10574. private readonly _scene;
  10575. private _options;
  10576. /**
  10577. * This observable will be notified with any error during the creation of the environment,
  10578. * mainly texture creation errors.
  10579. */
  10580. onErrorObservable: Observable<{
  10581. message?: string;
  10582. exception?: any;
  10583. }>;
  10584. /**
  10585. * constructor
  10586. * @param options
  10587. * @param scene The scene to add the material to
  10588. */
  10589. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10590. /**
  10591. * Updates the background according to the new options
  10592. * @param options
  10593. */
  10594. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10595. /**
  10596. * Sets the primary color of all the available elements.
  10597. * @param color the main color to affect to the ground and the background
  10598. */
  10599. setMainColor(color: Color3): void;
  10600. /**
  10601. * Setup the image processing according to the specified options.
  10602. */
  10603. private _setupImageProcessing;
  10604. /**
  10605. * Setup the environment texture according to the specified options.
  10606. */
  10607. private _setupEnvironmentTexture;
  10608. /**
  10609. * Setup the background according to the specified options.
  10610. */
  10611. private _setupBackground;
  10612. /**
  10613. * Get the scene sizes according to the setup.
  10614. */
  10615. private _getSceneSize;
  10616. /**
  10617. * Setup the ground according to the specified options.
  10618. */
  10619. private _setupGround;
  10620. /**
  10621. * Setup the ground material according to the specified options.
  10622. */
  10623. private _setupGroundMaterial;
  10624. /**
  10625. * Setup the ground diffuse texture according to the specified options.
  10626. */
  10627. private _setupGroundDiffuseTexture;
  10628. /**
  10629. * Setup the ground mirror texture according to the specified options.
  10630. */
  10631. private _setupGroundMirrorTexture;
  10632. /**
  10633. * Setup the ground to receive the mirror texture.
  10634. */
  10635. private _setupMirrorInGroundMaterial;
  10636. /**
  10637. * Setup the skybox according to the specified options.
  10638. */
  10639. private _setupSkybox;
  10640. /**
  10641. * Setup the skybox material according to the specified options.
  10642. */
  10643. private _setupSkyboxMaterial;
  10644. /**
  10645. * Setup the skybox reflection texture according to the specified options.
  10646. */
  10647. private _setupSkyboxReflectionTexture;
  10648. private _errorHandler;
  10649. /**
  10650. * Dispose all the elements created by the Helper.
  10651. */
  10652. dispose(): void;
  10653. }
  10654. }
  10655. declare module BABYLON {
  10656. /**
  10657. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10658. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10659. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10660. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10661. */
  10662. class PhotoDome extends TransformNode {
  10663. private _useDirectMapping;
  10664. /**
  10665. * The texture being displayed on the sphere
  10666. */
  10667. protected _photoTexture: Texture;
  10668. /**
  10669. * Gets or sets the texture being displayed on the sphere
  10670. */
  10671. photoTexture: Texture;
  10672. /**
  10673. * Observable raised when an error occured while loading the 360 image
  10674. */
  10675. onLoadErrorObservable: Observable<string>;
  10676. /**
  10677. * The skybox material
  10678. */
  10679. protected _material: BackgroundMaterial;
  10680. /**
  10681. * The surface used for the skybox
  10682. */
  10683. protected _mesh: Mesh;
  10684. /**
  10685. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10686. * Also see the options.resolution property.
  10687. */
  10688. fovMultiplier: number;
  10689. /**
  10690. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10691. * @param name Element's name, child elements will append suffixes for their own names.
  10692. * @param urlsOfPhoto defines the url of the photo to display
  10693. * @param options defines an object containing optional or exposed sub element properties
  10694. * @param onError defines a callback called when an error occured while loading the texture
  10695. */
  10696. constructor(name: string, urlOfPhoto: string, options: {
  10697. resolution?: number;
  10698. size?: number;
  10699. useDirectMapping?: boolean;
  10700. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10701. /**
  10702. * Releases resources associated with this node.
  10703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10705. */
  10706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. /**
  10711. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10712. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10713. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10714. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10715. */
  10716. class VideoDome extends TransformNode {
  10717. private _useDirectMapping;
  10718. /**
  10719. * The video texture being displayed on the sphere
  10720. */
  10721. protected _videoTexture: VideoTexture;
  10722. /**
  10723. * Gets the video texture being displayed on the sphere
  10724. */
  10725. readonly videoTexture: VideoTexture;
  10726. /**
  10727. * The skybox material
  10728. */
  10729. protected _material: BackgroundMaterial;
  10730. /**
  10731. * The surface used for the skybox
  10732. */
  10733. protected _mesh: Mesh;
  10734. /**
  10735. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10736. * Also see the options.resolution property.
  10737. */
  10738. fovMultiplier: number;
  10739. /**
  10740. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10741. * @param name Element's name, child elements will append suffixes for their own names.
  10742. * @param urlsOrVideo defines the url(s) or the video element to use
  10743. * @param options An object containing optional or exposed sub element properties
  10744. */
  10745. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10746. resolution?: number;
  10747. clickToPlay?: boolean;
  10748. autoPlay?: boolean;
  10749. loop?: boolean;
  10750. size?: number;
  10751. poster?: string;
  10752. useDirectMapping?: boolean;
  10753. }, scene: Scene);
  10754. /**
  10755. * Releases resources associated with this node.
  10756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10758. */
  10759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10760. }
  10761. }
  10762. declare module BABYLON {
  10763. /**
  10764. * This class can be used to get instrumentation data from a Babylon engine
  10765. */
  10766. class EngineInstrumentation implements IDisposable {
  10767. engine: Engine;
  10768. private _captureGPUFrameTime;
  10769. private _gpuFrameTimeToken;
  10770. private _gpuFrameTime;
  10771. private _captureShaderCompilationTime;
  10772. private _shaderCompilationTime;
  10773. private _onBeginFrameObserver;
  10774. private _onEndFrameObserver;
  10775. private _onBeforeShaderCompilationObserver;
  10776. private _onAfterShaderCompilationObserver;
  10777. /**
  10778. * Gets the perf counter used for GPU frame time
  10779. */
  10780. readonly gpuFrameTimeCounter: PerfCounter;
  10781. /**
  10782. * Gets the GPU frame time capture status
  10783. */
  10784. /**
  10785. * Enable or disable the GPU frame time capture
  10786. */
  10787. captureGPUFrameTime: boolean;
  10788. /**
  10789. * Gets the perf counter used for shader compilation time
  10790. */
  10791. readonly shaderCompilationTimeCounter: PerfCounter;
  10792. /**
  10793. * Gets the shader compilation time capture status
  10794. */
  10795. /**
  10796. * Enable or disable the shader compilation time capture
  10797. */
  10798. captureShaderCompilationTime: boolean;
  10799. constructor(engine: Engine);
  10800. dispose(): void;
  10801. }
  10802. }
  10803. declare module BABYLON {
  10804. /**
  10805. * This class can be used to get instrumentation data from a Babylon engine
  10806. */
  10807. class SceneInstrumentation implements IDisposable {
  10808. scene: Scene;
  10809. private _captureActiveMeshesEvaluationTime;
  10810. private _activeMeshesEvaluationTime;
  10811. private _captureRenderTargetsRenderTime;
  10812. private _renderTargetsRenderTime;
  10813. private _captureFrameTime;
  10814. private _frameTime;
  10815. private _captureRenderTime;
  10816. private _renderTime;
  10817. private _captureInterFrameTime;
  10818. private _interFrameTime;
  10819. private _captureParticlesRenderTime;
  10820. private _particlesRenderTime;
  10821. private _captureSpritesRenderTime;
  10822. private _spritesRenderTime;
  10823. private _capturePhysicsTime;
  10824. private _physicsTime;
  10825. private _captureAnimationsTime;
  10826. private _animationsTime;
  10827. private _captureCameraRenderTime;
  10828. private _cameraRenderTime;
  10829. private _onBeforeActiveMeshesEvaluationObserver;
  10830. private _onAfterActiveMeshesEvaluationObserver;
  10831. private _onBeforeRenderTargetsRenderObserver;
  10832. private _onAfterRenderTargetsRenderObserver;
  10833. private _onAfterRenderObserver;
  10834. private _onBeforeDrawPhaseObserver;
  10835. private _onAfterDrawPhaseObserver;
  10836. private _onBeforeAnimationsObserver;
  10837. private _onBeforeParticlesRenderingObserver;
  10838. private _onAfterParticlesRenderingObserver;
  10839. private _onBeforeSpritesRenderingObserver;
  10840. private _onAfterSpritesRenderingObserver;
  10841. private _onBeforePhysicsObserver;
  10842. private _onAfterPhysicsObserver;
  10843. private _onAfterAnimationsObserver;
  10844. private _onBeforeCameraRenderObserver;
  10845. private _onAfterCameraRenderObserver;
  10846. /**
  10847. * Gets the perf counter used for active meshes evaluation time
  10848. */
  10849. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10850. /**
  10851. * Gets the active meshes evaluation time capture status
  10852. */
  10853. /**
  10854. * Enable or disable the active meshes evaluation time capture
  10855. */
  10856. captureActiveMeshesEvaluationTime: boolean;
  10857. /**
  10858. * Gets the perf counter used for render targets render time
  10859. */
  10860. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10861. /**
  10862. * Gets the render targets render time capture status
  10863. */
  10864. /**
  10865. * Enable or disable the render targets render time capture
  10866. */
  10867. captureRenderTargetsRenderTime: boolean;
  10868. /**
  10869. * Gets the perf counter used for particles render time
  10870. */
  10871. readonly particlesRenderTimeCounter: PerfCounter;
  10872. /**
  10873. * Gets the particles render time capture status
  10874. */
  10875. /**
  10876. * Enable or disable the particles render time capture
  10877. */
  10878. captureParticlesRenderTime: boolean;
  10879. /**
  10880. * Gets the perf counter used for sprites render time
  10881. */
  10882. readonly spritesRenderTimeCounter: PerfCounter;
  10883. /**
  10884. * Gets the sprites render time capture status
  10885. */
  10886. /**
  10887. * Enable or disable the sprites render time capture
  10888. */
  10889. captureSpritesRenderTime: boolean;
  10890. /**
  10891. * Gets the perf counter used for physics time
  10892. */
  10893. readonly physicsTimeCounter: PerfCounter;
  10894. /**
  10895. * Gets the physics time capture status
  10896. */
  10897. /**
  10898. * Enable or disable the physics time capture
  10899. */
  10900. capturePhysicsTime: boolean;
  10901. /**
  10902. * Gets the perf counter used for animations time
  10903. */
  10904. readonly animationsTimeCounter: PerfCounter;
  10905. /**
  10906. * Gets the animations time capture status
  10907. */
  10908. /**
  10909. * Enable or disable the animations time capture
  10910. */
  10911. captureAnimationsTime: boolean;
  10912. /**
  10913. * Gets the perf counter used for frame time capture
  10914. */
  10915. readonly frameTimeCounter: PerfCounter;
  10916. /**
  10917. * Gets the frame time capture status
  10918. */
  10919. /**
  10920. * Enable or disable the frame time capture
  10921. */
  10922. captureFrameTime: boolean;
  10923. /**
  10924. * Gets the perf counter used for inter-frames time capture
  10925. */
  10926. readonly interFrameTimeCounter: PerfCounter;
  10927. /**
  10928. * Gets the inter-frames time capture status
  10929. */
  10930. /**
  10931. * Enable or disable the inter-frames time capture
  10932. */
  10933. captureInterFrameTime: boolean;
  10934. /**
  10935. * Gets the perf counter used for render time capture
  10936. */
  10937. readonly renderTimeCounter: PerfCounter;
  10938. /**
  10939. * Gets the render time capture status
  10940. */
  10941. /**
  10942. * Enable or disable the render time capture
  10943. */
  10944. captureRenderTime: boolean;
  10945. /**
  10946. * Gets the perf counter used for camera render time capture
  10947. */
  10948. readonly cameraRenderTimeCounter: PerfCounter;
  10949. /**
  10950. * Gets the camera render time capture status
  10951. */
  10952. /**
  10953. * Enable or disable the camera render time capture
  10954. */
  10955. captureCameraRenderTime: boolean;
  10956. /**
  10957. * Gets the perf counter used for draw calls
  10958. */
  10959. readonly drawCallsCounter: PerfCounter;
  10960. /**
  10961. * Gets the perf counter used for texture collisions
  10962. */
  10963. readonly textureCollisionsCounter: PerfCounter;
  10964. constructor(scene: Scene);
  10965. dispose(): void;
  10966. }
  10967. }
  10968. declare module BABYLON {
  10969. /**
  10970. * @hidden
  10971. **/
  10972. class _TimeToken {
  10973. _startTimeQuery: Nullable<WebGLQuery>;
  10974. _endTimeQuery: Nullable<WebGLQuery>;
  10975. _timeElapsedQuery: Nullable<WebGLQuery>;
  10976. _timeElapsedQueryEnded: boolean;
  10977. }
  10978. }
  10979. declare module BABYLON {
  10980. /**
  10981. * Effect layer options. This helps customizing the behaviour
  10982. * of the effect layer.
  10983. */
  10984. interface IEffectLayerOptions {
  10985. /**
  10986. * Multiplication factor apply to the canvas size to compute the render target size
  10987. * used to generated the objects (the smaller the faster).
  10988. */
  10989. mainTextureRatio: number;
  10990. /**
  10991. * Enforces a fixed size texture to ensure effect stability across devices.
  10992. */
  10993. mainTextureFixedSize?: number;
  10994. /**
  10995. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10996. */
  10997. alphaBlendingMode: number;
  10998. /**
  10999. * The camera attached to the layer.
  11000. */
  11001. camera: Nullable<Camera>;
  11002. /**
  11003. * The rendering group to draw the layer in.
  11004. */
  11005. renderingGroupId: number;
  11006. }
  11007. /**
  11008. * The effect layer Helps adding post process effect blended with the main pass.
  11009. *
  11010. * This can be for instance use to generate glow or higlight effects on the scene.
  11011. *
  11012. * The effect layer class can not be used directly and is intented to inherited from to be
  11013. * customized per effects.
  11014. */
  11015. abstract class EffectLayer {
  11016. private _vertexBuffers;
  11017. private _indexBuffer;
  11018. private _cachedDefines;
  11019. private _effectLayerMapGenerationEffect;
  11020. private _effectLayerOptions;
  11021. private _mergeEffect;
  11022. protected _scene: Scene;
  11023. protected _engine: Engine;
  11024. protected _maxSize: number;
  11025. protected _mainTextureDesiredSize: ISize;
  11026. protected _mainTexture: RenderTargetTexture;
  11027. protected _shouldRender: boolean;
  11028. protected _postProcesses: PostProcess[];
  11029. protected _textures: BaseTexture[];
  11030. protected _emissiveTextureAndColor: {
  11031. texture: Nullable<BaseTexture>;
  11032. color: Color4;
  11033. };
  11034. /**
  11035. * The name of the layer
  11036. */
  11037. name: string;
  11038. /**
  11039. * The clear color of the texture used to generate the glow map.
  11040. */
  11041. neutralColor: Color4;
  11042. /**
  11043. * Specifies wether the highlight layer is enabled or not.
  11044. */
  11045. isEnabled: boolean;
  11046. /**
  11047. * Gets the camera attached to the layer.
  11048. */
  11049. readonly camera: Nullable<Camera>;
  11050. /**
  11051. * Gets the rendering group id the layer should render in.
  11052. */
  11053. readonly renderingGroupId: number;
  11054. /**
  11055. * An event triggered when the effect layer has been disposed.
  11056. */
  11057. onDisposeObservable: Observable<EffectLayer>;
  11058. /**
  11059. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11060. */
  11061. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11062. /**
  11063. * An event triggered when the generated texture is being merged in the scene.
  11064. */
  11065. onBeforeComposeObservable: Observable<EffectLayer>;
  11066. /**
  11067. * An event triggered when the generated texture has been merged in the scene.
  11068. */
  11069. onAfterComposeObservable: Observable<EffectLayer>;
  11070. /**
  11071. * An event triggered when the efffect layer changes its size.
  11072. */
  11073. onSizeChangedObservable: Observable<EffectLayer>;
  11074. /**
  11075. * Instantiates a new effect Layer and references it in the scene.
  11076. * @param name The name of the layer
  11077. * @param scene The scene to use the layer in
  11078. */
  11079. constructor(
  11080. /** The Friendly of the effect in the scene */
  11081. name: string, scene: Scene);
  11082. /**
  11083. * Get the effect name of the layer.
  11084. * @return The effect name
  11085. */
  11086. abstract getEffectName(): string;
  11087. /**
  11088. * Checks for the readiness of the element composing the layer.
  11089. * @param subMesh the mesh to check for
  11090. * @param useInstances specify wether or not to use instances to render the mesh
  11091. * @return true if ready otherwise, false
  11092. */
  11093. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11094. /**
  11095. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11096. * @returns true if the effect requires stencil during the main canvas render pass.
  11097. */
  11098. abstract needStencil(): boolean;
  11099. /**
  11100. * Create the merge effect. This is the shader use to blit the information back
  11101. * to the main canvas at the end of the scene rendering.
  11102. * @returns The effect containing the shader used to merge the effect on the main canvas
  11103. */
  11104. protected abstract _createMergeEffect(): Effect;
  11105. /**
  11106. * Creates the render target textures and post processes used in the effect layer.
  11107. */
  11108. protected abstract _createTextureAndPostProcesses(): void;
  11109. /**
  11110. * Implementation specific of rendering the generating effect on the main canvas.
  11111. * @param effect The effect used to render through
  11112. */
  11113. protected abstract _internalRender(effect: Effect): void;
  11114. /**
  11115. * Sets the required values for both the emissive texture and and the main color.
  11116. */
  11117. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11118. /**
  11119. * Free any resources and references associated to a mesh.
  11120. * Internal use
  11121. * @param mesh The mesh to free.
  11122. */
  11123. abstract _disposeMesh(mesh: Mesh): void;
  11124. /**
  11125. * Serializes this layer (Glow or Highlight for example)
  11126. * @returns a serialized layer object
  11127. */
  11128. abstract serialize?(): any;
  11129. /**
  11130. * Initializes the effect layer with the required options.
  11131. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11132. */
  11133. protected _init(options: Partial<IEffectLayerOptions>): void;
  11134. /**
  11135. * Generates the index buffer of the full screen quad blending to the main canvas.
  11136. */
  11137. private _generateIndexBuffer;
  11138. /**
  11139. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11140. */
  11141. private _genrateVertexBuffer;
  11142. /**
  11143. * Sets the main texture desired size which is the closest power of two
  11144. * of the engine canvas size.
  11145. */
  11146. private _setMainTextureSize;
  11147. /**
  11148. * Creates the main texture for the effect layer.
  11149. */
  11150. protected _createMainTexture(): void;
  11151. /**
  11152. * Checks for the readiness of the element composing the layer.
  11153. * @param subMesh the mesh to check for
  11154. * @param useInstances specify wether or not to use instances to render the mesh
  11155. * @param emissiveTexture the associated emissive texture used to generate the glow
  11156. * @return true if ready otherwise, false
  11157. */
  11158. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11159. /**
  11160. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11161. */
  11162. render(): void;
  11163. /**
  11164. * Determine if a given mesh will be used in the current effect.
  11165. * @param mesh mesh to test
  11166. * @returns true if the mesh will be used
  11167. */
  11168. hasMesh(mesh: AbstractMesh): boolean;
  11169. /**
  11170. * Returns true if the layer contains information to display, otherwise false.
  11171. * @returns true if the glow layer should be rendered
  11172. */
  11173. shouldRender(): boolean;
  11174. /**
  11175. * Returns true if the mesh should render, otherwise false.
  11176. * @param mesh The mesh to render
  11177. * @returns true if it should render otherwise false
  11178. */
  11179. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11180. /**
  11181. * Returns true if the mesh should render, otherwise false.
  11182. * @param mesh The mesh to render
  11183. * @returns true if it should render otherwise false
  11184. */
  11185. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11186. /**
  11187. * Renders the submesh passed in parameter to the generation map.
  11188. */
  11189. protected _renderSubMesh(subMesh: SubMesh): void;
  11190. /**
  11191. * Rebuild the required buffers.
  11192. * @hidden Internal use only.
  11193. */
  11194. _rebuild(): void;
  11195. /**
  11196. * Dispose only the render target textures and post process.
  11197. */
  11198. private _disposeTextureAndPostProcesses;
  11199. /**
  11200. * Dispose the highlight layer and free resources.
  11201. */
  11202. dispose(): void;
  11203. /**
  11204. * Gets the class name of the effect layer
  11205. * @returns the string with the class name of the effect layer
  11206. */
  11207. getClassName(): string;
  11208. /**
  11209. * Creates an effect layer from parsed effect layer data
  11210. * @param parsedEffectLayer defines effect layer data
  11211. * @param scene defines the current scene
  11212. * @param rootUrl defines the root URL containing the effect layer information
  11213. * @returns a parsed effect Layer
  11214. */
  11215. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11216. }
  11217. }
  11218. declare module BABYLON {
  11219. interface AbstractScene {
  11220. /**
  11221. * The list of effect layers (highlights/glow) added to the scene
  11222. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11223. * @see http://doc.babylonjs.com/how_to/glow_layer
  11224. */
  11225. effectLayers: Array<EffectLayer>;
  11226. /**
  11227. * Removes the given effect layer from this scene.
  11228. * @param toRemove defines the effect layer to remove
  11229. * @returns the index of the removed effect layer
  11230. */
  11231. removeEffectLayer(toRemove: EffectLayer): number;
  11232. /**
  11233. * Adds the given effect layer to this scene
  11234. * @param newEffectLayer defines the effect layer to add
  11235. */
  11236. addEffectLayer(newEffectLayer: EffectLayer): void;
  11237. }
  11238. /**
  11239. * Defines the layer scene component responsible to manage any effect layers
  11240. * in a given scene.
  11241. */
  11242. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11243. /**
  11244. * The component name helpfull to identify the component in the list of scene components.
  11245. */
  11246. readonly name: string;
  11247. /**
  11248. * The scene the component belongs to.
  11249. */
  11250. scene: Scene;
  11251. private _engine;
  11252. private _renderEffects;
  11253. private _needStencil;
  11254. private _previousStencilState;
  11255. /**
  11256. * Creates a new instance of the component for the given scene
  11257. * @param scene Defines the scene to register the component in
  11258. */
  11259. constructor(scene: Scene);
  11260. /**
  11261. * Registers the component in a given scene
  11262. */
  11263. register(): void;
  11264. /**
  11265. * Rebuilds the elements related to this component in case of
  11266. * context lost for instance.
  11267. */
  11268. rebuild(): void;
  11269. /**
  11270. * Serializes the component data to the specified json object
  11271. * @param serializationObject The object to serialize to
  11272. */
  11273. serialize(serializationObject: any): void;
  11274. /**
  11275. * Adds all the element from the container to the scene
  11276. * @param container the container holding the elements
  11277. */
  11278. addFromContainer(container: AbstractScene): void;
  11279. /**
  11280. * Removes all the elements in the container from the scene
  11281. * @param container contains the elements to remove
  11282. */
  11283. removeFromContainer(container: AbstractScene): void;
  11284. /**
  11285. * Disposes the component and the associated ressources.
  11286. */
  11287. dispose(): void;
  11288. private _isReadyForMesh;
  11289. private _renderMainTexture;
  11290. private _setStencil;
  11291. private _setStencilBack;
  11292. private _draw;
  11293. private _drawCamera;
  11294. private _drawRenderingGroup;
  11295. }
  11296. }
  11297. declare module BABYLON {
  11298. interface AbstractScene {
  11299. /**
  11300. * Return a the first highlight layer of the scene with a given name.
  11301. * @param name The name of the highlight layer to look for.
  11302. * @return The highlight layer if found otherwise null.
  11303. */
  11304. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11305. }
  11306. /**
  11307. * Glow layer options. This helps customizing the behaviour
  11308. * of the glow layer.
  11309. */
  11310. interface IGlowLayerOptions {
  11311. /**
  11312. * Multiplication factor apply to the canvas size to compute the render target size
  11313. * used to generated the glowing objects (the smaller the faster).
  11314. */
  11315. mainTextureRatio: number;
  11316. /**
  11317. * Enforces a fixed size texture to ensure resize independant blur.
  11318. */
  11319. mainTextureFixedSize?: number;
  11320. /**
  11321. * How big is the kernel of the blur texture.
  11322. */
  11323. blurKernelSize: number;
  11324. /**
  11325. * The camera attached to the layer.
  11326. */
  11327. camera: Nullable<Camera>;
  11328. /**
  11329. * Enable MSAA by chosing the number of samples.
  11330. */
  11331. mainTextureSamples?: number;
  11332. /**
  11333. * The rendering group to draw the layer in.
  11334. */
  11335. renderingGroupId: number;
  11336. }
  11337. /**
  11338. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11339. *
  11340. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11341. * glowy meshes to your scene.
  11342. *
  11343. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11344. */
  11345. class GlowLayer extends EffectLayer {
  11346. /**
  11347. * Effect Name of the layer.
  11348. */
  11349. static readonly EffectName: string;
  11350. /**
  11351. * The default blur kernel size used for the glow.
  11352. */
  11353. static DefaultBlurKernelSize: number;
  11354. /**
  11355. * The default texture size ratio used for the glow.
  11356. */
  11357. static DefaultTextureRatio: number;
  11358. /**
  11359. * Sets the kernel size of the blur.
  11360. */
  11361. /**
  11362. * Gets the kernel size of the blur.
  11363. */
  11364. blurKernelSize: number;
  11365. /**
  11366. * Sets the glow intensity.
  11367. */
  11368. /**
  11369. * Gets the glow intensity.
  11370. */
  11371. intensity: number;
  11372. private _options;
  11373. private _intensity;
  11374. private _horizontalBlurPostprocess1;
  11375. private _verticalBlurPostprocess1;
  11376. private _horizontalBlurPostprocess2;
  11377. private _verticalBlurPostprocess2;
  11378. private _blurTexture1;
  11379. private _blurTexture2;
  11380. private _postProcesses1;
  11381. private _postProcesses2;
  11382. private _includedOnlyMeshes;
  11383. private _excludedMeshes;
  11384. /**
  11385. * Callback used to let the user override the color selection on a per mesh basis
  11386. */
  11387. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11388. /**
  11389. * Callback used to let the user override the texture selection on a per mesh basis
  11390. */
  11391. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11392. /**
  11393. * Instantiates a new glow Layer and references it to the scene.
  11394. * @param name The name of the layer
  11395. * @param scene The scene to use the layer in
  11396. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11397. */
  11398. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11399. /**
  11400. * Get the effect name of the layer.
  11401. * @return The effect name
  11402. */
  11403. getEffectName(): string;
  11404. /**
  11405. * Create the merge effect. This is the shader use to blit the information back
  11406. * to the main canvas at the end of the scene rendering.
  11407. */
  11408. protected _createMergeEffect(): Effect;
  11409. /**
  11410. * Creates the render target textures and post processes used in the glow layer.
  11411. */
  11412. protected _createTextureAndPostProcesses(): void;
  11413. /**
  11414. * Checks for the readiness of the element composing the layer.
  11415. * @param subMesh the mesh to check for
  11416. * @param useInstances specify wether or not to use instances to render the mesh
  11417. * @param emissiveTexture the associated emissive texture used to generate the glow
  11418. * @return true if ready otherwise, false
  11419. */
  11420. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11421. /**
  11422. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11423. */
  11424. needStencil(): boolean;
  11425. /**
  11426. * Implementation specific of rendering the generating effect on the main canvas.
  11427. * @param effect The effect used to render through
  11428. */
  11429. protected _internalRender(effect: Effect): void;
  11430. /**
  11431. * Sets the required values for both the emissive texture and and the main color.
  11432. */
  11433. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11434. /**
  11435. * Returns true if the mesh should render, otherwise false.
  11436. * @param mesh The mesh to render
  11437. * @returns true if it should render otherwise false
  11438. */
  11439. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11440. /**
  11441. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11442. * @param mesh The mesh to exclude from the glow layer
  11443. */
  11444. addExcludedMesh(mesh: Mesh): void;
  11445. /**
  11446. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11447. * @param mesh The mesh to remove
  11448. */
  11449. removeExcludedMesh(mesh: Mesh): void;
  11450. /**
  11451. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11452. * @param mesh The mesh to include in the glow layer
  11453. */
  11454. addIncludedOnlyMesh(mesh: Mesh): void;
  11455. /**
  11456. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11457. * @param mesh The mesh to remove
  11458. */
  11459. removeIncludedOnlyMesh(mesh: Mesh): void;
  11460. /**
  11461. * Determine if a given mesh will be used in the glow layer
  11462. * @param mesh The mesh to test
  11463. * @returns true if the mesh will be highlighted by the current glow layer
  11464. */
  11465. hasMesh(mesh: AbstractMesh): boolean;
  11466. /**
  11467. * Free any resources and references associated to a mesh.
  11468. * Internal use
  11469. * @param mesh The mesh to free.
  11470. * @hidden
  11471. */
  11472. _disposeMesh(mesh: Mesh): void;
  11473. /**
  11474. * Gets the class name of the effect layer
  11475. * @returns the string with the class name of the effect layer
  11476. */
  11477. getClassName(): string;
  11478. /**
  11479. * Serializes this glow layer
  11480. * @returns a serialized glow layer object
  11481. */
  11482. serialize(): any;
  11483. /**
  11484. * Creates a Glow Layer from parsed glow layer data
  11485. * @param parsedGlowLayer defines glow layer data
  11486. * @param scene defines the current scene
  11487. * @param rootUrl defines the root URL containing the glow layer information
  11488. * @returns a parsed Glow Layer
  11489. */
  11490. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11491. }
  11492. }
  11493. declare module BABYLON {
  11494. interface AbstractScene {
  11495. /**
  11496. * Return a the first highlight layer of the scene with a given name.
  11497. * @param name The name of the highlight layer to look for.
  11498. * @return The highlight layer if found otherwise null.
  11499. */
  11500. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11501. }
  11502. /**
  11503. * Highlight layer options. This helps customizing the behaviour
  11504. * of the highlight layer.
  11505. */
  11506. interface IHighlightLayerOptions {
  11507. /**
  11508. * Multiplication factor apply to the canvas size to compute the render target size
  11509. * used to generated the glowing objects (the smaller the faster).
  11510. */
  11511. mainTextureRatio: number;
  11512. /**
  11513. * Enforces a fixed size texture to ensure resize independant blur.
  11514. */
  11515. mainTextureFixedSize?: number;
  11516. /**
  11517. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11518. * of the picture to blur (the smaller the faster).
  11519. */
  11520. blurTextureSizeRatio: number;
  11521. /**
  11522. * How big in texel of the blur texture is the vertical blur.
  11523. */
  11524. blurVerticalSize: number;
  11525. /**
  11526. * How big in texel of the blur texture is the horizontal blur.
  11527. */
  11528. blurHorizontalSize: number;
  11529. /**
  11530. * Alpha blending mode used to apply the blur. Default is combine.
  11531. */
  11532. alphaBlendingMode: number;
  11533. /**
  11534. * The camera attached to the layer.
  11535. */
  11536. camera: Nullable<Camera>;
  11537. /**
  11538. * Should we display highlight as a solid stroke?
  11539. */
  11540. isStroke?: boolean;
  11541. /**
  11542. * The rendering group to draw the layer in.
  11543. */
  11544. renderingGroupId: number;
  11545. }
  11546. /**
  11547. * The highlight layer Helps adding a glow effect around a mesh.
  11548. *
  11549. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11550. * glowy meshes to your scene.
  11551. *
  11552. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11553. */
  11554. class HighlightLayer extends EffectLayer {
  11555. name: string;
  11556. /**
  11557. * Effect Name of the highlight layer.
  11558. */
  11559. static readonly EffectName: string;
  11560. /**
  11561. * The neutral color used during the preparation of the glow effect.
  11562. * This is black by default as the blend operation is a blend operation.
  11563. */
  11564. static NeutralColor: Color4;
  11565. /**
  11566. * Stencil value used for glowing meshes.
  11567. */
  11568. static GlowingMeshStencilReference: number;
  11569. /**
  11570. * Stencil value used for the other meshes in the scene.
  11571. */
  11572. static NormalMeshStencilReference: number;
  11573. /**
  11574. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11575. */
  11576. innerGlow: boolean;
  11577. /**
  11578. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11579. */
  11580. outerGlow: boolean;
  11581. /**
  11582. * Specifies the horizontal size of the blur.
  11583. */
  11584. /**
  11585. * Gets the horizontal size of the blur.
  11586. */
  11587. blurHorizontalSize: number;
  11588. /**
  11589. * Specifies the vertical size of the blur.
  11590. */
  11591. /**
  11592. * Gets the vertical size of the blur.
  11593. */
  11594. blurVerticalSize: number;
  11595. /**
  11596. * An event triggered when the highlight layer is being blurred.
  11597. */
  11598. onBeforeBlurObservable: Observable<HighlightLayer>;
  11599. /**
  11600. * An event triggered when the highlight layer has been blurred.
  11601. */
  11602. onAfterBlurObservable: Observable<HighlightLayer>;
  11603. private _instanceGlowingMeshStencilReference;
  11604. private _options;
  11605. private _downSamplePostprocess;
  11606. private _horizontalBlurPostprocess;
  11607. private _verticalBlurPostprocess;
  11608. private _blurTexture;
  11609. private _meshes;
  11610. private _excludedMeshes;
  11611. /**
  11612. * Instantiates a new highlight Layer and references it to the scene..
  11613. * @param name The name of the layer
  11614. * @param scene The scene to use the layer in
  11615. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11616. */
  11617. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11618. /**
  11619. * Get the effect name of the layer.
  11620. * @return The effect name
  11621. */
  11622. getEffectName(): string;
  11623. /**
  11624. * Create the merge effect. This is the shader use to blit the information back
  11625. * to the main canvas at the end of the scene rendering.
  11626. */
  11627. protected _createMergeEffect(): Effect;
  11628. /**
  11629. * Creates the render target textures and post processes used in the highlight layer.
  11630. */
  11631. protected _createTextureAndPostProcesses(): void;
  11632. /**
  11633. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11634. */
  11635. needStencil(): boolean;
  11636. /**
  11637. * Checks for the readiness of the element composing the layer.
  11638. * @param subMesh the mesh to check for
  11639. * @param useInstances specify wether or not to use instances to render the mesh
  11640. * @param emissiveTexture the associated emissive texture used to generate the glow
  11641. * @return true if ready otherwise, false
  11642. */
  11643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11644. /**
  11645. * Implementation specific of rendering the generating effect on the main canvas.
  11646. * @param effect The effect used to render through
  11647. */
  11648. protected _internalRender(effect: Effect): void;
  11649. /**
  11650. * Returns true if the layer contains information to display, otherwise false.
  11651. */
  11652. shouldRender(): boolean;
  11653. /**
  11654. * Returns true if the mesh should render, otherwise false.
  11655. * @param mesh The mesh to render
  11656. * @returns true if it should render otherwise false
  11657. */
  11658. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11659. /**
  11660. * Sets the required values for both the emissive texture and and the main color.
  11661. */
  11662. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11663. /**
  11664. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11665. * @param mesh The mesh to exclude from the highlight layer
  11666. */
  11667. addExcludedMesh(mesh: Mesh): void;
  11668. /**
  11669. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11670. * @param mesh The mesh to highlight
  11671. */
  11672. removeExcludedMesh(mesh: Mesh): void;
  11673. /**
  11674. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11675. * @param mesh mesh to test
  11676. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11677. */
  11678. hasMesh(mesh: AbstractMesh): boolean;
  11679. /**
  11680. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11681. * @param mesh The mesh to highlight
  11682. * @param color The color of the highlight
  11683. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11684. */
  11685. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11686. /**
  11687. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11688. * @param mesh The mesh to highlight
  11689. */
  11690. removeMesh(mesh: Mesh): void;
  11691. /**
  11692. * Force the stencil to the normal expected value for none glowing parts
  11693. */
  11694. private _defaultStencilReference;
  11695. /**
  11696. * Free any resources and references associated to a mesh.
  11697. * Internal use
  11698. * @param mesh The mesh to free.
  11699. * @hidden
  11700. */
  11701. _disposeMesh(mesh: Mesh): void;
  11702. /**
  11703. * Dispose the highlight layer and free resources.
  11704. */
  11705. dispose(): void;
  11706. /**
  11707. * Gets the class name of the effect layer
  11708. * @returns the string with the class name of the effect layer
  11709. */
  11710. getClassName(): string;
  11711. /**
  11712. * Serializes this Highlight layer
  11713. * @returns a serialized Highlight layer object
  11714. */
  11715. serialize(): any;
  11716. /**
  11717. * Creates a Highlight layer from parsed Highlight layer data
  11718. * @param parsedHightlightLayer defines the Highlight layer data
  11719. * @param scene defines the current scene
  11720. * @param rootUrl defines the root URL containing the Highlight layer information
  11721. * @returns a parsed Highlight layer
  11722. */
  11723. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11724. }
  11725. }
  11726. declare module BABYLON {
  11727. class Layer {
  11728. name: string;
  11729. texture: Nullable<Texture>;
  11730. isBackground: boolean;
  11731. color: Color4;
  11732. scale: Vector2;
  11733. offset: Vector2;
  11734. alphaBlendingMode: number;
  11735. alphaTest: boolean;
  11736. layerMask: number;
  11737. private _scene;
  11738. private _vertexBuffers;
  11739. private _indexBuffer;
  11740. private _effect;
  11741. private _alphaTestEffect;
  11742. /**
  11743. * An event triggered when the layer is disposed.
  11744. */
  11745. onDisposeObservable: Observable<Layer>;
  11746. private _onDisposeObserver;
  11747. onDispose: () => void;
  11748. /**
  11749. * An event triggered before rendering the scene
  11750. */
  11751. onBeforeRenderObservable: Observable<Layer>;
  11752. private _onBeforeRenderObserver;
  11753. onBeforeRender: () => void;
  11754. /**
  11755. * An event triggered after rendering the scene
  11756. */
  11757. onAfterRenderObservable: Observable<Layer>;
  11758. private _onAfterRenderObserver;
  11759. onAfterRender: () => void;
  11760. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11761. private _createIndexBuffer;
  11762. /** @hidden */
  11763. _rebuild(): void;
  11764. render(): void;
  11765. dispose(): void;
  11766. }
  11767. }
  11768. declare module BABYLON {
  11769. interface AbstractScene {
  11770. /**
  11771. * The list of layers (background and foreground) of the scene
  11772. */
  11773. layers: Array<Layer>;
  11774. }
  11775. /**
  11776. * Defines the layer scene component responsible to manage any layers
  11777. * in a given scene.
  11778. */
  11779. class LayerSceneComponent implements ISceneComponent {
  11780. /**
  11781. * The component name helpfull to identify the component in the list of scene components.
  11782. */
  11783. readonly name: string;
  11784. /**
  11785. * The scene the component belongs to.
  11786. */
  11787. scene: Scene;
  11788. private _engine;
  11789. /**
  11790. * Creates a new instance of the component for the given scene
  11791. * @param scene Defines the scene to register the component in
  11792. */
  11793. constructor(scene: Scene);
  11794. /**
  11795. * Registers the component in a given scene
  11796. */
  11797. register(): void;
  11798. /**
  11799. * Rebuilds the elements related to this component in case of
  11800. * context lost for instance.
  11801. */
  11802. rebuild(): void;
  11803. /**
  11804. * Disposes the component and the associated ressources.
  11805. */
  11806. dispose(): void;
  11807. private _draw;
  11808. private _drawBackground;
  11809. private _drawForeground;
  11810. }
  11811. }
  11812. declare module BABYLON {
  11813. class LensFlare {
  11814. size: number;
  11815. position: number;
  11816. color: Color3;
  11817. texture: Nullable<Texture>;
  11818. alphaMode: number;
  11819. private _system;
  11820. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11821. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11822. dispose(): void;
  11823. }
  11824. }
  11825. declare module BABYLON {
  11826. class LensFlareSystem {
  11827. name: string;
  11828. lensFlares: LensFlare[];
  11829. borderLimit: number;
  11830. viewportBorder: number;
  11831. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11832. layerMask: number;
  11833. id: string;
  11834. private _scene;
  11835. private _emitter;
  11836. private _vertexBuffers;
  11837. private _indexBuffer;
  11838. private _effect;
  11839. private _positionX;
  11840. private _positionY;
  11841. private _isEnabled;
  11842. constructor(name: string, emitter: any, scene: Scene);
  11843. isEnabled: boolean;
  11844. getScene(): Scene;
  11845. getEmitter(): any;
  11846. setEmitter(newEmitter: any): void;
  11847. getEmitterPosition(): Vector3;
  11848. computeEffectivePosition(globalViewport: Viewport): boolean;
  11849. /** @hidden */
  11850. _isVisible(): boolean;
  11851. render(): boolean;
  11852. dispose(): void;
  11853. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11854. serialize(): any;
  11855. }
  11856. }
  11857. declare module BABYLON {
  11858. interface AbstractScene {
  11859. /**
  11860. * The list of lens flare system added to the scene
  11861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11862. */
  11863. lensFlareSystems: Array<LensFlareSystem>;
  11864. /**
  11865. * Removes the given lens flare system from this scene.
  11866. * @param toRemove The lens flare system to remove
  11867. * @returns The index of the removed lens flare system
  11868. */
  11869. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11870. /**
  11871. * Adds the given lens flare system to this scene
  11872. * @param newLensFlareSystem The lens flare system to add
  11873. */
  11874. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11875. /**
  11876. * Gets a lens flare system using its name
  11877. * @param name defines the name to look for
  11878. * @returns the lens flare system or null if not found
  11879. */
  11880. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11881. /**
  11882. * Gets a lens flare system using its id
  11883. * @param id defines the id to look for
  11884. * @returns the lens flare system or null if not found
  11885. */
  11886. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11887. }
  11888. /**
  11889. * Defines the lens flare scene component responsible to manage any lens flares
  11890. * in a given scene.
  11891. */
  11892. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11893. /**
  11894. * The component name helpfull to identify the component in the list of scene components.
  11895. */
  11896. readonly name: string;
  11897. /**
  11898. * The scene the component belongs to.
  11899. */
  11900. scene: Scene;
  11901. /**
  11902. * Creates a new instance of the component for the given scene
  11903. * @param scene Defines the scene to register the component in
  11904. */
  11905. constructor(scene: Scene);
  11906. /**
  11907. * Registers the component in a given scene
  11908. */
  11909. register(): void;
  11910. /**
  11911. * Rebuilds the elements related to this component in case of
  11912. * context lost for instance.
  11913. */
  11914. rebuild(): void;
  11915. /**
  11916. * Adds all the element from the container to the scene
  11917. * @param container the container holding the elements
  11918. */
  11919. addFromContainer(container: AbstractScene): void;
  11920. /**
  11921. * Removes all the elements in the container from the scene
  11922. * @param container contains the elements to remove
  11923. */
  11924. removeFromContainer(container: AbstractScene): void;
  11925. /**
  11926. * Serializes the component data to the specified json object
  11927. * @param serializationObject The object to serialize to
  11928. */
  11929. serialize(serializationObject: any): void;
  11930. /**
  11931. * Disposes the component and the associated ressources.
  11932. */
  11933. dispose(): void;
  11934. private _draw;
  11935. }
  11936. }
  11937. declare module BABYLON {
  11938. /**
  11939. * A directional light is defined by a direction (what a surprise!).
  11940. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11941. * 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.
  11942. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11943. */
  11944. class DirectionalLight extends ShadowLight {
  11945. private _shadowFrustumSize;
  11946. /**
  11947. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11948. */
  11949. /**
  11950. * Specifies a fix frustum size for the shadow generation.
  11951. */
  11952. shadowFrustumSize: number;
  11953. private _shadowOrthoScale;
  11954. /**
  11955. * Gets the shadow projection scale against the optimal computed one.
  11956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11958. */
  11959. /**
  11960. * Sets the shadow projection scale against the optimal computed one.
  11961. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11962. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11963. */
  11964. shadowOrthoScale: number;
  11965. /**
  11966. * Automatically compute the projection matrix to best fit (including all the casters)
  11967. * on each frame.
  11968. */
  11969. autoUpdateExtends: boolean;
  11970. private _orthoLeft;
  11971. private _orthoRight;
  11972. private _orthoTop;
  11973. private _orthoBottom;
  11974. /**
  11975. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11976. * The directional light is emitted from everywhere in the given direction.
  11977. * It can cast shawdows.
  11978. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11979. * @param name The friendly name of the light
  11980. * @param direction The direction of the light
  11981. * @param scene The scene the light belongs to
  11982. */
  11983. constructor(name: string, direction: Vector3, scene: Scene);
  11984. /**
  11985. * Returns the string "DirectionalLight".
  11986. * @return The class name
  11987. */
  11988. getClassName(): string;
  11989. /**
  11990. * Returns the integer 1.
  11991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11992. */
  11993. getTypeID(): number;
  11994. /**
  11995. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11996. * Returns the DirectionalLight Shadow projection matrix.
  11997. */
  11998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11999. /**
  12000. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  12001. * Returns the DirectionalLight Shadow projection matrix.
  12002. */
  12003. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  12004. /**
  12005. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  12006. * Returns the DirectionalLight Shadow projection matrix.
  12007. */
  12008. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12009. protected _buildUniformLayout(): void;
  12010. /**
  12011. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  12012. * @param effect The effect to update
  12013. * @param lightIndex The index of the light in the effect to update
  12014. * @returns The directional light
  12015. */
  12016. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  12017. /**
  12018. * Gets the minZ used for shadow according to both the scene and the light.
  12019. *
  12020. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12021. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12022. * @param activeCamera The camera we are returning the min for
  12023. * @returns the depth min z
  12024. */
  12025. getDepthMinZ(activeCamera: Camera): number;
  12026. /**
  12027. * Gets the maxZ used for shadow according to both the scene and the light.
  12028. *
  12029. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12030. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12031. * @param activeCamera The camera we are returning the max for
  12032. * @returns the depth max z
  12033. */
  12034. getDepthMaxZ(activeCamera: Camera): number;
  12035. /**
  12036. * Prepares the list of defines specific to the light type.
  12037. * @param defines the list of defines
  12038. * @param lightIndex defines the index of the light for the effect
  12039. */
  12040. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12041. }
  12042. }
  12043. declare module BABYLON {
  12044. /**
  12045. * The HemisphericLight simulates the ambient environment light,
  12046. * so the passed direction is the light reflection direction, not the incoming direction.
  12047. */
  12048. class HemisphericLight extends Light {
  12049. /**
  12050. * The groundColor is the light in the opposite direction to the one specified during creation.
  12051. * 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.
  12052. */
  12053. groundColor: Color3;
  12054. /**
  12055. * The light reflection direction, not the incoming direction.
  12056. */
  12057. direction: Vector3;
  12058. private _worldMatrix;
  12059. /**
  12060. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12061. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12062. * The HemisphericLight can't cast shadows.
  12063. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12064. * @param name The friendly name of the light
  12065. * @param direction The direction of the light reflection
  12066. * @param scene The scene the light belongs to
  12067. */
  12068. constructor(name: string, direction: Vector3, scene: Scene);
  12069. protected _buildUniformLayout(): void;
  12070. /**
  12071. * Returns the string "HemisphericLight".
  12072. * @return The class name
  12073. */
  12074. getClassName(): string;
  12075. /**
  12076. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12077. * Returns the updated direction.
  12078. * @param target The target the direction should point to
  12079. * @return The computed direction
  12080. */
  12081. setDirectionToTarget(target: Vector3): Vector3;
  12082. /**
  12083. * Returns the shadow generator associated to the light.
  12084. * @returns Always null for hemispheric lights because it does not support shadows.
  12085. */
  12086. getShadowGenerator(): Nullable<IShadowGenerator>;
  12087. /**
  12088. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12089. * @param effect The effect to update
  12090. * @param lightIndex The index of the light in the effect to update
  12091. * @returns The hemispheric light
  12092. */
  12093. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12094. /**
  12095. * @hidden internal use only.
  12096. */
  12097. _getWorldMatrix(): Matrix;
  12098. /**
  12099. * Returns the integer 3.
  12100. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12101. */
  12102. getTypeID(): number;
  12103. /**
  12104. * Prepares the list of defines specific to the light type.
  12105. * @param defines the list of defines
  12106. * @param lightIndex defines the index of the light for the effect
  12107. */
  12108. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12109. }
  12110. }
  12111. declare module BABYLON {
  12112. /**
  12113. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12114. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12115. * 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.
  12116. */
  12117. abstract class Light extends Node {
  12118. /**
  12119. * Falloff Default: light is falling off following the material specification:
  12120. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12121. */
  12122. static readonly FALLOFF_DEFAULT: number;
  12123. /**
  12124. * Falloff Physical: light is falling off following the inverse squared distance law.
  12125. */
  12126. static readonly FALLOFF_PHYSICAL: number;
  12127. /**
  12128. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12129. * to enhance interoperability with other engines.
  12130. */
  12131. static readonly FALLOFF_GLTF: number;
  12132. /**
  12133. * Falloff Standard: light is falling off like in the standard material
  12134. * to enhance interoperability with other materials.
  12135. */
  12136. static readonly FALLOFF_STANDARD: number;
  12137. /**
  12138. * If every light affecting the material is in this lightmapMode,
  12139. * material.lightmapTexture adds or multiplies
  12140. * (depends on material.useLightmapAsShadowmap)
  12141. * after every other light calculations.
  12142. */
  12143. static readonly LIGHTMAP_DEFAULT: number;
  12144. /**
  12145. * material.lightmapTexture as only diffuse lighting from this light
  12146. * adds only specular lighting from this light
  12147. * adds dynamic shadows
  12148. */
  12149. static readonly LIGHTMAP_SPECULAR: number;
  12150. /**
  12151. * material.lightmapTexture as only lighting
  12152. * no light calculation from this light
  12153. * only adds dynamic shadows from this light
  12154. */
  12155. static readonly LIGHTMAP_SHADOWSONLY: number;
  12156. /**
  12157. * Each light type uses the default quantity according to its type:
  12158. * point/spot lights use luminous intensity
  12159. * directional lights use illuminance
  12160. */
  12161. static readonly INTENSITYMODE_AUTOMATIC: number;
  12162. /**
  12163. * lumen (lm)
  12164. */
  12165. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12166. /**
  12167. * candela (lm/sr)
  12168. */
  12169. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12170. /**
  12171. * lux (lm/m^2)
  12172. */
  12173. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12174. /**
  12175. * nit (cd/m^2)
  12176. */
  12177. static readonly INTENSITYMODE_LUMINANCE: number;
  12178. /**
  12179. * Light type const id of the point light.
  12180. */
  12181. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12182. /**
  12183. * Light type const id of the directional light.
  12184. */
  12185. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12186. /**
  12187. * Light type const id of the spot light.
  12188. */
  12189. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12190. /**
  12191. * Light type const id of the hemispheric light.
  12192. */
  12193. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12194. /**
  12195. * Diffuse gives the basic color to an object.
  12196. */
  12197. diffuse: Color3;
  12198. /**
  12199. * Specular produces a highlight color on an object.
  12200. * Note: This is note affecting PBR materials.
  12201. */
  12202. specular: Color3;
  12203. /**
  12204. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12205. * falling off base on range or angle.
  12206. * This can be set to any values in Light.FALLOFF_x.
  12207. *
  12208. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12209. * other types of materials.
  12210. */
  12211. falloffType: number;
  12212. /**
  12213. * Strength of the light.
  12214. * Note: By default it is define in the framework own unit.
  12215. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12216. */
  12217. intensity: number;
  12218. private _range;
  12219. protected _inverseSquaredRange: number;
  12220. /**
  12221. * Defines how far from the source the light is impacting in scene units.
  12222. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12223. */
  12224. /**
  12225. * Defines how far from the source the light is impacting in scene units.
  12226. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12227. */
  12228. range: number;
  12229. /**
  12230. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12231. * of light.
  12232. */
  12233. private _photometricScale;
  12234. private _intensityMode;
  12235. /**
  12236. * Gets the photometric scale used to interpret the intensity.
  12237. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12238. */
  12239. /**
  12240. * Sets the photometric scale used to interpret the intensity.
  12241. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12242. */
  12243. intensityMode: number;
  12244. private _radius;
  12245. /**
  12246. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12247. */
  12248. /**
  12249. * sets the light radius used by PBR Materials to simulate soft area lights.
  12250. */
  12251. radius: number;
  12252. private _renderPriority;
  12253. /**
  12254. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12255. * exceeding the number allowed of the materials.
  12256. */
  12257. renderPriority: number;
  12258. private _shadowEnabled;
  12259. /**
  12260. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12261. * the current shadow generator.
  12262. */
  12263. /**
  12264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12265. * the current shadow generator.
  12266. */
  12267. shadowEnabled: boolean;
  12268. private _includedOnlyMeshes;
  12269. /**
  12270. * Gets the only meshes impacted by this light.
  12271. */
  12272. /**
  12273. * Sets the only meshes impacted by this light.
  12274. */
  12275. includedOnlyMeshes: AbstractMesh[];
  12276. private _excludedMeshes;
  12277. /**
  12278. * Gets the meshes not impacted by this light.
  12279. */
  12280. /**
  12281. * Sets the meshes not impacted by this light.
  12282. */
  12283. excludedMeshes: AbstractMesh[];
  12284. private _excludeWithLayerMask;
  12285. /**
  12286. * Gets the layer id use to find what meshes are not impacted by the light.
  12287. * Inactive if 0
  12288. */
  12289. /**
  12290. * Sets the layer id use to find what meshes are not impacted by the light.
  12291. * Inactive if 0
  12292. */
  12293. excludeWithLayerMask: number;
  12294. private _includeOnlyWithLayerMask;
  12295. /**
  12296. * Gets the layer id use to find what meshes are impacted by the light.
  12297. * Inactive if 0
  12298. */
  12299. /**
  12300. * Sets the layer id use to find what meshes are impacted by the light.
  12301. * Inactive if 0
  12302. */
  12303. includeOnlyWithLayerMask: number;
  12304. private _lightmapMode;
  12305. /**
  12306. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12307. */
  12308. /**
  12309. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12310. */
  12311. lightmapMode: number;
  12312. private _parentedWorldMatrix;
  12313. /**
  12314. * Shadow generator associted to the light.
  12315. * @hidden Internal use only.
  12316. */
  12317. _shadowGenerator: Nullable<IShadowGenerator>;
  12318. /**
  12319. * @hidden Internal use only.
  12320. */
  12321. _excludedMeshesIds: string[];
  12322. /**
  12323. * @hidden Internal use only.
  12324. */
  12325. _includedOnlyMeshesIds: string[];
  12326. /**
  12327. * The current light unifom buffer.
  12328. * @hidden Internal use only.
  12329. */
  12330. _uniformBuffer: UniformBuffer;
  12331. /**
  12332. * Creates a Light object in the scene.
  12333. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12334. * @param name The firendly name of the light
  12335. * @param scene The scene the light belongs too
  12336. */
  12337. constructor(name: string, scene: Scene);
  12338. protected abstract _buildUniformLayout(): void;
  12339. /**
  12340. * Sets the passed Effect "effect" with the Light information.
  12341. * @param effect The effect to update
  12342. * @param lightIndex The index of the light in the effect to update
  12343. * @returns The light
  12344. */
  12345. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12346. /**
  12347. * @hidden internal use only.
  12348. */
  12349. abstract _getWorldMatrix(): Matrix;
  12350. /**
  12351. * Returns the string "Light".
  12352. * @returns the class name
  12353. */
  12354. getClassName(): string;
  12355. /**
  12356. * Converts the light information to a readable string for debug purpose.
  12357. * @param fullDetails Supports for multiple levels of logging within scene loading
  12358. * @returns the human readable light info
  12359. */
  12360. toString(fullDetails?: boolean): string;
  12361. /**
  12362. * Set the enabled state of this node.
  12363. * @param value - the new enabled state
  12364. */
  12365. setEnabled(value: boolean): void;
  12366. /**
  12367. * Returns the Light associated shadow generator if any.
  12368. * @return the associated shadow generator.
  12369. */
  12370. getShadowGenerator(): Nullable<IShadowGenerator>;
  12371. /**
  12372. * Returns a Vector3, the absolute light position in the World.
  12373. * @returns the world space position of the light
  12374. */
  12375. getAbsolutePosition(): Vector3;
  12376. /**
  12377. * Specifies if the light will affect the passed mesh.
  12378. * @param mesh The mesh to test against the light
  12379. * @return true the mesh is affected otherwise, false.
  12380. */
  12381. canAffectMesh(mesh: AbstractMesh): boolean;
  12382. /**
  12383. * Computes and Returns the light World matrix.
  12384. * @returns the world matrix
  12385. */
  12386. getWorldMatrix(): Matrix;
  12387. /**
  12388. * Sort function to order lights for rendering.
  12389. * @param a First Light object to compare to second.
  12390. * @param b Second Light object to compare first.
  12391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12392. */
  12393. static CompareLightsPriority(a: Light, b: Light): number;
  12394. /**
  12395. * Releases resources associated with this node.
  12396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12398. */
  12399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12400. /**
  12401. * Returns the light type ID (integer).
  12402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12403. */
  12404. getTypeID(): number;
  12405. /**
  12406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12407. * @returns the scaled intensity in intensity mode unit
  12408. */
  12409. getScaledIntensity(): number;
  12410. /**
  12411. * Returns a new Light object, named "name", from the current one.
  12412. * @param name The name of the cloned light
  12413. * @returns the new created light
  12414. */
  12415. clone(name: string): Nullable<Light>;
  12416. /**
  12417. * Serializes the current light into a Serialization object.
  12418. * @returns the serialized object.
  12419. */
  12420. serialize(): any;
  12421. /**
  12422. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12423. * This new light is named "name" and added to the passed scene.
  12424. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12425. * @param name The friendly name of the light
  12426. * @param scene The scene the new light will belong to
  12427. * @returns the constructor function
  12428. */
  12429. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12430. /**
  12431. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12432. * @param parsedLight The JSON representation of the light
  12433. * @param scene The scene to create the parsed light in
  12434. * @returns the created light after parsing
  12435. */
  12436. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12437. private _hookArrayForExcluded;
  12438. private _hookArrayForIncludedOnly;
  12439. private _resyncMeshes;
  12440. /**
  12441. * Forces the meshes to update their light related information in their rendering used effects
  12442. * @hidden Internal Use Only
  12443. */
  12444. _markMeshesAsLightDirty(): void;
  12445. /**
  12446. * Recomputes the cached photometric scale if needed.
  12447. */
  12448. private _computePhotometricScale;
  12449. /**
  12450. * Returns the Photometric Scale according to the light type and intensity mode.
  12451. */
  12452. private _getPhotometricScale;
  12453. /**
  12454. * Reorder the light in the scene according to their defined priority.
  12455. * @hidden Internal Use Only
  12456. */
  12457. _reorderLightsInScene(): void;
  12458. /**
  12459. * Prepares the list of defines specific to the light type.
  12460. * @param defines the list of defines
  12461. * @param lightIndex defines the index of the light for the effect
  12462. */
  12463. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12464. }
  12465. }
  12466. declare module BABYLON {
  12467. /**
  12468. * A point light is a light defined by an unique point in world space.
  12469. * The light is emitted in every direction from this point.
  12470. * A good example of a point light is a standard light bulb.
  12471. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12472. */
  12473. class PointLight extends ShadowLight {
  12474. private _shadowAngle;
  12475. /**
  12476. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12477. * This specifies what angle the shadow will use to be created.
  12478. *
  12479. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12480. */
  12481. /**
  12482. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12483. * This specifies what angle the shadow will use to be created.
  12484. *
  12485. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12486. */
  12487. shadowAngle: number;
  12488. /**
  12489. * Gets the direction if it has been set.
  12490. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12491. */
  12492. /**
  12493. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12494. */
  12495. direction: Vector3;
  12496. /**
  12497. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12498. * A PointLight emits the light in every direction.
  12499. * It can cast shadows.
  12500. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12501. * ```javascript
  12502. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12503. * ```
  12504. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12505. * @param name The light friendly name
  12506. * @param position The position of the point light in the scene
  12507. * @param scene The scene the lights belongs to
  12508. */
  12509. constructor(name: string, position: Vector3, scene: Scene);
  12510. /**
  12511. * Returns the string "PointLight"
  12512. * @returns the class name
  12513. */
  12514. getClassName(): string;
  12515. /**
  12516. * Returns the integer 0.
  12517. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12518. */
  12519. getTypeID(): number;
  12520. /**
  12521. * Specifies wether or not the shadowmap should be a cube texture.
  12522. * @returns true if the shadowmap needs to be a cube texture.
  12523. */
  12524. needCube(): boolean;
  12525. /**
  12526. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12527. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12528. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12529. */
  12530. getShadowDirection(faceIndex?: number): Vector3;
  12531. /**
  12532. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12533. * - fov = PI / 2
  12534. * - aspect ratio : 1.0
  12535. * - z-near and far equal to the active camera minZ and maxZ.
  12536. * Returns the PointLight.
  12537. */
  12538. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12539. protected _buildUniformLayout(): void;
  12540. /**
  12541. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12542. * @param effect The effect to update
  12543. * @param lightIndex The index of the light in the effect to update
  12544. * @returns The point light
  12545. */
  12546. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12547. /**
  12548. * Prepares the list of defines specific to the light type.
  12549. * @param defines the list of defines
  12550. * @param lightIndex defines the index of the light for the effect
  12551. */
  12552. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12553. }
  12554. }
  12555. declare module BABYLON {
  12556. /**
  12557. * Interface describing all the common properties and methods a shadow light needs to implement.
  12558. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12559. * as well as binding the different shadow properties to the effects.
  12560. */
  12561. interface IShadowLight extends Light {
  12562. /**
  12563. * The light id in the scene (used in scene.findLighById for instance)
  12564. */
  12565. id: string;
  12566. /**
  12567. * The position the shdow will be casted from.
  12568. */
  12569. position: Vector3;
  12570. /**
  12571. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12572. */
  12573. direction: Vector3;
  12574. /**
  12575. * The transformed position. Position of the light in world space taking parenting in account.
  12576. */
  12577. transformedPosition: Vector3;
  12578. /**
  12579. * The transformed direction. Direction of the light in world space taking parenting in account.
  12580. */
  12581. transformedDirection: Vector3;
  12582. /**
  12583. * The friendly name of the light in the scene.
  12584. */
  12585. name: string;
  12586. /**
  12587. * Defines the shadow projection clipping minimum z value.
  12588. */
  12589. shadowMinZ: number;
  12590. /**
  12591. * Defines the shadow projection clipping maximum z value.
  12592. */
  12593. shadowMaxZ: number;
  12594. /**
  12595. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12596. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12597. */
  12598. computeTransformedInformation(): boolean;
  12599. /**
  12600. * Gets the scene the light belongs to.
  12601. * @returns The scene
  12602. */
  12603. getScene(): Scene;
  12604. /**
  12605. * Callback defining a custom Projection Matrix Builder.
  12606. * This can be used to override the default projection matrix computation.
  12607. */
  12608. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12609. /**
  12610. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12611. * @param matrix The materix to updated with the projection information
  12612. * @param viewMatrix The transform matrix of the light
  12613. * @param renderList The list of mesh to render in the map
  12614. * @returns The current light
  12615. */
  12616. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12617. /**
  12618. * Gets the current depth scale used in ESM.
  12619. * @returns The scale
  12620. */
  12621. getDepthScale(): number;
  12622. /**
  12623. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12624. * @returns true if a cube texture needs to be use
  12625. */
  12626. needCube(): boolean;
  12627. /**
  12628. * Detects if the projection matrix requires to be recomputed this frame.
  12629. * @returns true if it requires to be recomputed otherwise, false.
  12630. */
  12631. needProjectionMatrixCompute(): boolean;
  12632. /**
  12633. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12634. */
  12635. forceProjectionMatrixCompute(): void;
  12636. /**
  12637. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12638. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12639. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12640. */
  12641. getShadowDirection(faceIndex?: number): Vector3;
  12642. /**
  12643. * Gets the minZ used for shadow according to both the scene and the light.
  12644. * @param activeCamera The camera we are returning the min for
  12645. * @returns the depth min z
  12646. */
  12647. getDepthMinZ(activeCamera: Camera): number;
  12648. /**
  12649. * Gets the maxZ used for shadow according to both the scene and the light.
  12650. * @param activeCamera The camera we are returning the max for
  12651. * @returns the depth max z
  12652. */
  12653. getDepthMaxZ(activeCamera: Camera): number;
  12654. }
  12655. /**
  12656. * Base implementation IShadowLight
  12657. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12658. */
  12659. abstract class ShadowLight extends Light implements IShadowLight {
  12660. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12661. protected _position: Vector3;
  12662. protected _setPosition(value: Vector3): void;
  12663. /**
  12664. * Sets the position the shadow will be casted from. Also use as the light position for both
  12665. * point and spot lights.
  12666. */
  12667. /**
  12668. * Sets the position the shadow will be casted from. Also use as the light position for both
  12669. * point and spot lights.
  12670. */
  12671. position: Vector3;
  12672. protected _direction: Vector3;
  12673. protected _setDirection(value: Vector3): void;
  12674. /**
  12675. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12676. * Also use as the light direction on spot and directional lights.
  12677. */
  12678. /**
  12679. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12680. * Also use as the light direction on spot and directional lights.
  12681. */
  12682. direction: Vector3;
  12683. private _shadowMinZ;
  12684. /**
  12685. * Gets the shadow projection clipping minimum z value.
  12686. */
  12687. /**
  12688. * Sets the shadow projection clipping minimum z value.
  12689. */
  12690. shadowMinZ: number;
  12691. private _shadowMaxZ;
  12692. /**
  12693. * Sets the shadow projection clipping maximum z value.
  12694. */
  12695. /**
  12696. * Gets the shadow projection clipping maximum z value.
  12697. */
  12698. shadowMaxZ: number;
  12699. /**
  12700. * Callback defining a custom Projection Matrix Builder.
  12701. * This can be used to override the default projection matrix computation.
  12702. */
  12703. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12704. /**
  12705. * The transformed position. Position of the light in world space taking parenting in account.
  12706. */
  12707. transformedPosition: Vector3;
  12708. /**
  12709. * The transformed direction. Direction of the light in world space taking parenting in account.
  12710. */
  12711. transformedDirection: Vector3;
  12712. private _worldMatrix;
  12713. private _needProjectionMatrixCompute;
  12714. /**
  12715. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12716. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12717. */
  12718. computeTransformedInformation(): boolean;
  12719. /**
  12720. * Return the depth scale used for the shadow map.
  12721. * @returns the depth scale.
  12722. */
  12723. getDepthScale(): number;
  12724. /**
  12725. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12726. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12727. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12728. */
  12729. getShadowDirection(faceIndex?: number): Vector3;
  12730. /**
  12731. * Returns the ShadowLight absolute position in the World.
  12732. * @returns the position vector in world space
  12733. */
  12734. getAbsolutePosition(): Vector3;
  12735. /**
  12736. * Sets the ShadowLight direction toward the passed target.
  12737. * @param target The point tot target in local space
  12738. * @returns the updated ShadowLight direction
  12739. */
  12740. setDirectionToTarget(target: Vector3): Vector3;
  12741. /**
  12742. * Returns the light rotation in euler definition.
  12743. * @returns the x y z rotation in local space.
  12744. */
  12745. getRotation(): Vector3;
  12746. /**
  12747. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12748. * @returns true if a cube texture needs to be use
  12749. */
  12750. needCube(): boolean;
  12751. /**
  12752. * Detects if the projection matrix requires to be recomputed this frame.
  12753. * @returns true if it requires to be recomputed otherwise, false.
  12754. */
  12755. needProjectionMatrixCompute(): boolean;
  12756. /**
  12757. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12758. */
  12759. forceProjectionMatrixCompute(): void;
  12760. /**
  12761. * Get the world matrix of the sahdow lights.
  12762. * @hidden Internal Use Only
  12763. */
  12764. _getWorldMatrix(): Matrix;
  12765. /**
  12766. * Gets the minZ used for shadow according to both the scene and the light.
  12767. * @param activeCamera The camera we are returning the min for
  12768. * @returns the depth min z
  12769. */
  12770. getDepthMinZ(activeCamera: Camera): number;
  12771. /**
  12772. * Gets the maxZ used for shadow according to both the scene and the light.
  12773. * @param activeCamera The camera we are returning the max for
  12774. * @returns the depth max z
  12775. */
  12776. getDepthMaxZ(activeCamera: Camera): number;
  12777. /**
  12778. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12779. * @param matrix The materix to updated with the projection information
  12780. * @param viewMatrix The transform matrix of the light
  12781. * @param renderList The list of mesh to render in the map
  12782. * @returns The current light
  12783. */
  12784. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12785. }
  12786. }
  12787. declare module BABYLON {
  12788. /**
  12789. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12790. * These values define a cone of light starting from the position, emitting toward the direction.
  12791. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12792. * and the exponent defines the speed of the decay of the light with distance (reach).
  12793. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12794. */
  12795. class SpotLight extends ShadowLight {
  12796. private _angle;
  12797. private _innerAngle;
  12798. private _cosHalfAngle;
  12799. private _lightAngleScale;
  12800. private _lightAngleOffset;
  12801. /**
  12802. * Gets the cone angle of the spot light in Radians.
  12803. */
  12804. /**
  12805. * Sets the cone angle of the spot light in Radians.
  12806. */
  12807. angle: number;
  12808. /**
  12809. * Only used in gltf falloff mode, this defines the angle where
  12810. * the directional falloff will start before cutting at angle which could be seen
  12811. * as outer angle.
  12812. */
  12813. /**
  12814. * Only used in gltf falloff mode, this defines the angle where
  12815. * the directional falloff will start before cutting at angle which could be seen
  12816. * as outer angle.
  12817. */
  12818. innerAngle: number;
  12819. private _shadowAngleScale;
  12820. /**
  12821. * Allows scaling the angle of the light for shadow generation only.
  12822. */
  12823. /**
  12824. * Allows scaling the angle of the light for shadow generation only.
  12825. */
  12826. shadowAngleScale: number;
  12827. /**
  12828. * The light decay speed with the distance from the emission spot.
  12829. */
  12830. exponent: number;
  12831. private _projectionTextureMatrix;
  12832. /**
  12833. * Allows reading the projecton texture
  12834. */
  12835. readonly projectionTextureMatrix: Matrix;
  12836. protected _projectionTextureLightNear: number;
  12837. /**
  12838. * Gets the near clip of the Spotlight for texture projection.
  12839. */
  12840. /**
  12841. * Sets the near clip of the Spotlight for texture projection.
  12842. */
  12843. projectionTextureLightNear: number;
  12844. protected _projectionTextureLightFar: number;
  12845. /**
  12846. * Gets the far clip of the Spotlight for texture projection.
  12847. */
  12848. /**
  12849. * Sets the far clip of the Spotlight for texture projection.
  12850. */
  12851. projectionTextureLightFar: number;
  12852. protected _projectionTextureUpDirection: Vector3;
  12853. /**
  12854. * Gets the Up vector of the Spotlight for texture projection.
  12855. */
  12856. /**
  12857. * Sets the Up vector of the Spotlight for texture projection.
  12858. */
  12859. projectionTextureUpDirection: Vector3;
  12860. private _projectionTexture;
  12861. /**
  12862. * Gets the projection texture of the light.
  12863. */
  12864. /**
  12865. * Sets the projection texture of the light.
  12866. */
  12867. projectionTexture: Nullable<BaseTexture>;
  12868. private _projectionTextureViewLightDirty;
  12869. private _projectionTextureProjectionLightDirty;
  12870. private _projectionTextureDirty;
  12871. private _projectionTextureViewTargetVector;
  12872. private _projectionTextureViewLightMatrix;
  12873. private _projectionTextureProjectionLightMatrix;
  12874. private _projectionTextureScalingMatrix;
  12875. /**
  12876. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12877. * It can cast shadows.
  12878. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12879. * @param name The light friendly name
  12880. * @param position The position of the spot light in the scene
  12881. * @param direction The direction of the light in the scene
  12882. * @param angle The cone angle of the light in Radians
  12883. * @param exponent The light decay speed with the distance from the emission spot
  12884. * @param scene The scene the lights belongs to
  12885. */
  12886. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12887. /**
  12888. * Returns the string "SpotLight".
  12889. * @returns the class name
  12890. */
  12891. getClassName(): string;
  12892. /**
  12893. * Returns the integer 2.
  12894. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12895. */
  12896. getTypeID(): number;
  12897. /**
  12898. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12899. */
  12900. protected _setDirection(value: Vector3): void;
  12901. /**
  12902. * Overrides the position setter to recompute the projection texture view light Matrix.
  12903. */
  12904. protected _setPosition(value: Vector3): void;
  12905. /**
  12906. * 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.
  12907. * Returns the SpotLight.
  12908. */
  12909. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12910. protected _computeProjectionTextureViewLightMatrix(): void;
  12911. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12912. /**
  12913. * Main function for light texture projection matrix computing.
  12914. */
  12915. protected _computeProjectionTextureMatrix(): void;
  12916. protected _buildUniformLayout(): void;
  12917. private _computeAngleValues;
  12918. /**
  12919. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12920. * @param effect The effect to update
  12921. * @param lightIndex The index of the light in the effect to update
  12922. * @returns The spot light
  12923. */
  12924. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12925. /**
  12926. * Disposes the light and the associated resources.
  12927. */
  12928. dispose(): void;
  12929. /**
  12930. * Prepares the list of defines specific to the light type.
  12931. * @param defines the list of defines
  12932. * @param lightIndex defines the index of the light for the effect
  12933. */
  12934. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12935. }
  12936. }
  12937. declare module BABYLON {
  12938. interface ILoadingScreen {
  12939. displayLoadingUI: () => void;
  12940. hideLoadingUI: () => void;
  12941. loadingUIBackgroundColor: string;
  12942. loadingUIText: string;
  12943. }
  12944. class DefaultLoadingScreen implements ILoadingScreen {
  12945. private _renderingCanvas;
  12946. private _loadingText;
  12947. private _loadingDivBackgroundColor;
  12948. private _loadingDiv;
  12949. private _loadingTextDiv;
  12950. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12951. displayLoadingUI(): void;
  12952. hideLoadingUI(): void;
  12953. loadingUIText: string;
  12954. loadingUIBackgroundColor: string;
  12955. private _resizeLoadingUI;
  12956. }
  12957. }
  12958. declare module BABYLON {
  12959. class SceneLoaderProgressEvent {
  12960. readonly lengthComputable: boolean;
  12961. readonly loaded: number;
  12962. readonly total: number;
  12963. constructor(lengthComputable: boolean, loaded: number, total: number);
  12964. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12965. }
  12966. interface ISceneLoaderPluginExtensions {
  12967. [extension: string]: {
  12968. isBinary: boolean;
  12969. };
  12970. }
  12971. interface ISceneLoaderPluginFactory {
  12972. name: string;
  12973. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12974. canDirectLoad?: (data: string) => boolean;
  12975. }
  12976. interface ISceneLoaderPlugin {
  12977. /**
  12978. * The friendly name of this plugin.
  12979. */
  12980. name: string;
  12981. /**
  12982. * The file extensions supported by this plugin.
  12983. */
  12984. extensions: string | ISceneLoaderPluginExtensions;
  12985. /**
  12986. * Import meshes into a scene.
  12987. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12988. * @param scene The scene to import into
  12989. * @param data The data to import
  12990. * @param rootUrl The root url for scene and resources
  12991. * @param meshes The meshes array to import into
  12992. * @param particleSystems The particle systems array to import into
  12993. * @param skeletons The skeletons array to import into
  12994. * @param onError The callback when import fails
  12995. * @returns True if successful or false otherwise
  12996. */
  12997. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12998. /**
  12999. * Load into a scene.
  13000. * @param scene The scene to load into
  13001. * @param data The data to import
  13002. * @param rootUrl The root url for scene and resources
  13003. * @param onError The callback when import fails
  13004. * @returns true if successful or false otherwise
  13005. */
  13006. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  13007. /**
  13008. * The callback that returns true if the data can be directly loaded.
  13009. */
  13010. canDirectLoad?: (data: string) => boolean;
  13011. /**
  13012. * The callback that allows custom handling of the root url based on the response url.
  13013. */
  13014. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13015. /**
  13016. * Load into an asset container.
  13017. * @param scene The scene to load into
  13018. * @param data The data to import
  13019. * @param rootUrl The root url for scene and resources
  13020. * @param onError The callback when import fails
  13021. * @returns The loaded asset container
  13022. */
  13023. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  13024. }
  13025. interface ISceneLoaderPluginAsync {
  13026. /**
  13027. * The friendly name of this plugin.
  13028. */
  13029. name: string;
  13030. /**
  13031. * The file extensions supported by this plugin.
  13032. */
  13033. extensions: string | ISceneLoaderPluginExtensions;
  13034. /**
  13035. * Import meshes into a scene.
  13036. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13037. * @param scene The scene to import into
  13038. * @param data The data to import
  13039. * @param rootUrl The root url for scene and resources
  13040. * @param onProgress The callback when the load progresses
  13041. * @param fullName Defines the FQDN of the file to load
  13042. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13043. */
  13044. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<{
  13045. meshes: AbstractMesh[];
  13046. particleSystems: IParticleSystem[];
  13047. skeletons: Skeleton[];
  13048. animationGroups: AnimationGroup[];
  13049. }>;
  13050. /**
  13051. * Load into a scene.
  13052. * @param scene The scene to load into
  13053. * @param data The data to import
  13054. * @param rootUrl The root url for scene and resources
  13055. * @param onProgress The callback when the load progresses
  13056. * @param fullName Defines the FQDN of the file to load
  13057. * @returns Nothing
  13058. */
  13059. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<void>;
  13060. /**
  13061. * The callback that returns true if the data can be directly loaded.
  13062. */
  13063. canDirectLoad?: (data: string) => boolean;
  13064. /**
  13065. * The callback that allows custom handling of the root url based on the response url.
  13066. */
  13067. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13068. /**
  13069. * Load into an asset container.
  13070. * @param scene The scene to load into
  13071. * @param data The data to import
  13072. * @param rootUrl The root url for scene and resources
  13073. * @param onProgress The callback when the load progresses
  13074. * @param fullName Defines the FQDN of the file to load
  13075. * @returns The loaded asset container
  13076. */
  13077. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fullName?: string): Promise<AssetContainer>;
  13078. }
  13079. class SceneLoader {
  13080. private static _ForceFullSceneLoadingForIncremental;
  13081. private static _ShowLoadingScreen;
  13082. private static _CleanBoneMatrixWeights;
  13083. static readonly NO_LOGGING: number;
  13084. static readonly MINIMAL_LOGGING: number;
  13085. static readonly SUMMARY_LOGGING: number;
  13086. static readonly DETAILED_LOGGING: number;
  13087. private static _loggingLevel;
  13088. static ForceFullSceneLoadingForIncremental: boolean;
  13089. static ShowLoadingScreen: boolean;
  13090. static loggingLevel: number;
  13091. static CleanBoneMatrixWeights: boolean;
  13092. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13093. private static _registeredPlugins;
  13094. private static _getDefaultPlugin;
  13095. private static _getPluginForExtension;
  13096. private static _getPluginForDirectLoad;
  13097. private static _getPluginForFilename;
  13098. private static _getDirectLoad;
  13099. private static _loadData;
  13100. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13101. static IsPluginForExtensionAvailable(extension: string): boolean;
  13102. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  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 onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13110. * @param onProgress a callback with a progress event for each file being loaded
  13111. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13112. * @param pluginExtension the extension used to determine the plugin
  13113. * @returns The loaded plugin
  13114. */
  13115. 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>;
  13116. /**
  13117. * Import meshes into a scene
  13118. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13119. * @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)
  13120. * @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)
  13121. * @param scene the instance of BABYLON.Scene to append to
  13122. * @param onProgress a callback with a progress event for each file being loaded
  13123. * @param pluginExtension the extension used to determine the plugin
  13124. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13125. */
  13126. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13127. meshes: AbstractMesh[];
  13128. particleSystems: IParticleSystem[];
  13129. skeletons: Skeleton[];
  13130. animationGroups: AnimationGroup[];
  13131. }>;
  13132. /**
  13133. * Load a scene
  13134. * @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)
  13135. * @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)
  13136. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13137. * @param onSuccess a callback with the scene when import succeeds
  13138. * @param onProgress a callback with a progress event for each file being loaded
  13139. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13140. * @param pluginExtension the extension used to determine the plugin
  13141. * @returns The loaded plugin
  13142. */
  13143. 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>;
  13144. /**
  13145. * Load a scene
  13146. * @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)
  13147. * @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)
  13148. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13149. * @param onProgress a callback with a progress event for each file being loaded
  13150. * @param pluginExtension the extension used to determine the plugin
  13151. * @returns The loaded scene
  13152. */
  13153. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13154. /**
  13155. * Append a scene
  13156. * @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)
  13157. * @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)
  13158. * @param scene is the instance of BABYLON.Scene to append to
  13159. * @param onSuccess a callback with the scene when import succeeds
  13160. * @param onProgress a callback with a progress event for each file being loaded
  13161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13162. * @param pluginExtension the extension used to determine the plugin
  13163. * @returns The loaded plugin
  13164. */
  13165. 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>;
  13166. /**
  13167. * Append a scene
  13168. * @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)
  13169. * @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)
  13170. * @param scene is the instance of BABYLON.Scene to append to
  13171. * @param onProgress a callback with a progress event for each file being loaded
  13172. * @param pluginExtension the extension used to determine the plugin
  13173. * @returns The given scene
  13174. */
  13175. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13176. /**
  13177. * Load a scene into an asset container
  13178. * @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)
  13179. * @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)
  13180. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13181. * @param onSuccess a callback with the scene when import succeeds
  13182. * @param onProgress a callback with a progress event for each file being loaded
  13183. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13184. * @param pluginExtension the extension used to determine the plugin
  13185. * @returns The loaded plugin
  13186. */
  13187. 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>;
  13188. /**
  13189. * Load a scene into an asset container
  13190. * @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)
  13191. * @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)
  13192. * @param scene is the instance of BABYLON.Scene to append to
  13193. * @param onProgress a callback with a progress event for each file being loaded
  13194. * @param pluginExtension the extension used to determine the plugin
  13195. * @returns The loaded asset container
  13196. */
  13197. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13198. }
  13199. }
  13200. declare module BABYLON {
  13201. class Scalar {
  13202. /**
  13203. * Two pi constants convenient for computation.
  13204. */
  13205. static TwoPi: number;
  13206. /**
  13207. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  13208. */
  13209. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  13210. /**
  13211. * Returns a string : the upper case translation of the number i to hexadecimal.
  13212. */
  13213. static ToHex(i: number): string;
  13214. /**
  13215. * Returns -1 if value is negative and +1 is value is positive.
  13216. * Returns the value itself if it's equal to zero.
  13217. */
  13218. static Sign(value: number): number;
  13219. /**
  13220. * Returns the value itself if it's between min and max.
  13221. * Returns min if the value is lower than min.
  13222. * Returns max if the value is greater than max.
  13223. */
  13224. static Clamp(value: number, min?: number, max?: number): number;
  13225. /**
  13226. * Returns the log2 of value.
  13227. */
  13228. static Log2(value: number): number;
  13229. /**
  13230. * Loops the value, so that it is never larger than length and never smaller than 0.
  13231. *
  13232. * This is similar to the modulo operator but it works with floating point numbers.
  13233. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  13234. * With t = 5 and length = 2.5, the result would be 0.0.
  13235. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  13236. */
  13237. static Repeat(value: number, length: number): number;
  13238. /**
  13239. * Normalize the value between 0.0 and 1.0 using min and max values
  13240. */
  13241. static Normalize(value: number, min: number, max: number): number;
  13242. /**
  13243. * Denormalize the value from 0.0 and 1.0 using min and max values
  13244. */
  13245. static Denormalize(normalized: number, min: number, max: number): number;
  13246. /**
  13247. * Calculates the shortest difference between two given angles given in degrees.
  13248. */
  13249. static DeltaAngle(current: number, target: number): number;
  13250. /**
  13251. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  13252. *
  13253. * The returned value will move back and forth between 0 and length
  13254. */
  13255. static PingPong(tx: number, length: number): number;
  13256. /**
  13257. * Interpolates between min and max with smoothing at the limits.
  13258. *
  13259. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  13260. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  13261. */
  13262. static SmoothStep(from: number, to: number, tx: number): number;
  13263. /**
  13264. * Moves a value current towards target.
  13265. *
  13266. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  13267. * Negative values of maxDelta pushes the value away from target.
  13268. */
  13269. static MoveTowards(current: number, target: number, maxDelta: number): number;
  13270. /**
  13271. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13272. *
  13273. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  13274. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  13275. */
  13276. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  13277. /**
  13278. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  13279. */
  13280. static Lerp(start: number, end: number, amount: number): number;
  13281. /**
  13282. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13283. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  13284. */
  13285. static LerpAngle(start: number, end: number, amount: number): number;
  13286. /**
  13287. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  13288. */
  13289. static InverseLerp(a: number, b: number, value: number): number;
  13290. /**
  13291. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  13292. */
  13293. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  13294. /**
  13295. * Returns a random float number between and min and max values
  13296. */
  13297. static RandomRange(min: number, max: number): number;
  13298. /**
  13299. * This function returns percentage of a number in a given range.
  13300. *
  13301. * RangeToPercent(40,20,60) will return 0.5 (50%)
  13302. * RangeToPercent(34,0,100) will return 0.34 (34%)
  13303. */
  13304. static RangeToPercent(number: number, min: number, max: number): number;
  13305. /**
  13306. * This function returns number that corresponds to the percentage in a given range.
  13307. *
  13308. * PercentToRange(0.34,0,100) will return 34.
  13309. */
  13310. static PercentToRange(percent: number, min: number, max: number): number;
  13311. /**
  13312. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  13313. * @param angle The angle to normalize in radian.
  13314. * @return The converted angle.
  13315. */
  13316. static NormalizeRadians(angle: number): number;
  13317. }
  13318. }
  13319. declare module BABYLON {
  13320. const ToGammaSpace: number;
  13321. const ToLinearSpace = 2.2;
  13322. const Epsilon = 0.001;
  13323. /**
  13324. * Class used to hold a RBG color
  13325. */
  13326. class Color3 {
  13327. /**
  13328. * Defines the red component (between 0 and 1, default is 0)
  13329. */
  13330. r: number;
  13331. /**
  13332. * Defines the green component (between 0 and 1, default is 0)
  13333. */
  13334. g: number;
  13335. /**
  13336. * Defines the blue component (between 0 and 1, default is 0)
  13337. */
  13338. b: number;
  13339. /**
  13340. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  13341. * @param r defines the red component (between 0 and 1, default is 0)
  13342. * @param g defines the green component (between 0 and 1, default is 0)
  13343. * @param b defines the blue component (between 0 and 1, default is 0)
  13344. */
  13345. constructor(
  13346. /**
  13347. * Defines the red component (between 0 and 1, default is 0)
  13348. */
  13349. r?: number,
  13350. /**
  13351. * Defines the green component (between 0 and 1, default is 0)
  13352. */
  13353. g?: number,
  13354. /**
  13355. * Defines the blue component (between 0 and 1, default is 0)
  13356. */
  13357. b?: number);
  13358. /**
  13359. * Creates a string with the Color3 current values
  13360. * @returns the string representation of the Color3 object
  13361. */
  13362. toString(): string;
  13363. /**
  13364. * Returns the string "Color3"
  13365. * @returns "Color3"
  13366. */
  13367. getClassName(): string;
  13368. /**
  13369. * Compute the Color3 hash code
  13370. * @returns an unique number that can be used to hash Color3 objects
  13371. */
  13372. getHashCode(): number;
  13373. /**
  13374. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  13375. * @param array defines the array where to store the r,g,b components
  13376. * @param index defines an optional index in the target array to define where to start storing values
  13377. * @returns the current Color3 object
  13378. */
  13379. toArray(array: FloatArray, index?: number): Color3;
  13380. /**
  13381. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  13382. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  13383. * @returns a new {BABYLON.Color4} object
  13384. */
  13385. toColor4(alpha?: number): Color4;
  13386. /**
  13387. * Returns a new array populated with 3 numeric elements : red, green and blue values
  13388. * @returns the new array
  13389. */
  13390. asArray(): number[];
  13391. /**
  13392. * Returns the luminance value
  13393. * @returns a float value
  13394. */
  13395. toLuminance(): number;
  13396. /**
  13397. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  13398. * @param otherColor defines the second operand
  13399. * @returns the new Color3 object
  13400. */
  13401. multiply(otherColor: Color3): Color3;
  13402. /**
  13403. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  13404. * @param otherColor defines the second operand
  13405. * @param result defines the Color3 object where to store the result
  13406. * @returns the current Color3
  13407. */
  13408. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  13409. /**
  13410. * Determines equality between Color3 objects
  13411. * @param otherColor defines the second operand
  13412. * @returns true if the rgb values are equal to the given ones
  13413. */
  13414. equals(otherColor: Color3): boolean;
  13415. /**
  13416. * Determines equality between the current Color3 object and a set of r,b,g values
  13417. * @param r defines the red component to check
  13418. * @param g defines the green component to check
  13419. * @param b defines the blue component to check
  13420. * @returns true if the rgb values are equal to the given ones
  13421. */
  13422. equalsFloats(r: number, g: number, b: number): boolean;
  13423. /**
  13424. * Multiplies in place each rgb value by scale
  13425. * @param scale defines the scaling factor
  13426. * @returns the updated Color3
  13427. */
  13428. scale(scale: number): Color3;
  13429. /**
  13430. * Multiplies the rgb values by scale and stores the result into "result"
  13431. * @param scale defines the scaling factor
  13432. * @param result defines the Color3 object where to store the result
  13433. * @returns the unmodified current Color3
  13434. */
  13435. scaleToRef(scale: number, result: Color3): Color3;
  13436. /**
  13437. * Scale the current Color3 values by a factor and add the result to a given Color3
  13438. * @param scale defines the scale factor
  13439. * @param result defines color to store the result into
  13440. * @returns the unmodified current Color3
  13441. */
  13442. scaleAndAddToRef(scale: number, result: Color3): Color3;
  13443. /**
  13444. * Clamps the rgb values by the min and max values and stores the result into "result"
  13445. * @param min defines minimum clamping value (default is 0)
  13446. * @param max defines maximum clamping value (default is 1)
  13447. * @param result defines color to store the result into
  13448. * @returns the original Color3
  13449. */
  13450. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  13451. /**
  13452. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  13453. * @param otherColor defines the second operand
  13454. * @returns the new Color3
  13455. */
  13456. add(otherColor: Color3): Color3;
  13457. /**
  13458. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  13459. * @param otherColor defines the second operand
  13460. * @param result defines Color3 object to store the result into
  13461. * @returns the unmodified current Color3
  13462. */
  13463. addToRef(otherColor: Color3, result: Color3): Color3;
  13464. /**
  13465. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  13466. * @param otherColor defines the second operand
  13467. * @returns the new Color3
  13468. */
  13469. subtract(otherColor: Color3): Color3;
  13470. /**
  13471. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  13472. * @param otherColor defines the second operand
  13473. * @param result defines Color3 object to store the result into
  13474. * @returns the unmodified current Color3
  13475. */
  13476. subtractToRef(otherColor: Color3, result: Color3): Color3;
  13477. /**
  13478. * Copy the current object
  13479. * @returns a new Color3 copied the current one
  13480. */
  13481. clone(): Color3;
  13482. /**
  13483. * Copies the rgb values from the source in the current Color3
  13484. * @param source defines the source Color3 object
  13485. * @returns the updated Color3 object
  13486. */
  13487. copyFrom(source: Color3): Color3;
  13488. /**
  13489. * Updates the Color3 rgb values from the given floats
  13490. * @param r defines the red component to read from
  13491. * @param g defines the green component to read from
  13492. * @param b defines the blue component to read from
  13493. * @returns the current Color3 object
  13494. */
  13495. copyFromFloats(r: number, g: number, b: number): Color3;
  13496. /**
  13497. * Updates the Color3 rgb values from the given floats
  13498. * @param r defines the red component to read from
  13499. * @param g defines the green component to read from
  13500. * @param b defines the blue component to read from
  13501. * @returns the current Color3 object
  13502. */
  13503. set(r: number, g: number, b: number): Color3;
  13504. /**
  13505. * Compute the Color3 hexadecimal code as a string
  13506. * @returns a string containing the hexadecimal representation of the Color3 object
  13507. */
  13508. toHexString(): string;
  13509. /**
  13510. * Computes a new Color3 converted from the current one to linear space
  13511. * @returns a new Color3 object
  13512. */
  13513. toLinearSpace(): Color3;
  13514. /**
  13515. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  13516. * @param convertedColor defines the Color3 object where to store the linear space version
  13517. * @returns the unmodified Color3
  13518. */
  13519. toLinearSpaceToRef(convertedColor: Color3): Color3;
  13520. /**
  13521. * Computes a new Color3 converted from the current one to gamma space
  13522. * @returns a new Color3 object
  13523. */
  13524. toGammaSpace(): Color3;
  13525. /**
  13526. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  13527. * @param convertedColor defines the Color3 object where to store the gamma space version
  13528. * @returns the unmodified Color3
  13529. */
  13530. toGammaSpaceToRef(convertedColor: Color3): Color3;
  13531. /**
  13532. * Creates a new Color3 from the string containing valid hexadecimal values
  13533. * @param hex defines a string containing valid hexadecimal values
  13534. * @returns a new Color3 object
  13535. */
  13536. static FromHexString(hex: string): Color3;
  13537. /**
  13538. * Creates a new Vector3 from the starting index of the given array
  13539. * @param array defines the source array
  13540. * @param offset defines an offset in the source array
  13541. * @returns a new Color3 object
  13542. */
  13543. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  13544. /**
  13545. * Creates a new Color3 from integer values (< 256)
  13546. * @param r defines the red component to read from (value between 0 and 255)
  13547. * @param g defines the green component to read from (value between 0 and 255)
  13548. * @param b defines the blue component to read from (value between 0 and 255)
  13549. * @returns a new Color3 object
  13550. */
  13551. static FromInts(r: number, g: number, b: number): Color3;
  13552. /**
  13553. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  13554. * @param start defines the start Color3 value
  13555. * @param end defines the end Color3 value
  13556. * @param amount defines the gradient value between start and end
  13557. * @returns a new Color3 object
  13558. */
  13559. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  13560. /**
  13561. * Returns a Color3 value containing a red color
  13562. * @returns a new Color3 object
  13563. */
  13564. static Red(): Color3;
  13565. /**
  13566. * Returns a Color3 value containing a green color
  13567. * @returns a new Color3 object
  13568. */
  13569. static Green(): Color3;
  13570. /**
  13571. * Returns a Color3 value containing a blue color
  13572. * @returns a new Color3 object
  13573. */
  13574. static Blue(): Color3;
  13575. /**
  13576. * Returns a Color3 value containing a black color
  13577. * @returns a new Color3 object
  13578. */
  13579. static Black(): Color3;
  13580. /**
  13581. * Returns a Color3 value containing a white color
  13582. * @returns a new Color3 object
  13583. */
  13584. static White(): Color3;
  13585. /**
  13586. * Returns a Color3 value containing a purple color
  13587. * @returns a new Color3 object
  13588. */
  13589. static Purple(): Color3;
  13590. /**
  13591. * Returns a Color3 value containing a magenta color
  13592. * @returns a new Color3 object
  13593. */
  13594. static Magenta(): Color3;
  13595. /**
  13596. * Returns a Color3 value containing a yellow color
  13597. * @returns a new Color3 object
  13598. */
  13599. static Yellow(): Color3;
  13600. /**
  13601. * Returns a Color3 value containing a gray color
  13602. * @returns a new Color3 object
  13603. */
  13604. static Gray(): Color3;
  13605. /**
  13606. * Returns a Color3 value containing a teal color
  13607. * @returns a new Color3 object
  13608. */
  13609. static Teal(): Color3;
  13610. /**
  13611. * Returns a Color3 value containing a random color
  13612. * @returns a new Color3 object
  13613. */
  13614. static Random(): Color3;
  13615. }
  13616. /**
  13617. * Class used to hold a RBGA color
  13618. */
  13619. class Color4 {
  13620. /**
  13621. * Defines the red component (between 0 and 1, default is 0)
  13622. */
  13623. r: number;
  13624. /**
  13625. * Defines the green component (between 0 and 1, default is 0)
  13626. */
  13627. g: number;
  13628. /**
  13629. * Defines the blue component (between 0 and 1, default is 0)
  13630. */
  13631. b: number;
  13632. /**
  13633. * Defines the alpha component (between 0 and 1, default is 1)
  13634. */
  13635. a: number;
  13636. /**
  13637. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  13638. * @param r defines the red component (between 0 and 1, default is 0)
  13639. * @param g defines the green component (between 0 and 1, default is 0)
  13640. * @param b defines the blue component (between 0 and 1, default is 0)
  13641. * @param a defines the alpha component (between 0 and 1, default is 1)
  13642. */
  13643. constructor(
  13644. /**
  13645. * Defines the red component (between 0 and 1, default is 0)
  13646. */
  13647. r?: number,
  13648. /**
  13649. * Defines the green component (between 0 and 1, default is 0)
  13650. */
  13651. g?: number,
  13652. /**
  13653. * Defines the blue component (between 0 and 1, default is 0)
  13654. */
  13655. b?: number,
  13656. /**
  13657. * Defines the alpha component (between 0 and 1, default is 1)
  13658. */
  13659. a?: number);
  13660. /**
  13661. * Adds in place the given Color4 values to the current Color4 object
  13662. * @param right defines the second operand
  13663. * @returns the current updated Color4 object
  13664. */
  13665. addInPlace(right: Color4): Color4;
  13666. /**
  13667. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  13668. * @returns the new array
  13669. */
  13670. asArray(): number[];
  13671. /**
  13672. * Stores from the starting index in the given array the Color4 successive values
  13673. * @param array defines the array where to store the r,g,b components
  13674. * @param index defines an optional index in the target array to define where to start storing values
  13675. * @returns the current Color4 object
  13676. */
  13677. toArray(array: number[], index?: number): Color4;
  13678. /**
  13679. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  13680. * @param right defines the second operand
  13681. * @returns a new Color4 object
  13682. */
  13683. add(right: Color4): Color4;
  13684. /**
  13685. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  13686. * @param right defines the second operand
  13687. * @returns a new Color4 object
  13688. */
  13689. subtract(right: Color4): Color4;
  13690. /**
  13691. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  13692. * @param right defines the second operand
  13693. * @param result defines the Color4 object where to store the result
  13694. * @returns the current Color4 object
  13695. */
  13696. subtractToRef(right: Color4, result: Color4): Color4;
  13697. /**
  13698. * Creates a new Color4 with the current Color4 values multiplied by scale
  13699. * @param scale defines the scaling factor to apply
  13700. * @returns a new Color4 object
  13701. */
  13702. scale(scale: number): Color4;
  13703. /**
  13704. * Multiplies the current Color4 values by scale and stores the result in "result"
  13705. * @param scale defines the scaling factor to apply
  13706. * @param result defines the Color4 object where to store the result
  13707. * @returns the current unmodified Color4
  13708. */
  13709. scaleToRef(scale: number, result: Color4): Color4;
  13710. /**
  13711. * Scale the current Color4 values by a factor and add the result to a given Color4
  13712. * @param scale defines the scale factor
  13713. * @param result defines the Color4 object where to store the result
  13714. * @returns the unmodified current Color4
  13715. */
  13716. scaleAndAddToRef(scale: number, result: Color4): Color4;
  13717. /**
  13718. * Clamps the rgb values by the min and max values and stores the result into "result"
  13719. * @param min defines minimum clamping value (default is 0)
  13720. * @param max defines maximum clamping value (default is 1)
  13721. * @param result defines color to store the result into.
  13722. * @returns the cuurent Color4
  13723. */
  13724. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  13725. /**
  13726. * Multipy an Color4 value by another and return a new Color4 object
  13727. * @param color defines the Color4 value to multiply by
  13728. * @returns a new Color4 object
  13729. */
  13730. multiply(color: Color4): Color4;
  13731. /**
  13732. * Multipy a Color4 value by another and push the result in a reference value
  13733. * @param color defines the Color4 value to multiply by
  13734. * @param result defines the Color4 to fill the result in
  13735. * @returns the result Color4
  13736. */
  13737. multiplyToRef(color: Color4, result: Color4): Color4;
  13738. /**
  13739. * Creates a string with the Color4 current values
  13740. * @returns the string representation of the Color4 object
  13741. */
  13742. toString(): string;
  13743. /**
  13744. * Returns the string "Color4"
  13745. * @returns "Color4"
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Compute the Color4 hash code
  13750. * @returns an unique number that can be used to hash Color4 objects
  13751. */
  13752. getHashCode(): number;
  13753. /**
  13754. * Creates a new Color4 copied from the current one
  13755. * @returns a new Color4 object
  13756. */
  13757. clone(): Color4;
  13758. /**
  13759. * Copies the given Color4 values into the current one
  13760. * @param source defines the source Color4 object
  13761. * @returns the current updated Color4 object
  13762. */
  13763. copyFrom(source: Color4): Color4;
  13764. /**
  13765. * Copies the given float values into the current one
  13766. * @param r defines the red component to read from
  13767. * @param g defines the green component to read from
  13768. * @param b defines the blue component to read from
  13769. * @param a defines the alpha component to read from
  13770. * @returns the current updated Color4 object
  13771. */
  13772. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  13773. /**
  13774. * Copies the given float values into the current one
  13775. * @param r defines the red component to read from
  13776. * @param g defines the green component to read from
  13777. * @param b defines the blue component to read from
  13778. * @param a defines the alpha component to read from
  13779. * @returns the current updated Color4 object
  13780. */
  13781. set(r: number, g: number, b: number, a: number): Color4;
  13782. /**
  13783. * Compute the Color4 hexadecimal code as a string
  13784. * @returns a string containing the hexadecimal representation of the Color4 object
  13785. */
  13786. toHexString(): string;
  13787. /**
  13788. * Computes a new Color4 converted from the current one to linear space
  13789. * @returns a new Color4 object
  13790. */
  13791. toLinearSpace(): Color4;
  13792. /**
  13793. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  13794. * @param convertedColor defines the Color4 object where to store the linear space version
  13795. * @returns the unmodified Color4
  13796. */
  13797. toLinearSpaceToRef(convertedColor: Color4): Color4;
  13798. /**
  13799. * Computes a new Color4 converted from the current one to gamma space
  13800. * @returns a new Color4 object
  13801. */
  13802. toGammaSpace(): Color4;
  13803. /**
  13804. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  13805. * @param convertedColor defines the Color4 object where to store the gamma space version
  13806. * @returns the unmodified Color4
  13807. */
  13808. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13809. /**
  13810. * Creates a new Color4 from the string containing valid hexadecimal values
  13811. * @param hex defines a string containing valid hexadecimal values
  13812. * @returns a new Color4 object
  13813. */
  13814. static FromHexString(hex: string): Color4;
  13815. /**
  13816. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13817. * @param left defines the start value
  13818. * @param right defines the end value
  13819. * @param amount defines the gradient factor
  13820. * @returns a new Color4 object
  13821. */
  13822. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13823. /**
  13824. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13825. * @param left defines the start value
  13826. * @param right defines the end value
  13827. * @param amount defines the gradient factor
  13828. * @param result defines the Color4 object where to store data
  13829. */
  13830. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13831. /**
  13832. * Creates a new Color4 from the starting index element of the given array
  13833. * @param array defines the source array to read from
  13834. * @param offset defines the offset in the source array
  13835. * @returns a new Color4 object
  13836. */
  13837. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13838. /**
  13839. * Creates a new Color3 from integer values (< 256)
  13840. * @param r defines the red component to read from (value between 0 and 255)
  13841. * @param g defines the green component to read from (value between 0 and 255)
  13842. * @param b defines the blue component to read from (value between 0 and 255)
  13843. * @param a defines the alpha component to read from (value between 0 and 255)
  13844. * @returns a new Color3 object
  13845. */
  13846. static FromInts(r: number, g: number, b: number, a: number): Color4;
  13847. /**
  13848. * Check the content of a given array and convert it to an array containing RGBA data
  13849. * If the original array was already containing count * 4 values then it is returned directly
  13850. * @param colors defines the array to check
  13851. * @param count defines the number of RGBA data to expect
  13852. * @returns an array containing count * 4 values (RGBA)
  13853. */
  13854. static CheckColors4(colors: number[], count: number): number[];
  13855. }
  13856. /**
  13857. * Class representing a vector containing 2 coordinates
  13858. */
  13859. class Vector2 {
  13860. /** defines the first coordinate */
  13861. x: number;
  13862. /** defines the second coordinate */
  13863. y: number;
  13864. /**
  13865. * Creates a new Vector2 from the given x and y coordinates
  13866. * @param x defines the first coordinate
  13867. * @param y defines the second coordinate
  13868. */
  13869. constructor(
  13870. /** defines the first coordinate */
  13871. x?: number,
  13872. /** defines the second coordinate */
  13873. y?: number);
  13874. /**
  13875. * Gets a string with the Vector2 coordinates
  13876. * @returns a string with the Vector2 coordinates
  13877. */
  13878. toString(): string;
  13879. /**
  13880. * Gets class name
  13881. * @returns the string "Vector2"
  13882. */
  13883. getClassName(): string;
  13884. /**
  13885. * Gets current vector hash code
  13886. * @returns the Vector2 hash code as a number
  13887. */
  13888. getHashCode(): number;
  13889. /**
  13890. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  13891. * @param array defines the source array
  13892. * @param index defines the offset in source array
  13893. * @returns the current Vector2
  13894. */
  13895. toArray(array: FloatArray, index?: number): Vector2;
  13896. /**
  13897. * Copy the current vector to an array
  13898. * @returns a new array with 2 elements: the Vector2 coordinates.
  13899. */
  13900. asArray(): number[];
  13901. /**
  13902. * Sets the Vector2 coordinates with the given Vector2 coordinates
  13903. * @param source defines the source Vector2
  13904. * @returns the current updated Vector2
  13905. */
  13906. copyFrom(source: Vector2): Vector2;
  13907. /**
  13908. * Sets the Vector2 coordinates with the given floats
  13909. * @param x defines the first coordinate
  13910. * @param y defines the second coordinate
  13911. * @returns the current updated Vector2
  13912. */
  13913. copyFromFloats(x: number, y: number): Vector2;
  13914. /**
  13915. * Sets the Vector2 coordinates with the given floats
  13916. * @param x defines the first coordinate
  13917. * @param y defines the second coordinate
  13918. * @returns the current updated Vector2
  13919. */
  13920. set(x: number, y: number): Vector2;
  13921. /**
  13922. * Add another vector with the current one
  13923. * @param otherVector defines the other vector
  13924. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  13925. */
  13926. add(otherVector: Vector2): Vector2;
  13927. /**
  13928. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  13929. * @param otherVector defines the other vector
  13930. * @param result defines the target vector
  13931. * @returns the unmodified current Vector2
  13932. */
  13933. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13934. /**
  13935. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  13936. * @param otherVector defines the other vector
  13937. * @returns the current updated Vector2
  13938. */
  13939. addInPlace(otherVector: Vector2): Vector2;
  13940. /**
  13941. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  13942. * @param otherVector defines the other vector
  13943. * @returns a new Vector2
  13944. */
  13945. addVector3(otherVector: Vector3): Vector2;
  13946. /**
  13947. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  13948. * @param otherVector defines the other vector
  13949. * @returns a new Vector2
  13950. */
  13951. subtract(otherVector: Vector2): Vector2;
  13952. /**
  13953. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  13954. * @param otherVector defines the other vector
  13955. * @param result defines the target vector
  13956. * @returns the unmodified current Vector2
  13957. */
  13958. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13959. /**
  13960. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  13961. * @param otherVector defines the other vector
  13962. * @returns the current updated Vector2
  13963. */
  13964. subtractInPlace(otherVector: Vector2): Vector2;
  13965. /**
  13966. * Multiplies in place the current Vector2 coordinates by the given ones
  13967. * @param otherVector defines the other vector
  13968. * @returns the current updated Vector2
  13969. */
  13970. multiplyInPlace(otherVector: Vector2): Vector2;
  13971. /**
  13972. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  13973. * @param otherVector defines the other vector
  13974. * @returns a new Vector2
  13975. */
  13976. multiply(otherVector: Vector2): Vector2;
  13977. /**
  13978. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  13979. * @param otherVector defines the other vector
  13980. * @param result defines the target vector
  13981. * @returns the unmodified current Vector2
  13982. */
  13983. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13984. /**
  13985. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  13986. * @param x defines the first coordinate
  13987. * @param y defines the second coordinate
  13988. * @returns a new Vector2
  13989. */
  13990. multiplyByFloats(x: number, y: number): Vector2;
  13991. /**
  13992. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  13993. * @param otherVector defines the other vector
  13994. * @returns a new Vector2
  13995. */
  13996. divide(otherVector: Vector2): Vector2;
  13997. /**
  13998. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  13999. * @param otherVector defines the other vector
  14000. * @param result defines the target vector
  14001. * @returns the unmodified current Vector2
  14002. */
  14003. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  14004. /**
  14005. * Divides the current Vector2 coordinates by the given ones
  14006. * @param otherVector defines the other vector
  14007. * @returns the current updated Vector2
  14008. */
  14009. divideInPlace(otherVector: Vector2): Vector2;
  14010. /**
  14011. * Gets a new Vector2 with current Vector2 negated coordinates
  14012. * @returns a new Vector2
  14013. */
  14014. negate(): Vector2;
  14015. /**
  14016. * Multiply the Vector2 coordinates by scale
  14017. * @param scale defines the scaling factor
  14018. * @returns the current updated Vector2
  14019. */
  14020. scaleInPlace(scale: number): Vector2;
  14021. /**
  14022. * Returns a new Vector2 scaled by "scale" from the current Vector2
  14023. * @param scale defines the scaling factor
  14024. * @returns a new Vector2
  14025. */
  14026. scale(scale: number): Vector2;
  14027. /**
  14028. * Scale the current Vector2 values by a factor to a given Vector2
  14029. * @param scale defines the scale factor
  14030. * @param result defines the Vector2 object where to store the result
  14031. * @returns the unmodified current Vector2
  14032. */
  14033. scaleToRef(scale: number, result: Vector2): Vector2;
  14034. /**
  14035. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  14036. * @param scale defines the scale factor
  14037. * @param result defines the Vector2 object where to store the result
  14038. * @returns the unmodified current Vector2
  14039. */
  14040. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  14041. /**
  14042. * Gets a boolean if two vectors are equals
  14043. * @param otherVector defines the other vector
  14044. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  14045. */
  14046. equals(otherVector: Vector2): boolean;
  14047. /**
  14048. * Gets a boolean if two vectors are equals (using an epsilon value)
  14049. * @param otherVector defines the other vector
  14050. * @param epsilon defines the minimal distance to consider equality
  14051. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  14052. */
  14053. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  14054. /**
  14055. * Gets a new Vector2 from current Vector2 floored values
  14056. * @returns a new Vector2
  14057. */
  14058. floor(): Vector2;
  14059. /**
  14060. * Gets a new Vector2 from current Vector2 floored values
  14061. * @returns a new Vector2
  14062. */
  14063. fract(): Vector2;
  14064. /**
  14065. * Gets the length of the vector
  14066. * @returns the vector length (float)
  14067. */
  14068. length(): number;
  14069. /**
  14070. * Gets the vector squared length
  14071. * @returns the vector squared length (float)
  14072. */
  14073. lengthSquared(): number;
  14074. /**
  14075. * Normalize the vector
  14076. * @returns the current updated Vector2
  14077. */
  14078. normalize(): Vector2;
  14079. /**
  14080. * Gets a new Vector2 copied from the Vector2
  14081. * @returns a new Vector2
  14082. */
  14083. clone(): Vector2;
  14084. /**
  14085. * Gets a new Vector2(0, 0)
  14086. * @returns a new Vector2
  14087. */
  14088. static Zero(): Vector2;
  14089. /**
  14090. * Gets a new Vector2(1, 1)
  14091. * @returns a new Vector2
  14092. */
  14093. static One(): Vector2;
  14094. /**
  14095. * Gets a new Vector2 set from the given index element of the given array
  14096. * @param array defines the data source
  14097. * @param offset defines the offset in the data source
  14098. * @returns a new Vector2
  14099. */
  14100. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  14101. /**
  14102. * Sets "result" from the given index element of the given array
  14103. * @param array defines the data source
  14104. * @param offset defines the offset in the data source
  14105. * @param result defines the target vector
  14106. */
  14107. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  14108. /**
  14109. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  14110. * @param value1 defines 1st point of control
  14111. * @param value2 defines 2nd point of control
  14112. * @param value3 defines 3rd point of control
  14113. * @param value4 defines 4th point of control
  14114. * @param amount defines the interpolation factor
  14115. * @returns a new Vector2
  14116. */
  14117. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  14118. /**
  14119. * 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".
  14120. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  14121. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  14122. * @param value defines the value to clamp
  14123. * @param min defines the lower limit
  14124. * @param max defines the upper limit
  14125. * @returns a new Vector2
  14126. */
  14127. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  14128. /**
  14129. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  14130. * @param value1 defines the 1st control point
  14131. * @param tangent1 defines the outgoing tangent
  14132. * @param value2 defines the 2nd control point
  14133. * @param tangent2 defines the incoming tangent
  14134. * @param amount defines the interpolation factor
  14135. * @returns a new Vector2
  14136. */
  14137. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  14138. /**
  14139. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  14140. * @param start defines the start vector
  14141. * @param end defines the end vector
  14142. * @param amount defines the interpolation factor
  14143. * @returns a new Vector2
  14144. */
  14145. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  14146. /**
  14147. * Gets the dot product of the vector "left" and the vector "right"
  14148. * @param left defines first vector
  14149. * @param right defines second vector
  14150. * @returns the dot product (float)
  14151. */
  14152. static Dot(left: Vector2, right: Vector2): number;
  14153. /**
  14154. * Returns a new Vector2 equal to the normalized given vector
  14155. * @param vector defines the vector to normalize
  14156. * @returns a new Vector2
  14157. */
  14158. static Normalize(vector: Vector2): Vector2;
  14159. /**
  14160. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  14161. * @param left defines 1st vector
  14162. * @param right defines 2nd vector
  14163. * @returns a new Vector2
  14164. */
  14165. static Minimize(left: Vector2, right: Vector2): Vector2;
  14166. /**
  14167. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  14168. * @param left defines 1st vector
  14169. * @param right defines 2nd vector
  14170. * @returns a new Vector2
  14171. */
  14172. static Maximize(left: Vector2, right: Vector2): Vector2;
  14173. /**
  14174. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  14175. * @param vector defines the vector to transform
  14176. * @param transformation defines the matrix to apply
  14177. * @returns a new Vector2
  14178. */
  14179. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  14180. /**
  14181. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  14182. * @param vector defines the vector to transform
  14183. * @param transformation defines the matrix to apply
  14184. * @param result defines the target vector
  14185. */
  14186. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  14187. /**
  14188. * Determines if a given vector is included in a triangle
  14189. * @param p defines the vector to test
  14190. * @param p0 defines 1st triangle point
  14191. * @param p1 defines 2nd triangle point
  14192. * @param p2 defines 3rd triangle point
  14193. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  14194. */
  14195. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  14196. /**
  14197. * Gets the distance between the vectors "value1" and "value2"
  14198. * @param value1 defines first vector
  14199. * @param value2 defines second vector
  14200. * @returns the distance between vectors
  14201. */
  14202. static Distance(value1: Vector2, value2: Vector2): number;
  14203. /**
  14204. * Returns the squared distance between the vectors "value1" and "value2"
  14205. * @param value1 defines first vector
  14206. * @param value2 defines second vector
  14207. * @returns the squared distance between vectors
  14208. */
  14209. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  14210. /**
  14211. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  14212. * @param value1 defines first vector
  14213. * @param value2 defines second vector
  14214. * @returns a new Vector2
  14215. */
  14216. static Center(value1: Vector2, value2: Vector2): Vector2;
  14217. /**
  14218. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  14219. * @param p defines the middle point
  14220. * @param segA defines one point of the segment
  14221. * @param segB defines the other point of the segment
  14222. * @returns the shortest distance
  14223. */
  14224. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  14225. }
  14226. /**
  14227. * Classed used to store (x,y,z) vector representation
  14228. * A Vector3 is the main object used in 3D geometry
  14229. * It can represent etiher the coordinates of a point the space, either a direction
  14230. * Reminder: Babylon.js uses a left handed forward facing system
  14231. */
  14232. class Vector3 {
  14233. /**
  14234. * Defines the first coordinates (on X axis)
  14235. */
  14236. x: number;
  14237. /**
  14238. * Defines the second coordinates (on Y axis)
  14239. */
  14240. y: number;
  14241. /**
  14242. * Defines the third coordinates (on Z axis)
  14243. */
  14244. z: number;
  14245. /**
  14246. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  14247. * @param x defines the first coordinates (on X axis)
  14248. * @param y defines the second coordinates (on Y axis)
  14249. * @param z defines the third coordinates (on Z axis)
  14250. */
  14251. constructor(
  14252. /**
  14253. * Defines the first coordinates (on X axis)
  14254. */
  14255. x?: number,
  14256. /**
  14257. * Defines the second coordinates (on Y axis)
  14258. */
  14259. y?: number,
  14260. /**
  14261. * Defines the third coordinates (on Z axis)
  14262. */
  14263. z?: number);
  14264. /**
  14265. * Creates a string representation of the Vector3
  14266. * @returns a string with the Vector3 coordinates.
  14267. */
  14268. toString(): string;
  14269. /**
  14270. * Gets the class name
  14271. * @returns the string "Vector3"
  14272. */
  14273. getClassName(): string;
  14274. /**
  14275. * Creates the Vector3 hash code
  14276. * @returns a number which tends to be unique between Vector3 instances
  14277. */
  14278. getHashCode(): number;
  14279. /**
  14280. * Creates an array containing three elements : the coordinates of the Vector3
  14281. * @returns a new array of numbers
  14282. */
  14283. asArray(): number[];
  14284. /**
  14285. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  14286. * @param array defines the destination array
  14287. * @param index defines the offset in the destination array
  14288. * @returns the current Vector3
  14289. */
  14290. toArray(array: FloatArray, index?: number): Vector3;
  14291. /**
  14292. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  14293. * @returns a new Quaternion object, computed from the Vector3 coordinates
  14294. */
  14295. toQuaternion(): Quaternion;
  14296. /**
  14297. * Adds the given vector to the current Vector3
  14298. * @param otherVector defines the second operand
  14299. * @returns the current updated Vector3
  14300. */
  14301. addInPlace(otherVector: Vector3): Vector3;
  14302. /**
  14303. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  14304. * @param otherVector defines the second operand
  14305. * @returns the resulting Vector3
  14306. */
  14307. add(otherVector: Vector3): Vector3;
  14308. /**
  14309. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  14310. * @param otherVector defines the second operand
  14311. * @param result defines the Vector3 object where to store the result
  14312. * @returns the current Vector3
  14313. */
  14314. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  14315. /**
  14316. * Subtract the given vector from the current Vector3
  14317. * @param otherVector defines the second operand
  14318. * @returns the current updated Vector3
  14319. */
  14320. subtractInPlace(otherVector: Vector3): Vector3;
  14321. /**
  14322. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  14323. * @param otherVector defines the second operand
  14324. * @returns the resulting Vector3
  14325. */
  14326. subtract(otherVector: Vector3): Vector3;
  14327. /**
  14328. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  14329. * @param otherVector defines the second operand
  14330. * @param result defines the Vector3 object where to store the result
  14331. * @returns the current Vector3
  14332. */
  14333. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  14334. /**
  14335. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  14336. * @param x defines the x coordinate of the operand
  14337. * @param y defines the y coordinate of the operand
  14338. * @param z defines the z coordinate of the operand
  14339. * @returns the resulting Vector3
  14340. */
  14341. subtractFromFloats(x: number, y: number, z: number): Vector3;
  14342. /**
  14343. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  14344. * @param x defines the x coordinate of the operand
  14345. * @param y defines the y coordinate of the operand
  14346. * @param z defines the z coordinate of the operand
  14347. * @param result defines the Vector3 object where to store the result
  14348. * @returns the current Vector3
  14349. */
  14350. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  14351. /**
  14352. * Gets a new Vector3 set with the current Vector3 negated coordinates
  14353. * @returns a new Vector3
  14354. */
  14355. negate(): Vector3;
  14356. /**
  14357. * Multiplies the Vector3 coordinates by the float "scale"
  14358. * @param scale defines the multiplier factor
  14359. * @returns the current updated Vector3
  14360. */
  14361. scaleInPlace(scale: number): Vector3;
  14362. /**
  14363. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  14364. * @param scale defines the multiplier factor
  14365. * @returns a new Vector3
  14366. */
  14367. scale(scale: number): Vector3;
  14368. /**
  14369. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  14370. * @param scale defines the multiplier factor
  14371. * @param result defines the Vector3 object where to store the result
  14372. * @returns the current Vector3
  14373. */
  14374. scaleToRef(scale: number, result: Vector3): Vector3;
  14375. /**
  14376. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  14377. * @param scale defines the scale factor
  14378. * @param result defines the Vector3 object where to store the result
  14379. * @returns the unmodified current Vector3
  14380. */
  14381. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  14382. /**
  14383. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  14384. * @param otherVector defines the second operand
  14385. * @returns true if both vectors are equals
  14386. */
  14387. equals(otherVector: Vector3): boolean;
  14388. /**
  14389. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  14390. * @param otherVector defines the second operand
  14391. * @param epsilon defines the minimal distance to define values as equals
  14392. * @returns true if both vectors are distant less than epsilon
  14393. */
  14394. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  14395. /**
  14396. * Returns true if the current Vector3 coordinates equals the given floats
  14397. * @param x defines the x coordinate of the operand
  14398. * @param y defines the y coordinate of the operand
  14399. * @param z defines the z coordinate of the operand
  14400. * @returns true if both vectors are equals
  14401. */
  14402. equalsToFloats(x: number, y: number, z: number): boolean;
  14403. /**
  14404. * Multiplies the current Vector3 coordinates by the given ones
  14405. * @param otherVector defines the second operand
  14406. * @returns the current updated Vector3
  14407. */
  14408. multiplyInPlace(otherVector: Vector3): Vector3;
  14409. /**
  14410. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  14411. * @param otherVector defines the second operand
  14412. * @returns the new Vector3
  14413. */
  14414. multiply(otherVector: Vector3): Vector3;
  14415. /**
  14416. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  14417. * @param otherVector defines the second operand
  14418. * @param result defines the Vector3 object where to store the result
  14419. * @returns the current Vector3
  14420. */
  14421. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  14422. /**
  14423. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  14424. * @param x defines the x coordinate of the operand
  14425. * @param y defines the y coordinate of the operand
  14426. * @param z defines the z coordinate of the operand
  14427. * @returns the new Vector3
  14428. */
  14429. multiplyByFloats(x: number, y: number, z: number): Vector3;
  14430. /**
  14431. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  14432. * @param otherVector defines the second operand
  14433. * @returns the new Vector3
  14434. */
  14435. divide(otherVector: Vector3): Vector3;
  14436. /**
  14437. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  14438. * @param otherVector defines the second operand
  14439. * @param result defines the Vector3 object where to store the result
  14440. * @returns the current Vector3
  14441. */
  14442. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  14443. /**
  14444. * Divides the current Vector3 coordinates by the given ones.
  14445. * @param otherVector defines the second operand
  14446. * @returns the current updated Vector3
  14447. */
  14448. divideInPlace(otherVector: Vector3): Vector3;
  14449. /**
  14450. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  14451. * @param other defines the second operand
  14452. * @returns the current updated Vector3
  14453. */
  14454. minimizeInPlace(other: Vector3): Vector3;
  14455. /**
  14456. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  14457. * @param other defines the second operand
  14458. * @returns the current updated Vector3
  14459. */
  14460. maximizeInPlace(other: Vector3): Vector3;
  14461. /**
  14462. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  14463. */
  14464. readonly isNonUniform: boolean;
  14465. /**
  14466. * Gets a new Vector3 from current Vector3 floored values
  14467. * @returns a new Vector3
  14468. */
  14469. floor(): Vector3;
  14470. /**
  14471. * Gets a new Vector3 from current Vector3 floored values
  14472. * @returns a new Vector3
  14473. */
  14474. fract(): Vector3;
  14475. /**
  14476. * Gets the length of the Vector3
  14477. * @returns the length of the Vecto3
  14478. */
  14479. length(): number;
  14480. /**
  14481. * Gets the squared length of the Vector3
  14482. * @returns squared length of the Vector3
  14483. */
  14484. lengthSquared(): number;
  14485. /**
  14486. * Normalize the current Vector3.
  14487. * Please note that this is an in place operation.
  14488. * @returns the current updated Vector3
  14489. */
  14490. normalize(): Vector3;
  14491. /**
  14492. * Normalize the current Vector3 to a new vector
  14493. * @returns the new Vector3
  14494. */
  14495. normalizeToNew(): Vector3;
  14496. /**
  14497. * Normalize the current Vector3 to the reference
  14498. * @param reference define the Vector3 to update
  14499. * @returns the updated Vector3
  14500. */
  14501. normalizeToRef(reference: Vector3): Vector3;
  14502. /**
  14503. * Creates a new Vector3 copied from the current Vector3
  14504. * @returns the new Vector3
  14505. */
  14506. clone(): Vector3;
  14507. /**
  14508. * Copies the given vector coordinates to the current Vector3 ones
  14509. * @param source defines the source Vector3
  14510. * @returns the current updated Vector3
  14511. */
  14512. copyFrom(source: Vector3): Vector3;
  14513. /**
  14514. * Copies the given floats to the current Vector3 coordinates
  14515. * @param x defines the x coordinate of the operand
  14516. * @param y defines the y coordinate of the operand
  14517. * @param z defines the z coordinate of the operand
  14518. * @returns the current updated Vector3
  14519. */
  14520. copyFromFloats(x: number, y: number, z: number): Vector3;
  14521. /**
  14522. * Copies the given floats to the current Vector3 coordinates
  14523. * @param x defines the x coordinate of the operand
  14524. * @param y defines the y coordinate of the operand
  14525. * @param z defines the z coordinate of the operand
  14526. * @returns the current updated Vector3
  14527. */
  14528. set(x: number, y: number, z: number): Vector3;
  14529. /**
  14530. * Get the clip factor between two vectors
  14531. * @param vector0 defines the first operand
  14532. * @param vector1 defines the second operand
  14533. * @param axis defines the axis to use
  14534. * @param size defines the size along the axis
  14535. * @returns the clip factor
  14536. */
  14537. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  14538. /**
  14539. * Get angle between two vectors
  14540. * @param vector0 angle between vector0 and vector1
  14541. * @param vector1 angle between vector0 and vector1
  14542. * @param normal direction of the normal
  14543. * @return the angle between vector0 and vector1
  14544. */
  14545. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  14546. /**
  14547. * Returns a new Vector3 set from the index "offset" of the given array
  14548. * @param array defines the source array
  14549. * @param offset defines the offset in the source array
  14550. * @returns the new Vector3
  14551. */
  14552. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  14553. /**
  14554. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  14555. * This function is deprecated. Use FromArray instead
  14556. * @param array defines the source array
  14557. * @param offset defines the offset in the source array
  14558. * @returns the new Vector3
  14559. */
  14560. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  14561. /**
  14562. * Sets the given vector "result" with the element values from the index "offset" of the given array
  14563. * @param array defines the source array
  14564. * @param offset defines the offset in the source array
  14565. * @param result defines the Vector3 where to store the result
  14566. */
  14567. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  14568. /**
  14569. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  14570. * This function is deprecated. Use FromArrayToRef instead.
  14571. * @param array defines the source array
  14572. * @param offset defines the offset in the source array
  14573. * @param result defines the Vector3 where to store the result
  14574. */
  14575. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  14576. /**
  14577. * Sets the given vector "result" with the given floats.
  14578. * @param x defines the x coordinate of the source
  14579. * @param y defines the y coordinate of the source
  14580. * @param z defines the z coordinate of the source
  14581. * @param result defines the Vector3 where to store the result
  14582. */
  14583. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  14584. /**
  14585. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  14586. * @returns a new empty Vector3
  14587. */
  14588. static Zero(): Vector3;
  14589. /**
  14590. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  14591. * @returns a new unit Vector3
  14592. */
  14593. static One(): Vector3;
  14594. /**
  14595. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  14596. * @returns a new up Vector3
  14597. */
  14598. static Up(): Vector3;
  14599. /**
  14600. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  14601. * @returns a new down Vector3
  14602. */
  14603. static Down(): Vector3;
  14604. /**
  14605. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  14606. * @returns a new forward Vector3
  14607. */
  14608. static Forward(): Vector3;
  14609. /**
  14610. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  14611. * @returns a new right Vector3
  14612. */
  14613. static Right(): Vector3;
  14614. /**
  14615. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  14616. * @returns a new left Vector3
  14617. */
  14618. static Left(): Vector3;
  14619. /**
  14620. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  14621. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14622. * @param vector defines the Vector3 to transform
  14623. * @param transformation defines the transformation matrix
  14624. * @returns the transformed Vector3
  14625. */
  14626. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  14627. /**
  14628. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  14629. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14630. * @param vector defines the Vector3 to transform
  14631. * @param transformation defines the transformation matrix
  14632. * @param result defines the Vector3 where to store the result
  14633. */
  14634. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14635. /**
  14636. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  14637. * This method computes tranformed coordinates only, not transformed direction vectors
  14638. * @param x define the x coordinate of the source vector
  14639. * @param y define the y coordinate of the source vector
  14640. * @param z define the z coordinate of the source vector
  14641. * @param transformation defines the transformation matrix
  14642. * @param result defines the Vector3 where to store the result
  14643. */
  14644. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14645. /**
  14646. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  14647. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14648. * @param vector defines the Vector3 to transform
  14649. * @param transformation defines the transformation matrix
  14650. * @returns the new Vector3
  14651. */
  14652. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  14653. /**
  14654. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  14655. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14656. * @param vector defines the Vector3 to transform
  14657. * @param transformation defines the transformation matrix
  14658. * @param result defines the Vector3 where to store the result
  14659. */
  14660. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14661. /**
  14662. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  14663. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14664. * @param x define the x coordinate of the source vector
  14665. * @param y define the y coordinate of the source vector
  14666. * @param z define the z coordinate of the source vector
  14667. * @param transformation defines the transformation matrix
  14668. * @param result defines the Vector3 where to store the result
  14669. */
  14670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14671. /**
  14672. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  14673. * @param value1 defines the first control point
  14674. * @param value2 defines the second control point
  14675. * @param value3 defines the third control point
  14676. * @param value4 defines the fourth control point
  14677. * @param amount defines the amount on the spline to use
  14678. * @returns the new Vector3
  14679. */
  14680. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  14681. /**
  14682. * 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"
  14683. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  14684. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  14685. * @param value defines the current value
  14686. * @param min defines the lower range value
  14687. * @param max defines the upper range value
  14688. * @returns the new Vector3
  14689. */
  14690. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  14691. /**
  14692. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  14693. * @param value1 defines the first control point
  14694. * @param tangent1 defines the first tangent vector
  14695. * @param value2 defines the second control point
  14696. * @param tangent2 defines the second tangent vector
  14697. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  14698. * @returns the new Vector3
  14699. */
  14700. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  14701. /**
  14702. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  14703. * @param start defines the start value
  14704. * @param end defines the end value
  14705. * @param amount max defines amount between both (between 0 and 1)
  14706. * @returns the new Vector3
  14707. */
  14708. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  14709. /**
  14710. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  14711. * @param start defines the start value
  14712. * @param end defines the end value
  14713. * @param amount max defines amount between both (between 0 and 1)
  14714. * @param result defines the Vector3 where to store the result
  14715. */
  14716. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  14717. /**
  14718. * Returns the dot product (float) between the vectors "left" and "right"
  14719. * @param left defines the left operand
  14720. * @param right defines the right operand
  14721. * @returns the dot product
  14722. */
  14723. static Dot(left: Vector3, right: Vector3): number;
  14724. /**
  14725. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  14726. * The cross product is then orthogonal to both "left" and "right"
  14727. * @param left defines the left operand
  14728. * @param right defines the right operand
  14729. * @returns the cross product
  14730. */
  14731. static Cross(left: Vector3, right: Vector3): Vector3;
  14732. /**
  14733. * Sets the given vector "result" with the cross product of "left" and "right"
  14734. * The cross product is then orthogonal to both "left" and "right"
  14735. * @param left defines the left operand
  14736. * @param right defines the right operand
  14737. * @param result defines the Vector3 where to store the result
  14738. */
  14739. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  14740. /**
  14741. * Returns a new Vector3 as the normalization of the given vector
  14742. * @param vector defines the Vector3 to normalize
  14743. * @returns the new Vector3
  14744. */
  14745. static Normalize(vector: Vector3): Vector3;
  14746. /**
  14747. * Sets the given vector "result" with the normalization of the given first vector
  14748. * @param vector defines the Vector3 to normalize
  14749. * @param result defines the Vector3 where to store the result
  14750. */
  14751. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  14752. private static _viewportMatrixCache;
  14753. /**
  14754. * Project a Vector3 onto screen space
  14755. * @param vector defines the Vector3 to project
  14756. * @param world defines the world matrix to use
  14757. * @param transform defines the transform (view x projection) matrix to use
  14758. * @param viewport defines the screen viewport to use
  14759. * @returns the new Vector3
  14760. */
  14761. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  14762. /**
  14763. * Unproject from screen space to object space
  14764. * @param source defines the screen space Vector3 to use
  14765. * @param viewportWidth defines the current width of the viewport
  14766. * @param viewportHeight defines the current height of the viewport
  14767. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14768. * @param transform defines the transform (view x projection) matrix to use
  14769. * @returns the new Vector3
  14770. */
  14771. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  14772. /**
  14773. * Unproject from screen space to object space
  14774. * @param source defines the screen space Vector3 to use
  14775. * @param viewportWidth defines the current width of the viewport
  14776. * @param viewportHeight defines the current height of the viewport
  14777. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14778. * @param view defines the view matrix to use
  14779. * @param projection defines the projection matrix to use
  14780. * @returns the new Vector3
  14781. */
  14782. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  14783. /**
  14784. * Unproject from screen space to object space
  14785. * @param source defines the screen space Vector3 to use
  14786. * @param viewportWidth defines the current width of the viewport
  14787. * @param viewportHeight defines the current height of the viewport
  14788. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14789. * @param view defines the view matrix to use
  14790. * @param projection defines the projection matrix to use
  14791. * @param result defines the Vector3 where to store the result
  14792. */
  14793. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14794. /**
  14795. * Unproject from screen space to object space
  14796. * @param sourceX defines the screen space x coordinate to use
  14797. * @param sourceY defines the screen space y coordinate to use
  14798. * @param sourceZ defines the screen space z coordinate to use
  14799. * @param viewportWidth defines the current width of the viewport
  14800. * @param viewportHeight defines the current height of the viewport
  14801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14802. * @param view defines the view matrix to use
  14803. * @param projection defines the projection matrix to use
  14804. * @param result defines the Vector3 where to store the result
  14805. */
  14806. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14807. /**
  14808. * Gets the minimal coordinate values between two Vector3
  14809. * @param left defines the first operand
  14810. * @param right defines the second operand
  14811. * @returns the new Vector3
  14812. */
  14813. static Minimize(left: Vector3, right: Vector3): Vector3;
  14814. /**
  14815. * Gets the maximal coordinate values between two Vector3
  14816. * @param left defines the first operand
  14817. * @param right defines the second operand
  14818. * @returns the new Vector3
  14819. */
  14820. static Maximize(left: Vector3, right: Vector3): Vector3;
  14821. /**
  14822. * Returns the distance between the vectors "value1" and "value2"
  14823. * @param value1 defines the first operand
  14824. * @param value2 defines the second operand
  14825. * @returns the distance
  14826. */
  14827. static Distance(value1: Vector3, value2: Vector3): number;
  14828. /**
  14829. * Returns the squared distance between the vectors "value1" and "value2"
  14830. * @param value1 defines the first operand
  14831. * @param value2 defines the second operand
  14832. * @returns the squared distance
  14833. */
  14834. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14835. /**
  14836. * Returns a new Vector3 located at the center between "value1" and "value2"
  14837. * @param value1 defines the first operand
  14838. * @param value2 defines the second operand
  14839. * @returns the new Vector3
  14840. */
  14841. static Center(value1: Vector3, value2: Vector3): Vector3;
  14842. /**
  14843. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14844. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14845. * to something in order to rotate it from its local system to the given target system
  14846. * Note: axis1, axis2 and axis3 are normalized during this operation
  14847. * @param axis1 defines the first axis
  14848. * @param axis2 defines the second axis
  14849. * @param axis3 defines the third axis
  14850. * @returns a new Vector3
  14851. */
  14852. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14853. /**
  14854. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  14855. * @param axis1 defines the first axis
  14856. * @param axis2 defines the second axis
  14857. * @param axis3 defines the third axis
  14858. * @param ref defines the Vector3 where to store the result
  14859. */
  14860. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14861. }
  14862. class Vector4 {
  14863. x: number;
  14864. y: number;
  14865. z: number;
  14866. w: number;
  14867. /**
  14868. * Creates a Vector4 object from the given floats.
  14869. */
  14870. constructor(x: number, y: number, z: number, w: number);
  14871. /**
  14872. * Returns the string with the Vector4 coordinates.
  14873. */
  14874. toString(): string;
  14875. /**
  14876. * Returns the string "Vector4".
  14877. */
  14878. getClassName(): string;
  14879. /**
  14880. * Returns the Vector4 hash code.
  14881. */
  14882. getHashCode(): number;
  14883. /**
  14884. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14885. */
  14886. asArray(): number[];
  14887. /**
  14888. * Populates the given array from the given index with the Vector4 coordinates.
  14889. * Returns the Vector4.
  14890. */
  14891. toArray(array: FloatArray, index?: number): Vector4;
  14892. /**
  14893. * Adds the given vector to the current Vector4.
  14894. * Returns the updated Vector4.
  14895. */
  14896. addInPlace(otherVector: Vector4): Vector4;
  14897. /**
  14898. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  14899. */
  14900. add(otherVector: Vector4): Vector4;
  14901. /**
  14902. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  14903. * Returns the current Vector4.
  14904. */
  14905. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14906. /**
  14907. * Subtract in place the given vector from the current Vector4.
  14908. * Returns the updated Vector4.
  14909. */
  14910. subtractInPlace(otherVector: Vector4): Vector4;
  14911. /**
  14912. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  14913. */
  14914. subtract(otherVector: Vector4): Vector4;
  14915. /**
  14916. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  14917. * Returns the current Vector4.
  14918. */
  14919. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14920. /**
  14921. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14922. */
  14923. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14924. /**
  14925. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14926. * Returns the current Vector4.
  14927. */
  14928. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14929. /**
  14930. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14931. */
  14932. negate(): Vector4;
  14933. /**
  14934. * Multiplies the current Vector4 coordinates by scale (float).
  14935. * Returns the updated Vector4.
  14936. */
  14937. scaleInPlace(scale: number): Vector4;
  14938. /**
  14939. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14940. */
  14941. scale(scale: number): Vector4;
  14942. /**
  14943. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14944. * Returns the current Vector4.
  14945. */
  14946. scaleToRef(scale: number, result: Vector4): Vector4;
  14947. /**
  14948. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14949. * @param scale defines the scale factor
  14950. * @param result defines the Vector4 object where to store the result
  14951. * @returns the unmodified current Vector4
  14952. */
  14953. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14954. /**
  14955. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  14956. */
  14957. equals(otherVector: Vector4): boolean;
  14958. /**
  14959. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  14960. */
  14961. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14962. /**
  14963. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  14964. */
  14965. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14966. /**
  14967. * Multiplies in place the current Vector4 by the given one.
  14968. * Returns the updated Vector4.
  14969. */
  14970. multiplyInPlace(otherVector: Vector4): Vector4;
  14971. /**
  14972. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  14973. */
  14974. multiply(otherVector: Vector4): Vector4;
  14975. /**
  14976. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  14977. * Returns the current Vector4.
  14978. */
  14979. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14980. /**
  14981. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  14982. */
  14983. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14984. /**
  14985. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  14986. */
  14987. divide(otherVector: Vector4): Vector4;
  14988. /**
  14989. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  14990. * Returns the current Vector4.
  14991. */
  14992. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  14993. /**
  14994. * Divides the current Vector3 coordinates by the given ones.
  14995. * @returns the updated Vector3.
  14996. */
  14997. divideInPlace(otherVector: Vector4): Vector4;
  14998. /**
  14999. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  15000. * @param other defines the second operand
  15001. * @returns the current updated Vector4
  15002. */
  15003. minimizeInPlace(other: Vector4): Vector4;
  15004. /**
  15005. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  15006. * @param other defines the second operand
  15007. * @returns the current updated Vector4
  15008. */
  15009. maximizeInPlace(other: Vector4): Vector4;
  15010. /**
  15011. * Gets a new Vector4 from current Vector4 floored values
  15012. * @returns a new Vector4
  15013. */
  15014. floor(): Vector4;
  15015. /**
  15016. * Gets a new Vector4 from current Vector3 floored values
  15017. * @returns a new Vector4
  15018. */
  15019. fract(): Vector4;
  15020. /**
  15021. * Returns the Vector4 length (float).
  15022. */
  15023. length(): number;
  15024. /**
  15025. * Returns the Vector4 squared length (float).
  15026. */
  15027. lengthSquared(): number;
  15028. /**
  15029. * Normalizes in place the Vector4.
  15030. * Returns the updated Vector4.
  15031. */
  15032. normalize(): Vector4;
  15033. /**
  15034. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  15035. */
  15036. toVector3(): Vector3;
  15037. /**
  15038. * Returns a new Vector4 copied from the current one.
  15039. */
  15040. clone(): Vector4;
  15041. /**
  15042. * Updates the current Vector4 with the given one coordinates.
  15043. * Returns the updated Vector4.
  15044. */
  15045. copyFrom(source: Vector4): Vector4;
  15046. /**
  15047. * Updates the current Vector4 coordinates with the given floats.
  15048. * Returns the updated Vector4.
  15049. */
  15050. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15051. /**
  15052. * Updates the current Vector4 coordinates with the given floats.
  15053. * Returns the updated Vector4.
  15054. */
  15055. set(x: number, y: number, z: number, w: number): Vector4;
  15056. /**
  15057. * Returns a new Vector4 set from the starting index of the given array.
  15058. */
  15059. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  15060. /**
  15061. * Updates the given vector "result" from the starting index of the given array.
  15062. */
  15063. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  15064. /**
  15065. * Updates the given vector "result" from the starting index of the given Float32Array.
  15066. */
  15067. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  15068. /**
  15069. * Updates the given vector "result" coordinates from the given floats.
  15070. */
  15071. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  15072. /**
  15073. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  15074. */
  15075. static Zero(): Vector4;
  15076. /**
  15077. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  15078. */
  15079. static One(): Vector4;
  15080. /**
  15081. * Returns a new normalized Vector4 from the given one.
  15082. */
  15083. static Normalize(vector: Vector4): Vector4;
  15084. /**
  15085. * Updates the given vector "result" from the normalization of the given one.
  15086. */
  15087. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  15088. static Minimize(left: Vector4, right: Vector4): Vector4;
  15089. static Maximize(left: Vector4, right: Vector4): Vector4;
  15090. /**
  15091. * Returns the distance (float) between the vectors "value1" and "value2".
  15092. */
  15093. static Distance(value1: Vector4, value2: Vector4): number;
  15094. /**
  15095. * Returns the squared distance (float) between the vectors "value1" and "value2".
  15096. */
  15097. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  15098. /**
  15099. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  15100. */
  15101. static Center(value1: Vector4, value2: Vector4): Vector4;
  15102. /**
  15103. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  15104. * This methods computes transformed normalized direction vectors only.
  15105. */
  15106. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  15107. /**
  15108. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  15109. * This methods computes transformed normalized direction vectors only.
  15110. */
  15111. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  15112. /**
  15113. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  15114. * This methods computes transformed normalized direction vectors only.
  15115. */
  15116. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  15117. }
  15118. interface ISize {
  15119. width: number;
  15120. height: number;
  15121. }
  15122. class Size implements ISize {
  15123. width: number;
  15124. height: number;
  15125. /**
  15126. * Creates a Size object from the given width and height (floats).
  15127. */
  15128. constructor(width: number, height: number);
  15129. toString(): string;
  15130. /**
  15131. * Returns the string "Size"
  15132. */
  15133. getClassName(): string;
  15134. /**
  15135. * Returns the Size hash code.
  15136. */
  15137. getHashCode(): number;
  15138. /**
  15139. * Updates the current size from the given one.
  15140. * Returns the updated Size.
  15141. */
  15142. copyFrom(src: Size): void;
  15143. /**
  15144. * Updates in place the current Size from the given floats.
  15145. * Returns the updated Size.
  15146. */
  15147. copyFromFloats(width: number, height: number): Size;
  15148. /**
  15149. * Updates in place the current Size from the given floats.
  15150. * Returns the updated Size.
  15151. */
  15152. set(width: number, height: number): Size;
  15153. /**
  15154. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  15155. */
  15156. multiplyByFloats(w: number, h: number): Size;
  15157. /**
  15158. * Returns a new Size copied from the given one.
  15159. */
  15160. clone(): Size;
  15161. /**
  15162. * Boolean : True if the current Size and the given one width and height are strictly equal.
  15163. */
  15164. equals(other: Size): boolean;
  15165. /**
  15166. * Returns the surface of the Size : width * height (float).
  15167. */
  15168. readonly surface: number;
  15169. /**
  15170. * Returns a new Size set to (0.0, 0.0)
  15171. */
  15172. static Zero(): Size;
  15173. /**
  15174. * Returns a new Size set as the addition result of the current Size and the given one.
  15175. */
  15176. add(otherSize: Size): Size;
  15177. /**
  15178. * Returns a new Size set as the subtraction result of the given one from the current Size.
  15179. */
  15180. subtract(otherSize: Size): Size;
  15181. /**
  15182. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  15183. */
  15184. static Lerp(start: Size, end: Size, amount: number): Size;
  15185. }
  15186. /**
  15187. * Class used to store quaternion data
  15188. * @see https://en.wikipedia.org/wiki/Quaternion
  15189. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  15190. */
  15191. class Quaternion {
  15192. /** defines the first component (0 by default) */
  15193. x: number;
  15194. /** defines the second component (0 by default) */
  15195. y: number;
  15196. /** defines the third component (0 by default) */
  15197. z: number;
  15198. /** defines the fourth component (1.0 by default) */
  15199. w: number;
  15200. /**
  15201. * Creates a new Quaternion from the given floats
  15202. * @param x defines the first component (0 by default)
  15203. * @param y defines the second component (0 by default)
  15204. * @param z defines the third component (0 by default)
  15205. * @param w defines the fourth component (1.0 by default)
  15206. */
  15207. constructor(
  15208. /** defines the first component (0 by default) */
  15209. x?: number,
  15210. /** defines the second component (0 by default) */
  15211. y?: number,
  15212. /** defines the third component (0 by default) */
  15213. z?: number,
  15214. /** defines the fourth component (1.0 by default) */
  15215. w?: number);
  15216. /**
  15217. * Gets a string representation for the current quaternion
  15218. * @returns a string with the Quaternion coordinates
  15219. */
  15220. toString(): string;
  15221. /**
  15222. * Gets the class name of the quaternion
  15223. * @returns the string "Quaternion"
  15224. */
  15225. getClassName(): string;
  15226. /**
  15227. * Gets a hash code for this quaternion
  15228. * @returns the quaternion hash code
  15229. */
  15230. getHashCode(): number;
  15231. /**
  15232. * Copy the quaternion to an array
  15233. * @returns a new array populated with 4 elements from the quaternion coordinates
  15234. */
  15235. asArray(): number[];
  15236. /**
  15237. * Check if two quaternions are equals
  15238. * @param otherQuaternion defines the second operand
  15239. * @return true if the current quaternion and the given one coordinates are strictly equals
  15240. */
  15241. equals(otherQuaternion: Quaternion): boolean;
  15242. /**
  15243. * Clone the current quaternion
  15244. * @returns a new quaternion copied from the current one
  15245. */
  15246. clone(): Quaternion;
  15247. /**
  15248. * Copy a quaternion to the current one
  15249. * @param other defines the other quaternion
  15250. * @returns the updated current quaternion
  15251. */
  15252. copyFrom(other: Quaternion): Quaternion;
  15253. /**
  15254. * Updates the current quaternion with the given float coordinates
  15255. * @param x defines the x coordinate
  15256. * @param y defines the y coordinate
  15257. * @param z defines the z coordinate
  15258. * @param w defines the w coordinate
  15259. * @returns the updated current quaternion
  15260. */
  15261. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  15262. /**
  15263. * Updates the current quaternion from the given float coordinates
  15264. * @param x defines the x coordinate
  15265. * @param y defines the y coordinate
  15266. * @param z defines the z coordinate
  15267. * @param w defines the w coordinate
  15268. * @returns the updated current quaternion
  15269. */
  15270. set(x: number, y: number, z: number, w: number): Quaternion;
  15271. /**
  15272. * Adds two quaternions
  15273. * @param other defines the second operand
  15274. * @returns a new quaternion as the addition result of the given one and the current quaternion
  15275. */
  15276. add(other: Quaternion): Quaternion;
  15277. /**
  15278. * Add a quaternion to the current one
  15279. * @param other defines the quaternion to add
  15280. * @returns the current quaternion
  15281. */
  15282. addInPlace(other: Quaternion): Quaternion;
  15283. /**
  15284. * Subtract two quaternions
  15285. * @param other defines the second operand
  15286. * @returns a new quaternion as the subtraction result of the given one from the current one
  15287. */
  15288. subtract(other: Quaternion): Quaternion;
  15289. /**
  15290. * Multiplies the current quaternion by a scale factor
  15291. * @param value defines the scale factor
  15292. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  15293. */
  15294. scale(value: number): Quaternion;
  15295. /**
  15296. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  15297. * @param scale defines the scale factor
  15298. * @param result defines the Quaternion object where to store the result
  15299. * @returns the unmodified current quaternion
  15300. */
  15301. scaleToRef(scale: number, result: Quaternion): Quaternion;
  15302. /**
  15303. * Multiplies in place the current quaternion by a scale factor
  15304. * @param value defines the scale factor
  15305. * @returns the current modified quaternion
  15306. */
  15307. scaleInPlace(value: number): Quaternion;
  15308. /**
  15309. * Scale the current quaternion values by a factor and add the result to a given quaternion
  15310. * @param scale defines the scale factor
  15311. * @param result defines the Quaternion object where to store the result
  15312. * @returns the unmodified current quaternion
  15313. */
  15314. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  15315. /**
  15316. * Multiplies two quaternions
  15317. * @param q1 defines the second operand
  15318. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  15319. */
  15320. multiply(q1: Quaternion): Quaternion;
  15321. /**
  15322. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  15323. * @param q1 defines the second operand
  15324. * @param result defines the target quaternion
  15325. * @returns the current quaternion
  15326. */
  15327. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  15328. /**
  15329. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  15330. * @param q1 defines the second operand
  15331. * @returns the currentupdated quaternion
  15332. */
  15333. multiplyInPlace(q1: Quaternion): Quaternion;
  15334. /**
  15335. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  15336. * @param ref defines the target quaternion
  15337. * @returns the current quaternion
  15338. */
  15339. conjugateToRef(ref: Quaternion): Quaternion;
  15340. /**
  15341. * Conjugates in place (1-q) the current quaternion
  15342. * @returns the current updated quaternion
  15343. */
  15344. conjugateInPlace(): Quaternion;
  15345. /**
  15346. * Conjugates in place (1-q) the current quaternion
  15347. * @returns a new quaternion
  15348. */
  15349. conjugate(): Quaternion;
  15350. /**
  15351. * Gets length of current quaternion
  15352. * @returns the quaternion length (float)
  15353. */
  15354. length(): number;
  15355. /**
  15356. * Normalize in place the current quaternion
  15357. * @returns the current updated quaternion
  15358. */
  15359. normalize(): Quaternion;
  15360. /**
  15361. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  15362. * @param order is a reserved parameter and is ignore for now
  15363. * @returns a new Vector3 containing the Euler angles
  15364. */
  15365. toEulerAngles(order?: string): Vector3;
  15366. /**
  15367. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  15368. * @param result defines the vector which will be filled with the Euler angles
  15369. * @param order is a reserved parameter and is ignore for now
  15370. * @returns the current unchanged quaternion
  15371. */
  15372. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  15373. /**
  15374. * Updates the given rotation matrix with the current quaternion values
  15375. * @param result defines the target matrix
  15376. * @returns the current unchanged quaternion
  15377. */
  15378. toRotationMatrix(result: Matrix): Quaternion;
  15379. /**
  15380. * Updates the current quaternion from the given rotation matrix values
  15381. * @param matrix defines the source matrix
  15382. * @returns the current updated quaternion
  15383. */
  15384. fromRotationMatrix(matrix: Matrix): Quaternion;
  15385. /**
  15386. * Creates a new quaternion from a rotation matrix
  15387. * @param matrix defines the source matrix
  15388. * @returns a new quaternion created from the given rotation matrix values
  15389. */
  15390. static FromRotationMatrix(matrix: Matrix): Quaternion;
  15391. /**
  15392. * Updates the given quaternion with the given rotation matrix values
  15393. * @param matrix defines the source matrix
  15394. * @param result defines the target quaternion
  15395. */
  15396. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  15397. /**
  15398. * Returns the dot product (float) between the quaternions "left" and "right"
  15399. * @param left defines the left operand
  15400. * @param right defines the right operand
  15401. * @returns the dot product
  15402. */
  15403. static Dot(left: Quaternion, right: Quaternion): number;
  15404. /**
  15405. * Checks if the two quaternions are close to each other
  15406. * @param quat0 defines the first quaternion to check
  15407. * @param quat1 defines the second quaternion to check
  15408. * @returns true if the two quaternions are close to each other
  15409. */
  15410. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  15411. /**
  15412. * Creates an empty quaternion
  15413. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  15414. */
  15415. static Zero(): Quaternion;
  15416. /**
  15417. * Inverse a given quaternion
  15418. * @param q defines the source quaternion
  15419. * @returns a new quaternion as the inverted current quaternion
  15420. */
  15421. static Inverse(q: Quaternion): Quaternion;
  15422. /**
  15423. * Creates an identity quaternion
  15424. * @returns the identity quaternion
  15425. */
  15426. static Identity(): Quaternion;
  15427. /**
  15428. * Gets a boolean indicating if the given quaternion is identity
  15429. * @param quaternion defines the quaternion to check
  15430. * @returns true if the quaternion is identity
  15431. */
  15432. static IsIdentity(quaternion: Quaternion): boolean;
  15433. /**
  15434. * Creates a quaternion from a rotation around an axis
  15435. * @param axis defines the axis to use
  15436. * @param angle defines the angle to use
  15437. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  15438. */
  15439. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  15440. /**
  15441. * Creates a rotation around an axis and stores it into the given quaternion
  15442. * @param axis defines the axis to use
  15443. * @param angle defines the angle to use
  15444. * @param result defines the target quaternion
  15445. * @returns the target quaternion
  15446. */
  15447. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  15448. /**
  15449. * Creates a new quaternion from data stored into an array
  15450. * @param array defines the data source
  15451. * @param offset defines the offset in the source array where the data starts
  15452. * @returns a new quaternion
  15453. */
  15454. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  15455. /**
  15456. * Creates a new quaternion from the given Euler float angles (y, x, z)
  15457. * @param yaw defines the rotation around Y axis
  15458. * @param pitch defines the rotation around X axis
  15459. * @param roll defines the rotation around Z axis
  15460. * @returns the new quaternion
  15461. */
  15462. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  15463. /**
  15464. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  15465. * @param yaw defines the rotation around Y axis
  15466. * @param pitch defines the rotation around X axis
  15467. * @param roll defines the rotation around Z axis
  15468. * @param result defines the target quaternion
  15469. */
  15470. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  15471. /**
  15472. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  15473. * @param alpha defines the rotation around first axis
  15474. * @param beta defines the rotation around second axis
  15475. * @param gamma defines the rotation around third axis
  15476. * @returns the new quaternion
  15477. */
  15478. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  15479. /**
  15480. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  15481. * @param alpha defines the rotation around first axis
  15482. * @param beta defines the rotation around second axis
  15483. * @param gamma defines the rotation around third axis
  15484. * @param result defines the target quaternion
  15485. */
  15486. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  15487. /**
  15488. * 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)
  15489. * @param axis1 defines the first axis
  15490. * @param axis2 defines the second axis
  15491. * @param axis3 defines the third axis
  15492. * @returns the new quaternion
  15493. */
  15494. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  15495. /**
  15496. * 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
  15497. * @param axis1 defines the first axis
  15498. * @param axis2 defines the second axis
  15499. * @param axis3 defines the third axis
  15500. * @param ref defines the target quaternion
  15501. */
  15502. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  15503. /**
  15504. * Interpolates between two quaternions
  15505. * @param left defines first quaternion
  15506. * @param right defines second quaternion
  15507. * @param amount defines the gradient to use
  15508. * @returns the new interpolated quaternion
  15509. */
  15510. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  15511. /**
  15512. * Interpolates between two quaternions and stores it into a target quaternion
  15513. * @param left defines first quaternion
  15514. * @param right defines second quaternion
  15515. * @param amount defines the gradient to use
  15516. * @param result defines the target quaternion
  15517. */
  15518. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  15519. /**
  15520. * Interpolate between two quaternions using Hermite interpolation
  15521. * @param value1 defines first quaternion
  15522. * @param tangent1 defines the incoming tangent
  15523. * @param value2 defines second quaternion
  15524. * @param tangent2 defines the outgoing tangent
  15525. * @param amount defines the target quaternion
  15526. * @returns the new interpolated quaternion
  15527. */
  15528. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  15529. }
  15530. /**
  15531. * Class used to store matrix data (4x4)
  15532. */
  15533. class Matrix {
  15534. private static _tempQuaternion;
  15535. private static _xAxis;
  15536. private static _yAxis;
  15537. private static _zAxis;
  15538. private static _updateFlagSeed;
  15539. private static _identityReadOnly;
  15540. private _isIdentity;
  15541. private _isIdentityDirty;
  15542. /**
  15543. * Gets the update flag of the matrix which is an unique number for the matrix.
  15544. * It will be incremented every time the matrix data change.
  15545. * You can use it to speed the comparison between two versions of the same matrix.
  15546. */
  15547. updateFlag: number;
  15548. /**
  15549. * Gets or sets the internal data of the matrix
  15550. */
  15551. m: Float32Array;
  15552. /** @hidden */
  15553. _markAsUpdated(): void;
  15554. /**
  15555. * Creates an empty matrix (filled with zeros)
  15556. */
  15557. constructor();
  15558. /**
  15559. * Check if the current matrix is indentity
  15560. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  15561. * @returns true is the matrix is the identity matrix
  15562. */
  15563. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  15564. /**
  15565. * Gets the determinant of the matrix
  15566. * @returns the matrix determinant
  15567. */
  15568. determinant(): number;
  15569. /**
  15570. * Returns the matrix as a Float32Array
  15571. * @returns the matrix underlying array
  15572. */
  15573. toArray(): Float32Array;
  15574. /**
  15575. * Returns the matrix as a Float32Array
  15576. * @returns the matrix underlying array.
  15577. */
  15578. asArray(): Float32Array;
  15579. /**
  15580. * Inverts the current matrix in place
  15581. * @returns the current inverted matrix
  15582. */
  15583. invert(): Matrix;
  15584. /**
  15585. * Sets all the matrix elements to zero
  15586. * @returns the current matrix
  15587. */
  15588. reset(): Matrix;
  15589. /**
  15590. * Adds the current matrix with a second one
  15591. * @param other defines the matrix to add
  15592. * @returns a new matrix as the addition of the current matrix and the given one
  15593. */
  15594. add(other: Matrix): Matrix;
  15595. /**
  15596. * Sets the given matrix "result" to the addition of the current matrix and the given one
  15597. * @param other defines the matrix to add
  15598. * @param result defines the target matrix
  15599. * @returns the current matrix
  15600. */
  15601. addToRef(other: Matrix, result: Matrix): Matrix;
  15602. /**
  15603. * Adds in place the given matrix to the current matrix
  15604. * @param other defines the second operand
  15605. * @returns the current updated matrix
  15606. */
  15607. addToSelf(other: Matrix): Matrix;
  15608. /**
  15609. * Sets the given matrix to the current inverted Matrix
  15610. * @param other defines the target matrix
  15611. * @returns the unmodified current matrix
  15612. */
  15613. invertToRef(other: Matrix): Matrix;
  15614. /**
  15615. * Inserts the translation vector (using 3 floats) in the current matrix
  15616. * @param x defines the 1st component of the translation
  15617. * @param y defines the 2nd component of the translation
  15618. * @param z defines the 3rd component of the translation
  15619. * @returns the current updated matrix
  15620. */
  15621. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  15622. /**
  15623. * Inserts the translation vector in the current matrix
  15624. * @param vector3 defines the translation to insert
  15625. * @returns the current updated matrix
  15626. */
  15627. setTranslation(vector3: Vector3): Matrix;
  15628. /**
  15629. * Gets the translation value of the current matrix
  15630. * @returns a new Vector3 as the extracted translation from the matrix
  15631. */
  15632. getTranslation(): Vector3;
  15633. /**
  15634. * Fill a Vector3 with the extracted translation from the matrix
  15635. * @param result defines the Vector3 where to store the translation
  15636. * @returns the current matrix
  15637. */
  15638. getTranslationToRef(result: Vector3): Matrix;
  15639. /**
  15640. * Remove rotation and scaling part from the matrix
  15641. * @returns the updated matrix
  15642. */
  15643. removeRotationAndScaling(): Matrix;
  15644. /**
  15645. * Multiply two matrices
  15646. * @param other defines the second operand
  15647. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  15648. */
  15649. multiply(other: Matrix): Matrix;
  15650. /**
  15651. * Copy the current matrix from the given one
  15652. * @param other defines the source matrix
  15653. * @returns the current updated matrix
  15654. */
  15655. copyFrom(other: Matrix): Matrix;
  15656. /**
  15657. * Populates the given array from the starting index with the current matrix values
  15658. * @param array defines the target array
  15659. * @param offset defines the offset in the target array where to start storing values
  15660. * @returns the current matrix
  15661. */
  15662. copyToArray(array: Float32Array, offset?: number): Matrix;
  15663. /**
  15664. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  15665. * @param other defines the second operand
  15666. * @param result defines the matrix where to store the multiplication
  15667. * @returns the current matrix
  15668. */
  15669. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  15670. /**
  15671. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  15672. * @param other defines the second operand
  15673. * @param result defines the array where to store the multiplication
  15674. * @param offset defines the offset in the target array where to start storing values
  15675. * @returns the current matrix
  15676. */
  15677. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  15678. /**
  15679. * Check equality between this matrix and a second one
  15680. * @param value defines the second matrix to compare
  15681. * @returns true is the current matrix and the given one values are strictly equal
  15682. */
  15683. equals(value: Matrix): boolean;
  15684. /**
  15685. * Clone the current matrix
  15686. * @returns a new matrix from the current matrix
  15687. */
  15688. clone(): Matrix;
  15689. /**
  15690. * Returns the name of the current matrix class
  15691. * @returns the string "Matrix"
  15692. */
  15693. getClassName(): string;
  15694. /**
  15695. * Gets the hash code of the current matrix
  15696. * @returns the hash code
  15697. */
  15698. getHashCode(): number;
  15699. /**
  15700. * Decomposes the current Matrix into a translation, rotation and scaling components
  15701. * @param scale defines the scale vector3 given as a reference to update
  15702. * @param rotation defines the rotation quaternion given as a reference to update
  15703. * @param translation defines the translation vector3 given as a reference to update
  15704. * @returns true if operation was successful
  15705. */
  15706. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  15707. /**
  15708. * Gets specific row of the matrix
  15709. * @param index defines the number of the row to get
  15710. * @returns the index-th row of the current matrix as a new Vector4
  15711. */
  15712. getRow(index: number): Nullable<Vector4>;
  15713. /**
  15714. * Sets the index-th row of the current matrix to the vector4 values
  15715. * @param index defines the number of the row to set
  15716. * @param row defines the target vector4
  15717. * @returns the updated current matrix
  15718. */
  15719. setRow(index: number, row: Vector4): Matrix;
  15720. /**
  15721. * Compute the transpose of the matrix
  15722. * @returns the new transposed matrix
  15723. */
  15724. transpose(): Matrix;
  15725. /**
  15726. * Compute the transpose of the matrix and store it in a given matrix
  15727. * @param result defines the target matrix
  15728. * @returns the current matrix
  15729. */
  15730. transposeToRef(result: Matrix): Matrix;
  15731. /**
  15732. * Sets the index-th row of the current matrix with the given 4 x float values
  15733. * @param index defines the row index
  15734. * @param x defines the x component to set
  15735. * @param y defines the y component to set
  15736. * @param z defines the z component to set
  15737. * @param w defines the w component to set
  15738. * @returns the updated current matrix
  15739. */
  15740. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  15741. /**
  15742. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  15743. * @param scale defines the scale factor
  15744. * @returns a new matrix
  15745. */
  15746. scale(scale: number): Matrix;
  15747. /**
  15748. * Scale the current matrix values by a factor to a given result matrix
  15749. * @param scale defines the scale factor
  15750. * @param result defines the matrix to store the result
  15751. * @returns the current matrix
  15752. */
  15753. scaleToRef(scale: number, result: Matrix): Matrix;
  15754. /**
  15755. * Scale the current matrix values by a factor and add the result to a given matrix
  15756. * @param scale defines the scale factor
  15757. * @param result defines the Matrix to store the result
  15758. * @returns the current matrix
  15759. */
  15760. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  15761. /**
  15762. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  15763. * @param ref matrix to store the result
  15764. */
  15765. toNormalMatrix(ref: Matrix): void;
  15766. /**
  15767. * Gets only rotation part of the current matrix
  15768. * @returns a new matrix sets to the extracted rotation matrix from the current one
  15769. */
  15770. getRotationMatrix(): Matrix;
  15771. /**
  15772. * Extracts the rotation matrix from the current one and sets it as the given "result"
  15773. * @param result defines the target matrix to store data to
  15774. * @returns the current matrix
  15775. */
  15776. getRotationMatrixToRef(result: Matrix): Matrix;
  15777. /**
  15778. * Creates a matrix from an array
  15779. * @param array defines the source array
  15780. * @param offset defines an offset in the source array
  15781. * @returns a new Matrix set from the starting index of the given array
  15782. */
  15783. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  15784. /**
  15785. * Copy the content of an array into a given matrix
  15786. * @param array defines the source array
  15787. * @param offset defines an offset in the source array
  15788. * @param result defines the target matrix
  15789. */
  15790. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  15791. /**
  15792. * Stores an array into a matrix after having multiplied each component by a given factor
  15793. * @param array defines the source array
  15794. * @param offset defines the offset in the source array
  15795. * @param scale defines the scaling factor
  15796. * @param result defines the target matrix
  15797. */
  15798. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  15799. /**
  15800. * Stores a list of values (16) inside a given matrix
  15801. * @param initialM11 defines 1st value of 1st row
  15802. * @param initialM12 defines 2nd value of 1st row
  15803. * @param initialM13 defines 3rd value of 1st row
  15804. * @param initialM14 defines 4th value of 1st row
  15805. * @param initialM21 defines 1st value of 2nd row
  15806. * @param initialM22 defines 2nd value of 2nd row
  15807. * @param initialM23 defines 3rd value of 2nd row
  15808. * @param initialM24 defines 4th value of 2nd row
  15809. * @param initialM31 defines 1st value of 3rd row
  15810. * @param initialM32 defines 2nd value of 3rd row
  15811. * @param initialM33 defines 3rd value of 3rd row
  15812. * @param initialM34 defines 4th value of 3rd row
  15813. * @param initialM41 defines 1st value of 4th row
  15814. * @param initialM42 defines 2nd value of 4th row
  15815. * @param initialM43 defines 3rd value of 4th row
  15816. * @param initialM44 defines 4th value of 4th row
  15817. * @param result defines the target matrix
  15818. */
  15819. 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;
  15820. /**
  15821. * Gets an identity matrix that must not be updated
  15822. */
  15823. static readonly IdentityReadOnly: Matrix;
  15824. /**
  15825. * Creates new matrix from a list of values (16)
  15826. * @param initialM11 defines 1st value of 1st row
  15827. * @param initialM12 defines 2nd value of 1st row
  15828. * @param initialM13 defines 3rd value of 1st row
  15829. * @param initialM14 defines 4th value of 1st row
  15830. * @param initialM21 defines 1st value of 2nd row
  15831. * @param initialM22 defines 2nd value of 2nd row
  15832. * @param initialM23 defines 3rd value of 2nd row
  15833. * @param initialM24 defines 4th value of 2nd row
  15834. * @param initialM31 defines 1st value of 3rd row
  15835. * @param initialM32 defines 2nd value of 3rd row
  15836. * @param initialM33 defines 3rd value of 3rd row
  15837. * @param initialM34 defines 4th value of 3rd row
  15838. * @param initialM41 defines 1st value of 4th row
  15839. * @param initialM42 defines 2nd value of 4th row
  15840. * @param initialM43 defines 3rd value of 4th row
  15841. * @param initialM44 defines 4th value of 4th row
  15842. * @returns the new matrix
  15843. */
  15844. 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;
  15845. /**
  15846. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15847. * @param scale defines the scale vector3
  15848. * @param rotation defines the rotation quaternion
  15849. * @param translation defines the translation vector3
  15850. * @returns a new matrix
  15851. */
  15852. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  15853. /**
  15854. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15855. * @param scale defines the scale vector3
  15856. * @param rotation defines the rotation quaternion
  15857. * @param translation defines the translation vector3
  15858. * @param result defines the target matrix
  15859. */
  15860. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  15861. /**
  15862. * Creates a new identity matrix
  15863. * @returns a new identity matrix
  15864. */
  15865. static Identity(): Matrix;
  15866. /**
  15867. * Creates a new identity matrix and stores the result in a given matrix
  15868. * @param result defines the target matrix
  15869. */
  15870. static IdentityToRef(result: Matrix): void;
  15871. /**
  15872. * Creates a new zero matrix
  15873. * @returns a new zero matrix
  15874. */
  15875. static Zero(): Matrix;
  15876. /**
  15877. * Creates a new rotation matrix for "angle" radians around the X axis
  15878. * @param angle defines the angle (in radians) to use
  15879. * @return the new matrix
  15880. */
  15881. static RotationX(angle: number): Matrix;
  15882. /**
  15883. * Creates a new matrix as the invert of a given matrix
  15884. * @param source defines the source matrix
  15885. * @returns the new matrix
  15886. */
  15887. static Invert(source: Matrix): Matrix;
  15888. /**
  15889. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  15890. * @param angle defines the angle (in radians) to use
  15891. * @param result defines the target matrix
  15892. */
  15893. static RotationXToRef(angle: number, result: Matrix): void;
  15894. /**
  15895. * Creates a new rotation matrix for "angle" radians around the Y axis
  15896. * @param angle defines the angle (in radians) to use
  15897. * @return the new matrix
  15898. */
  15899. static RotationY(angle: number): Matrix;
  15900. /**
  15901. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  15902. * @param angle defines the angle (in radians) to use
  15903. * @param result defines the target matrix
  15904. */
  15905. static RotationYToRef(angle: number, result: Matrix): void;
  15906. /**
  15907. * Creates a new rotation matrix for "angle" radians around the Z axis
  15908. * @param angle defines the angle (in radians) to use
  15909. * @return the new matrix
  15910. */
  15911. static RotationZ(angle: number): Matrix;
  15912. /**
  15913. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  15914. * @param angle defines the angle (in radians) to use
  15915. * @param result defines the target matrix
  15916. */
  15917. static RotationZToRef(angle: number, result: Matrix): void;
  15918. /**
  15919. * Creates a new rotation matrix for "angle" radians around the given axis
  15920. * @param axis defines the axis to use
  15921. * @param angle defines the angle (in radians) to use
  15922. * @return the new matrix
  15923. */
  15924. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15925. /**
  15926. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  15927. * @param axis defines the axis to use
  15928. * @param angle defines the angle (in radians) to use
  15929. * @param result defines the target matrix
  15930. */
  15931. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15932. /**
  15933. * Creates a rotation matrix
  15934. * @param yaw defines the yaw angle in radians (Y axis)
  15935. * @param pitch defines the pitch angle in radians (X axis)
  15936. * @param roll defines the roll angle in radians (X axis)
  15937. * @returns the new rotation matrix
  15938. */
  15939. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15940. /**
  15941. * Creates a rotation matrix and stores it in a given matrix
  15942. * @param yaw defines the yaw angle in radians (Y axis)
  15943. * @param pitch defines the pitch angle in radians (X axis)
  15944. * @param roll defines the roll angle in radians (X axis)
  15945. * @param result defines the target matrix
  15946. */
  15947. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15948. /**
  15949. * Creates a scaling matrix
  15950. * @param x defines the scale factor on X axis
  15951. * @param y defines the scale factor on Y axis
  15952. * @param z defines the scale factor on Z axis
  15953. * @returns the new matrix
  15954. */
  15955. static Scaling(x: number, y: number, z: number): Matrix;
  15956. /**
  15957. * Creates a scaling matrix and stores it in a given matrix
  15958. * @param x defines the scale factor on X axis
  15959. * @param y defines the scale factor on Y axis
  15960. * @param z defines the scale factor on Z axis
  15961. * @param result defines the target matrix
  15962. */
  15963. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15964. /**
  15965. * Creates a translation matrix
  15966. * @param x defines the translation on X axis
  15967. * @param y defines the translation on Y axis
  15968. * @param z defines the translationon Z axis
  15969. * @returns the new matrix
  15970. */
  15971. static Translation(x: number, y: number, z: number): Matrix;
  15972. /**
  15973. * Creates a translation matrix and stores it in a given matrix
  15974. * @param x defines the translation on X axis
  15975. * @param y defines the translation on Y axis
  15976. * @param z defines the translationon Z axis
  15977. * @param result defines the target matrix
  15978. */
  15979. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15980. /**
  15981. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15982. * @param startValue defines the start value
  15983. * @param endValue defines the end value
  15984. * @param gradient defines the gradient factor
  15985. * @returns the new matrix
  15986. */
  15987. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15988. /**
  15989. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15990. * @param startValue defines the start value
  15991. * @param endValue defines the end value
  15992. * @param gradient defines the gradient factor
  15993. * @param result defines the Matrix object where to store data
  15994. */
  15995. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15996. /**
  15997. * Builds a new matrix whose values are computed by:
  15998. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15999. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  16000. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  16001. * @param startValue defines the first matrix
  16002. * @param endValue defines the second matrix
  16003. * @param gradient defines the gradient between the two matrices
  16004. * @returns the new matrix
  16005. */
  16006. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  16007. /**
  16008. * Update a matrix to values which are computed by:
  16009. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  16010. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  16011. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  16012. * @param startValue defines the first matrix
  16013. * @param endValue defines the second matrix
  16014. * @param gradient defines the gradient between the two matrices
  16015. * @param result defines the target matrix
  16016. */
  16017. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  16018. /**
  16019. * 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"
  16020. * This function works in left handed mode
  16021. * @param eye defines the final position of the entity
  16022. * @param target defines where the entity should look at
  16023. * @param up defines the up vector for the entity
  16024. * @returns the new matrix
  16025. */
  16026. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16027. /**
  16028. * 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".
  16029. * This function works in left handed mode
  16030. * @param eye defines the final position of the entity
  16031. * @param target defines where the entity should look at
  16032. * @param up defines the up vector for the entity
  16033. * @param result defines the target matrix
  16034. */
  16035. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16036. /**
  16037. * 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"
  16038. * This function works in right handed mode
  16039. * @param eye defines the final position of the entity
  16040. * @param target defines where the entity should look at
  16041. * @param up defines the up vector for the entity
  16042. * @returns the new matrix
  16043. */
  16044. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16045. /**
  16046. * 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".
  16047. * This function works in right handed mode
  16048. * @param eye defines the final position of the entity
  16049. * @param target defines where the entity should look at
  16050. * @param up defines the up vector for the entity
  16051. * @param result defines the target matrix
  16052. */
  16053. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16054. /**
  16055. * Create a left-handed orthographic projection matrix
  16056. * @param width defines the viewport width
  16057. * @param height defines the viewport height
  16058. * @param znear defines the near clip plane
  16059. * @param zfar defines the far clip plane
  16060. * @returns a new matrix as a left-handed orthographic projection matrix
  16061. */
  16062. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16063. /**
  16064. * Store a left-handed orthographic projection to a given matrix
  16065. * @param width defines the viewport width
  16066. * @param height defines the viewport height
  16067. * @param znear defines the near clip plane
  16068. * @param zfar defines the far clip plane
  16069. * @param result defines the target matrix
  16070. */
  16071. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  16072. /**
  16073. * Create a left-handed orthographic projection matrix
  16074. * @param left defines the viewport left coordinate
  16075. * @param right defines the viewport right coordinate
  16076. * @param bottom defines the viewport bottom coordinate
  16077. * @param top defines the viewport top coordinate
  16078. * @param znear defines the near clip plane
  16079. * @param zfar defines the far clip plane
  16080. * @returns a new matrix as a left-handed orthographic projection matrix
  16081. */
  16082. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16083. /**
  16084. * Stores a left-handed orthographic projection into a given matrix
  16085. * @param left defines the viewport left coordinate
  16086. * @param right defines the viewport right coordinate
  16087. * @param bottom defines the viewport bottom coordinate
  16088. * @param top defines the viewport top coordinate
  16089. * @param znear defines the near clip plane
  16090. * @param zfar defines the far clip plane
  16091. * @param result defines the target matrix
  16092. */
  16093. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16094. /**
  16095. * Creates a right-handed orthographic projection matrix
  16096. * @param left defines the viewport left coordinate
  16097. * @param right defines the viewport right coordinate
  16098. * @param bottom defines the viewport bottom coordinate
  16099. * @param top defines the viewport top coordinate
  16100. * @param znear defines the near clip plane
  16101. * @param zfar defines the far clip plane
  16102. * @returns a new matrix as a right-handed orthographic projection matrix
  16103. */
  16104. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16105. /**
  16106. * Stores a right-handed orthographic projection into a given matrix
  16107. * @param left defines the viewport left coordinate
  16108. * @param right defines the viewport right coordinate
  16109. * @param bottom defines the viewport bottom coordinate
  16110. * @param top defines the viewport top coordinate
  16111. * @param znear defines the near clip plane
  16112. * @param zfar defines the far clip plane
  16113. * @param result defines the target matrix
  16114. */
  16115. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16116. /**
  16117. * Creates a left-handed perspective projection matrix
  16118. * @param width defines the viewport width
  16119. * @param height defines the viewport height
  16120. * @param znear defines the near clip plane
  16121. * @param zfar defines the far clip plane
  16122. * @returns a new matrix as a left-handed perspective projection matrix
  16123. */
  16124. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16125. /**
  16126. * Creates a left-handed perspective projection matrix
  16127. * @param fov defines the horizontal field of view
  16128. * @param aspect defines the aspect ratio
  16129. * @param znear defines the near clip plane
  16130. * @param zfar defines the far clip plane
  16131. * @returns a new matrix as a left-handed perspective projection matrix
  16132. */
  16133. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16134. /**
  16135. * Stores a left-handed perspective projection into a given matrix
  16136. * @param fov defines the horizontal field of view
  16137. * @param aspect defines the aspect ratio
  16138. * @param znear defines the near clip plane
  16139. * @param zfar defines the far clip plane
  16140. * @param result defines the target matrix
  16141. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16142. */
  16143. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16144. /**
  16145. * Creates a right-handed perspective projection matrix
  16146. * @param fov defines the horizontal field of view
  16147. * @param aspect defines the aspect ratio
  16148. * @param znear defines the near clip plane
  16149. * @param zfar defines the far clip plane
  16150. * @returns a new matrix as a right-handed perspective projection matrix
  16151. */
  16152. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16153. /**
  16154. * Stores a right-handed perspective projection into a given matrix
  16155. * @param fov defines the horizontal field of view
  16156. * @param aspect defines the aspect ratio
  16157. * @param znear defines the near clip plane
  16158. * @param zfar defines the far clip plane
  16159. * @param result defines the target matrix
  16160. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16161. */
  16162. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16163. /**
  16164. * Stores a perspective projection for WebVR info a given matrix
  16165. * @param fov defines the field of view
  16166. * @param znear defines the near clip plane
  16167. * @param zfar defines the far clip plane
  16168. * @param result defines the target matrix
  16169. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  16170. */
  16171. static PerspectiveFovWebVRToRef(fov: {
  16172. upDegrees: number;
  16173. downDegrees: number;
  16174. leftDegrees: number;
  16175. rightDegrees: number;
  16176. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  16177. /**
  16178. * Computes a complete transformation matrix
  16179. * @param viewport defines the viewport to use
  16180. * @param world defines the world matrix
  16181. * @param view defines the view matrix
  16182. * @param projection defines the projection matrix
  16183. * @param zmin defines the near clip plane
  16184. * @param zmax defines the far clip plane
  16185. * @returns the transformation matrix
  16186. */
  16187. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  16188. /**
  16189. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  16190. * @param matrix defines the matrix to use
  16191. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  16192. */
  16193. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  16194. /**
  16195. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  16196. * @param matrix defines the matrix to use
  16197. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  16198. */
  16199. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  16200. /**
  16201. * Compute the transpose of a given matrix
  16202. * @param matrix defines the matrix to transpose
  16203. * @returns the new matrix
  16204. */
  16205. static Transpose(matrix: Matrix): Matrix;
  16206. /**
  16207. * Compute the transpose of a matrix and store it in a target matrix
  16208. * @param matrix defines the matrix to transpose
  16209. * @param result defines the target matrix
  16210. */
  16211. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  16212. /**
  16213. * Computes a reflection matrix from a plane
  16214. * @param plane defines the reflection plane
  16215. * @returns a new matrix
  16216. */
  16217. static Reflection(plane: Plane): Matrix;
  16218. /**
  16219. * Computes a reflection matrix from a plane
  16220. * @param plane defines the reflection plane
  16221. * @param result defines the target matrix
  16222. */
  16223. static ReflectionToRef(plane: Plane, result: Matrix): void;
  16224. /**
  16225. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  16226. * @param xaxis defines the value of the 1st axis
  16227. * @param yaxis defines the value of the 2nd axis
  16228. * @param zaxis defines the value of the 3rd axis
  16229. * @param result defines the target matrix
  16230. */
  16231. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  16232. /**
  16233. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  16234. * @param quat defines the quaternion to use
  16235. * @param result defines the target matrix
  16236. */
  16237. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  16238. }
  16239. class Plane {
  16240. normal: Vector3;
  16241. d: number;
  16242. /**
  16243. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  16244. */
  16245. constructor(a: number, b: number, c: number, d: number);
  16246. /**
  16247. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  16248. */
  16249. asArray(): number[];
  16250. /**
  16251. * Returns a new plane copied from the current Plane.
  16252. */
  16253. clone(): Plane;
  16254. /**
  16255. * Returns the string "Plane".
  16256. */
  16257. getClassName(): string;
  16258. /**
  16259. * Returns the Plane hash code.
  16260. */
  16261. getHashCode(): number;
  16262. /**
  16263. * Normalize the current Plane in place.
  16264. * Returns the updated Plane.
  16265. */
  16266. normalize(): Plane;
  16267. /**
  16268. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  16269. */
  16270. transform(transformation: Matrix): Plane;
  16271. /**
  16272. * Returns the dot product (float) of the point coordinates and the plane normal.
  16273. */
  16274. dotCoordinate(point: Vector3): number;
  16275. /**
  16276. * Updates the current Plane from the plane defined by the three given points.
  16277. * Returns the updated Plane.
  16278. */
  16279. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16280. /**
  16281. * Boolean : True is the vector "direction" is the same side than the plane normal.
  16282. */
  16283. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  16284. /**
  16285. * Returns the signed distance (float) from the given point to the Plane.
  16286. */
  16287. signedDistanceTo(point: Vector3): number;
  16288. /**
  16289. * Returns a new Plane from the given array.
  16290. */
  16291. static FromArray(array: ArrayLike<number>): Plane;
  16292. /**
  16293. * Returns a new Plane defined by the three given points.
  16294. */
  16295. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16296. /**
  16297. * Returns a new Plane the normal vector to this plane at the given origin point.
  16298. * Note : the vector "normal" is updated because normalized.
  16299. */
  16300. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  16301. /**
  16302. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  16303. */
  16304. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  16305. }
  16306. class Viewport {
  16307. x: number;
  16308. y: number;
  16309. width: number;
  16310. height: number;
  16311. /**
  16312. * Creates a Viewport object located at (x, y) and sized (width, height).
  16313. */
  16314. constructor(x: number, y: number, width: number, height: number);
  16315. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  16316. /**
  16317. * Returns a new Viewport copied from the current one.
  16318. */
  16319. clone(): Viewport;
  16320. }
  16321. class Frustum {
  16322. /**
  16323. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  16324. */
  16325. static GetPlanes(transform: Matrix): Plane[];
  16326. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16327. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16328. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16329. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16330. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16331. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16332. /**
  16333. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  16334. */
  16335. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  16336. }
  16337. /** Defines supported spaces */
  16338. enum Space {
  16339. /** Local (object) space */
  16340. LOCAL = 0,
  16341. /** World space */
  16342. WORLD = 1,
  16343. /** Bone space */
  16344. BONE = 2
  16345. }
  16346. /** Defines the 3 main axes */
  16347. class Axis {
  16348. /** X axis */
  16349. static X: Vector3;
  16350. /** Y axis */
  16351. static Y: Vector3;
  16352. /** Z axis */
  16353. static Z: Vector3;
  16354. }
  16355. class BezierCurve {
  16356. /**
  16357. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  16358. */
  16359. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  16360. }
  16361. /**
  16362. * Defines potential orientation for back face culling
  16363. */
  16364. enum Orientation {
  16365. /**
  16366. * Clockwise
  16367. */
  16368. CW = 0,
  16369. /** Counter clockwise */
  16370. CCW = 1
  16371. }
  16372. /**
  16373. * Defines angle representation
  16374. */
  16375. class Angle {
  16376. private _radians;
  16377. /**
  16378. * Creates an Angle object of "radians" radians (float).
  16379. */
  16380. constructor(radians: number);
  16381. /**
  16382. * Get value in degrees
  16383. * @returns the Angle value in degrees (float)
  16384. */
  16385. degrees(): number;
  16386. /**
  16387. * Get value in radians
  16388. * @returns the Angle value in radians (float)
  16389. */
  16390. radians(): number;
  16391. /**
  16392. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  16393. * @param a defines first vector
  16394. * @param b defines second vector
  16395. * @returns a new Angle
  16396. */
  16397. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  16398. /**
  16399. * Gets a new Angle object from the given float in radians
  16400. * @param radians defines the angle value in radians
  16401. * @returns a new Angle
  16402. */
  16403. static FromRadians(radians: number): Angle;
  16404. /**
  16405. * Gets a new Angle object from the given float in degrees
  16406. * @param degrees defines the angle value in degrees
  16407. * @returns a new Angle
  16408. */
  16409. static FromDegrees(degrees: number): Angle;
  16410. }
  16411. class Arc2 {
  16412. startPoint: Vector2;
  16413. midPoint: Vector2;
  16414. endPoint: Vector2;
  16415. centerPoint: Vector2;
  16416. radius: number;
  16417. angle: Angle;
  16418. startAngle: Angle;
  16419. orientation: Orientation;
  16420. /**
  16421. * Creates an Arc object from the three given points : start, middle and end.
  16422. */
  16423. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  16424. }
  16425. class Path2 {
  16426. private _points;
  16427. private _length;
  16428. closed: boolean;
  16429. /**
  16430. * Creates a Path2 object from the starting 2D coordinates x and y.
  16431. */
  16432. constructor(x: number, y: number);
  16433. /**
  16434. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  16435. * Returns the updated Path2.
  16436. */
  16437. addLineTo(x: number, y: number): Path2;
  16438. /**
  16439. * 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.
  16440. * Returns the updated Path2.
  16441. */
  16442. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  16443. /**
  16444. * Closes the Path2.
  16445. * Returns the Path2.
  16446. */
  16447. close(): Path2;
  16448. /**
  16449. * Returns the Path2 total length (float).
  16450. */
  16451. length(): number;
  16452. /**
  16453. * Returns the Path2 internal array of points.
  16454. */
  16455. getPoints(): Vector2[];
  16456. /**
  16457. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  16458. */
  16459. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  16460. /**
  16461. * Returns a new Path2 starting at the coordinates (x, y).
  16462. */
  16463. static StartingAt(x: number, y: number): Path2;
  16464. }
  16465. class Path3D {
  16466. path: Vector3[];
  16467. private _curve;
  16468. private _distances;
  16469. private _tangents;
  16470. private _normals;
  16471. private _binormals;
  16472. private _raw;
  16473. /**
  16474. * new Path3D(path, normal, raw)
  16475. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  16476. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  16477. * path : an array of Vector3, the curve axis of the Path3D
  16478. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  16479. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  16480. */
  16481. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  16482. /**
  16483. * Returns the Path3D array of successive Vector3 designing its curve.
  16484. */
  16485. getCurve(): Vector3[];
  16486. /**
  16487. * Returns an array populated with tangent vectors on each Path3D curve point.
  16488. */
  16489. getTangents(): Vector3[];
  16490. /**
  16491. * Returns an array populated with normal vectors on each Path3D curve point.
  16492. */
  16493. getNormals(): Vector3[];
  16494. /**
  16495. * Returns an array populated with binormal vectors on each Path3D curve point.
  16496. */
  16497. getBinormals(): Vector3[];
  16498. /**
  16499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  16500. */
  16501. getDistances(): number[];
  16502. /**
  16503. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  16504. * Returns the same object updated.
  16505. */
  16506. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  16507. private _compute;
  16508. private _getFirstNonNullVector;
  16509. private _getLastNonNullVector;
  16510. private _normalVector;
  16511. }
  16512. class Curve3 {
  16513. private _points;
  16514. private _length;
  16515. /**
  16516. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  16517. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  16518. * @param v1 (Vector3) the control point
  16519. * @param v2 (Vector3) the end point of the Quadratic Bezier
  16520. * @param nbPoints (integer) the wanted number of points in the curve
  16521. */
  16522. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  16523. /**
  16524. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  16525. * @param v0 (Vector3) the origin point of the Cubic Bezier
  16526. * @param v1 (Vector3) the first control point
  16527. * @param v2 (Vector3) the second control point
  16528. * @param v3 (Vector3) the end point of the Cubic Bezier
  16529. * @param nbPoints (integer) the wanted number of points in the curve
  16530. */
  16531. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  16532. /**
  16533. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  16534. * @param p1 (Vector3) the origin point of the Hermite Spline
  16535. * @param t1 (Vector3) the tangent vector at the origin point
  16536. * @param p2 (Vector3) the end point of the Hermite Spline
  16537. * @param t2 (Vector3) the tangent vector at the end point
  16538. * @param nbPoints (integer) the wanted number of points in the curve
  16539. */
  16540. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  16541. /**
  16542. * Returns a Curve3 object along a CatmullRom Spline curve :
  16543. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  16544. * @param nbPoints (integer) the wanted number of points between each curve control points
  16545. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  16546. */
  16547. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  16548. /**
  16549. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  16550. * A Curve3 is designed from a series of successive Vector3.
  16551. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  16552. */
  16553. constructor(points: Vector3[]);
  16554. /**
  16555. * Returns the Curve3 stored array of successive Vector3
  16556. */
  16557. getPoints(): Vector3[];
  16558. /**
  16559. * Returns the computed length (float) of the curve.
  16560. */
  16561. length(): number;
  16562. /**
  16563. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  16564. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  16565. * curveA and curveB keep unchanged.
  16566. */
  16567. continue(curve: Curve3): Curve3;
  16568. private _computeLength;
  16569. }
  16570. class PositionNormalVertex {
  16571. position: Vector3;
  16572. normal: Vector3;
  16573. constructor(position?: Vector3, normal?: Vector3);
  16574. clone(): PositionNormalVertex;
  16575. }
  16576. class PositionNormalTextureVertex {
  16577. position: Vector3;
  16578. normal: Vector3;
  16579. uv: Vector2;
  16580. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  16581. clone(): PositionNormalTextureVertex;
  16582. }
  16583. class Tmp {
  16584. static Color3: Color3[];
  16585. static Color4: Color4[];
  16586. static Vector2: Vector2[];
  16587. static Vector3: Vector3[];
  16588. static Vector4: Vector4[];
  16589. static Quaternion: Quaternion[];
  16590. static Matrix: Matrix[];
  16591. }
  16592. }
  16593. declare module BABYLON {
  16594. /**
  16595. * Class representing spherical polynomial coefficients to the 3rd degree
  16596. */
  16597. class SphericalPolynomial {
  16598. /**
  16599. * The x coefficients of the spherical polynomial
  16600. */
  16601. x: Vector3;
  16602. /**
  16603. * The y coefficients of the spherical polynomial
  16604. */
  16605. y: Vector3;
  16606. /**
  16607. * The z coefficients of the spherical polynomial
  16608. */
  16609. z: Vector3;
  16610. /**
  16611. * The xx coefficients of the spherical polynomial
  16612. */
  16613. xx: Vector3;
  16614. /**
  16615. * The yy coefficients of the spherical polynomial
  16616. */
  16617. yy: Vector3;
  16618. /**
  16619. * The zz coefficients of the spherical polynomial
  16620. */
  16621. zz: Vector3;
  16622. /**
  16623. * The xy coefficients of the spherical polynomial
  16624. */
  16625. xy: Vector3;
  16626. /**
  16627. * The yz coefficients of the spherical polynomial
  16628. */
  16629. yz: Vector3;
  16630. /**
  16631. * The zx coefficients of the spherical polynomial
  16632. */
  16633. zx: Vector3;
  16634. /**
  16635. * Adds an ambient color to the spherical polynomial
  16636. * @param color the color to add
  16637. */
  16638. addAmbient(color: Color3): void;
  16639. /**
  16640. * Scales the spherical polynomial by the given amount
  16641. * @param scale the amount to scale
  16642. */
  16643. scale(scale: number): void;
  16644. /**
  16645. * Gets the spherical polynomial from harmonics
  16646. * @param harmonics the spherical harmonics
  16647. * @returns the spherical polynomial
  16648. */
  16649. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  16650. /**
  16651. * Constructs a spherical polynomial from an array.
  16652. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  16653. * @returns the spherical polynomial
  16654. */
  16655. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  16656. }
  16657. /**
  16658. * Class representing spherical harmonics coefficients to the 3rd degree
  16659. */
  16660. class SphericalHarmonics {
  16661. /**
  16662. * The l0,0 coefficients of the spherical harmonics
  16663. */
  16664. l00: Vector3;
  16665. /**
  16666. * The l1,-1 coefficients of the spherical harmonics
  16667. */
  16668. l1_1: Vector3;
  16669. /**
  16670. * The l1,0 coefficients of the spherical harmonics
  16671. */
  16672. l10: Vector3;
  16673. /**
  16674. * The l1,1 coefficients of the spherical harmonics
  16675. */
  16676. l11: Vector3;
  16677. /**
  16678. * The l2,-2 coefficients of the spherical harmonics
  16679. */
  16680. l2_2: Vector3;
  16681. /**
  16682. * The l2,-1 coefficients of the spherical harmonics
  16683. */
  16684. l2_1: Vector3;
  16685. /**
  16686. * The l2,0 coefficients of the spherical harmonics
  16687. */
  16688. l20: Vector3;
  16689. /**
  16690. * The l2,1 coefficients of the spherical harmonics
  16691. */
  16692. l21: Vector3;
  16693. /**
  16694. * The l2,2 coefficients of the spherical harmonics
  16695. */
  16696. lL22: Vector3;
  16697. /**
  16698. * Adds a light to the spherical harmonics
  16699. * @param direction the direction of the light
  16700. * @param color the color of the light
  16701. * @param deltaSolidAngle the delta solid angle of the light
  16702. */
  16703. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  16704. /**
  16705. * Scales the spherical harmonics by the given amount
  16706. * @param scale the amount to scale
  16707. */
  16708. scale(scale: number): void;
  16709. /**
  16710. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  16711. *
  16712. * ```
  16713. * E_lm = A_l * L_lm
  16714. * ```
  16715. *
  16716. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  16717. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  16718. * the scaling factors are given in equation 9.
  16719. */
  16720. convertIncidentRadianceToIrradiance(): void;
  16721. /**
  16722. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  16723. *
  16724. * ```
  16725. * L = (1/pi) * E * rho
  16726. * ```
  16727. *
  16728. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  16729. */
  16730. convertIrradianceToLambertianRadiance(): void;
  16731. /**
  16732. * Gets the spherical harmonics from polynomial
  16733. * @param polynomial the spherical polynomial
  16734. * @returns the spherical harmonics
  16735. */
  16736. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  16737. /**
  16738. * Constructs a spherical harmonics from an array.
  16739. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  16740. * @returns the spherical harmonics
  16741. */
  16742. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. /**
  16747. * Defines a target to use with MorphTargetManager
  16748. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  16749. */
  16750. class MorphTarget implements IAnimatable {
  16751. /** defines the name of the target */
  16752. name: string;
  16753. /**
  16754. * Gets or sets the list of animations
  16755. */
  16756. animations: Animation[];
  16757. private _scene;
  16758. private _positions;
  16759. private _normals;
  16760. private _tangents;
  16761. private _influence;
  16762. /**
  16763. * Observable raised when the influence changes
  16764. */
  16765. onInfluenceChanged: Observable<boolean>;
  16766. /**
  16767. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  16768. */
  16769. influence: number;
  16770. private _animationPropertiesOverride;
  16771. /**
  16772. * Gets or sets the animation properties override
  16773. */
  16774. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  16775. /**
  16776. * Creates a new MorphTarget
  16777. * @param name defines the name of the target
  16778. * @param influence defines the influence to use
  16779. */
  16780. constructor(
  16781. /** defines the name of the target */
  16782. name: string, influence?: number, scene?: Nullable<Scene>);
  16783. /**
  16784. * Gets a boolean defining if the target contains position data
  16785. */
  16786. readonly hasPositions: boolean;
  16787. /**
  16788. * Gets a boolean defining if the target contains normal data
  16789. */
  16790. readonly hasNormals: boolean;
  16791. /**
  16792. * Gets a boolean defining if the target contains tangent data
  16793. */
  16794. readonly hasTangents: boolean;
  16795. /**
  16796. * Affects position data to this target
  16797. * @param data defines the position data to use
  16798. */
  16799. setPositions(data: Nullable<FloatArray>): void;
  16800. /**
  16801. * Gets the position data stored in this target
  16802. * @returns a FloatArray containing the position data (or null if not present)
  16803. */
  16804. getPositions(): Nullable<FloatArray>;
  16805. /**
  16806. * Affects normal data to this target
  16807. * @param data defines the normal data to use
  16808. */
  16809. setNormals(data: Nullable<FloatArray>): void;
  16810. /**
  16811. * Gets the normal data stored in this target
  16812. * @returns a FloatArray containing the normal data (or null if not present)
  16813. */
  16814. getNormals(): Nullable<FloatArray>;
  16815. /**
  16816. * Affects tangent data to this target
  16817. * @param data defines the tangent data to use
  16818. */
  16819. setTangents(data: Nullable<FloatArray>): void;
  16820. /**
  16821. * Gets the tangent data stored in this target
  16822. * @returns a FloatArray containing the tangent data (or null if not present)
  16823. */
  16824. getTangents(): Nullable<FloatArray>;
  16825. /**
  16826. * Serializes the current target into a Serialization object
  16827. * @returns the serialized object
  16828. */
  16829. serialize(): any;
  16830. /**
  16831. * Creates a new target from serialized data
  16832. * @param serializationObject defines the serialized data to use
  16833. * @returns a new MorphTarget
  16834. */
  16835. static Parse(serializationObject: any): MorphTarget;
  16836. /**
  16837. * Creates a MorphTarget from mesh data
  16838. * @param mesh defines the source mesh
  16839. * @param name defines the name to use for the new target
  16840. * @param influence defines the influence to attach to the target
  16841. * @returns a new MorphTarget
  16842. */
  16843. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  16844. }
  16845. }
  16846. declare module BABYLON {
  16847. /**
  16848. * This class is used to deform meshes using morphing between different targets
  16849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  16850. */
  16851. class MorphTargetManager {
  16852. private _targets;
  16853. private _targetObservable;
  16854. private _activeTargets;
  16855. private _scene;
  16856. private _influences;
  16857. private _supportsNormals;
  16858. private _supportsTangents;
  16859. private _vertexCount;
  16860. private _uniqueId;
  16861. private _tempInfluences;
  16862. /**
  16863. * Creates a new MorphTargetManager
  16864. * @param scene defines the current scene
  16865. */
  16866. constructor(scene?: Nullable<Scene>);
  16867. /**
  16868. * Gets the unique ID of this manager
  16869. */
  16870. readonly uniqueId: number;
  16871. /**
  16872. * Gets the number of vertices handled by this manager
  16873. */
  16874. readonly vertexCount: number;
  16875. /**
  16876. * Gets a boolean indicating if this manager supports morphing of normals
  16877. */
  16878. readonly supportsNormals: boolean;
  16879. /**
  16880. * Gets a boolean indicating if this manager supports morphing of tangents
  16881. */
  16882. readonly supportsTangents: boolean;
  16883. /**
  16884. * Gets the number of targets stored in this manager
  16885. */
  16886. readonly numTargets: number;
  16887. /**
  16888. * Gets the number of influencers (ie. the number of targets with influences > 0)
  16889. */
  16890. readonly numInfluencers: number;
  16891. /**
  16892. * Gets the list of influences (one per target)
  16893. */
  16894. readonly influences: Float32Array;
  16895. /**
  16896. * Gets the active target at specified index. An active target is a target with an influence > 0
  16897. * @param index defines the index to check
  16898. * @returns the requested target
  16899. */
  16900. getActiveTarget(index: number): MorphTarget;
  16901. /**
  16902. * Gets the target at specified index
  16903. * @param index defines the index to check
  16904. * @returns the requested target
  16905. */
  16906. getTarget(index: number): MorphTarget;
  16907. /**
  16908. * Add a new target to this manager
  16909. * @param target defines the target to add
  16910. */
  16911. addTarget(target: MorphTarget): void;
  16912. /**
  16913. * Removes a target from the manager
  16914. * @param target defines the target to remove
  16915. */
  16916. removeTarget(target: MorphTarget): void;
  16917. /**
  16918. * Serializes the current manager into a Serialization object
  16919. * @returns the serialized object
  16920. */
  16921. serialize(): any;
  16922. private _syncActiveTargets;
  16923. /**
  16924. * Syncrhonize the targets with all the meshes using this morph target manager
  16925. */
  16926. synchronize(): void;
  16927. /**
  16928. * Creates a new MorphTargetManager from serialized data
  16929. * @param serializationObject defines the serialized data
  16930. * @param scene defines the hosting scene
  16931. * @returns the new MorphTargetManager
  16932. */
  16933. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /**
  16938. * This represents the base class for particle system in Babylon.
  16939. * 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.
  16940. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16941. * @example https://doc.babylonjs.com/babylon101/particles
  16942. */
  16943. class BaseParticleSystem {
  16944. /**
  16945. * Source color is added to the destination color without alpha affecting the result.
  16946. */
  16947. static BLENDMODE_ONEONE: number;
  16948. /**
  16949. * Blend current color and particle color using particle’s alpha.
  16950. */
  16951. static BLENDMODE_STANDARD: number;
  16952. /**
  16953. * Add current color and particle color multiplied by particle’s alpha.
  16954. */
  16955. static BLENDMODE_ADD: number;
  16956. /**
  16957. * Multiply current color with particle color
  16958. */
  16959. static BLENDMODE_MULTIPLY: number;
  16960. /**
  16961. * List of animations used by the particle system.
  16962. */
  16963. animations: Animation[];
  16964. /**
  16965. * The id of the Particle system.
  16966. */
  16967. id: string;
  16968. /**
  16969. * The friendly name of the Particle system.
  16970. */
  16971. name: string;
  16972. /**
  16973. * The rendering group used by the Particle system to chose when to render.
  16974. */
  16975. renderingGroupId: number;
  16976. /**
  16977. * The emitter represents the Mesh or position we are attaching the particle system to.
  16978. */
  16979. emitter: Nullable<AbstractMesh | Vector3>;
  16980. /**
  16981. * The maximum number of particles to emit per frame
  16982. */
  16983. emitRate: number;
  16984. /**
  16985. * If you want to launch only a few particles at once, that can be done, as well.
  16986. */
  16987. manualEmitCount: number;
  16988. /**
  16989. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16990. */
  16991. updateSpeed: number;
  16992. /**
  16993. * The amount of time the particle system is running (depends of the overall update speed).
  16994. */
  16995. targetStopDuration: number;
  16996. /**
  16997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16998. */
  16999. disposeOnStop: boolean;
  17000. /**
  17001. * Minimum power of emitting particles.
  17002. */
  17003. minEmitPower: number;
  17004. /**
  17005. * Maximum power of emitting particles.
  17006. */
  17007. maxEmitPower: number;
  17008. /**
  17009. * Minimum life time of emitting particles.
  17010. */
  17011. minLifeTime: number;
  17012. /**
  17013. * Maximum life time of emitting particles.
  17014. */
  17015. maxLifeTime: number;
  17016. /**
  17017. * Minimum Size of emitting particles.
  17018. */
  17019. minSize: number;
  17020. /**
  17021. * Maximum Size of emitting particles.
  17022. */
  17023. maxSize: number;
  17024. /**
  17025. * Minimum scale of emitting particles on X axis.
  17026. */
  17027. minScaleX: number;
  17028. /**
  17029. * Maximum scale of emitting particles on X axis.
  17030. */
  17031. maxScaleX: number;
  17032. /**
  17033. * Minimum scale of emitting particles on Y axis.
  17034. */
  17035. minScaleY: number;
  17036. /**
  17037. * Maximum scale of emitting particles on Y axis.
  17038. */
  17039. maxScaleY: number;
  17040. /**
  17041. * Gets or sets the minimal initial rotation in radians.
  17042. */
  17043. minInitialRotation: number;
  17044. /**
  17045. * Gets or sets the maximal initial rotation in radians.
  17046. */
  17047. maxInitialRotation: number;
  17048. /**
  17049. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17050. */
  17051. minAngularSpeed: number;
  17052. /**
  17053. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17054. */
  17055. maxAngularSpeed: number;
  17056. /**
  17057. * The texture used to render each particle. (this can be a spritesheet)
  17058. */
  17059. particleTexture: Nullable<Texture>;
  17060. /**
  17061. * The layer mask we are rendering the particles through.
  17062. */
  17063. layerMask: number;
  17064. /**
  17065. * This can help using your own shader to render the particle system.
  17066. * The according effect will be created
  17067. */
  17068. customShader: any;
  17069. /**
  17070. * By default particle system starts as soon as they are created. This prevents the
  17071. * automatic start to happen and let you decide when to start emitting particles.
  17072. */
  17073. preventAutoStart: boolean;
  17074. /**
  17075. * Gets or sets a texture used to add random noise to particle positions
  17076. */
  17077. noiseTexture: Nullable<BaseTexture>;
  17078. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17079. noiseStrength: Vector3;
  17080. /**
  17081. * Callback triggered when the particle animation is ending.
  17082. */
  17083. onAnimationEnd: Nullable<() => void>;
  17084. /**
  17085. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17086. */
  17087. blendMode: number;
  17088. /**
  17089. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17090. * to override the particles.
  17091. */
  17092. forceDepthWrite: boolean;
  17093. /** 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 */
  17094. preWarmCycles: number;
  17095. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17096. preWarmStepOffset: number;
  17097. /**
  17098. * 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)
  17099. */
  17100. spriteCellChangeSpeed: number;
  17101. /**
  17102. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17103. */
  17104. startSpriteCellID: number;
  17105. /**
  17106. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17107. */
  17108. endSpriteCellID: number;
  17109. /**
  17110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17111. */
  17112. spriteCellWidth: number;
  17113. /**
  17114. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17115. */
  17116. spriteCellHeight: number;
  17117. /**
  17118. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17119. */
  17120. spriteRandomStartCell: boolean;
  17121. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17122. translationPivot: Vector2;
  17123. /** @hidden */
  17124. protected _isAnimationSheetEnabled: boolean;
  17125. /**
  17126. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17127. */
  17128. isAnimationSheetEnabled: boolean;
  17129. /**
  17130. * Get hosting scene
  17131. * @returns the scene
  17132. */
  17133. getScene(): Scene;
  17134. /**
  17135. * You can use gravity if you want to give an orientation to your particles.
  17136. */
  17137. gravity: Vector3;
  17138. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17139. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17140. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17141. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17142. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17143. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17144. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17145. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17146. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17147. /**
  17148. * Gets the current list of drag gradients.
  17149. * You must use addDragGradient and removeDragGradient to udpate this list
  17150. * @returns the list of drag gradients
  17151. */
  17152. getDragGradients(): Nullable<Array<FactorGradient>>;
  17153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17154. limitVelocityDamping: number;
  17155. /**
  17156. * Gets the current list of limit velocity gradients.
  17157. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17158. * @returns the list of limit velocity gradients
  17159. */
  17160. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17161. /**
  17162. * Gets the current list of color gradients.
  17163. * You must use addColorGradient and removeColorGradient to udpate this list
  17164. * @returns the list of color gradients
  17165. */
  17166. getColorGradients(): Nullable<Array<ColorGradient>>;
  17167. /**
  17168. * Gets the current list of size gradients.
  17169. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17170. * @returns the list of size gradients
  17171. */
  17172. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17173. /**
  17174. * Gets the current list of life time gradients.
  17175. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17176. * @returns the list of life time gradients
  17177. */
  17178. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17179. /**
  17180. * Gets the current list of angular speed gradients.
  17181. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17182. * @returns the list of angular speed gradients
  17183. */
  17184. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17185. /**
  17186. * Gets the current list of velocity gradients.
  17187. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17188. * @returns the list of velocity gradients
  17189. */
  17190. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17191. /**
  17192. * Gets the current list of start size gradients.
  17193. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17194. * @returns the list of start size gradients
  17195. */
  17196. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17197. /**
  17198. * Gets the current list of emit rate gradients.
  17199. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17200. * @returns the list of emit rate gradients
  17201. */
  17202. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17203. /**
  17204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17206. */
  17207. direction1: Vector3;
  17208. /**
  17209. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17210. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17211. */
  17212. direction2: Vector3;
  17213. /**
  17214. * 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.
  17215. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17216. */
  17217. minEmitBox: Vector3;
  17218. /**
  17219. * 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.
  17220. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17221. */
  17222. maxEmitBox: Vector3;
  17223. /**
  17224. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17225. */
  17226. color1: Color4;
  17227. /**
  17228. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17229. */
  17230. color2: Color4;
  17231. /**
  17232. * Color the particle will have at the end of its lifetime
  17233. */
  17234. colorDead: Color4;
  17235. /**
  17236. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17237. */
  17238. textureMask: Color4;
  17239. /**
  17240. * The particle emitter type defines the emitter used by the particle system.
  17241. * It can be for example box, sphere, or cone...
  17242. */
  17243. particleEmitterType: IParticleEmitterType;
  17244. /**
  17245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17246. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  17247. */
  17248. billboardMode: number;
  17249. protected _isBillboardBased: boolean;
  17250. /**
  17251. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17252. */
  17253. isBillboardBased: boolean;
  17254. /**
  17255. * The scene the particle system belongs to.
  17256. */
  17257. protected _scene: Scene;
  17258. /**
  17259. * Local cache of defines for image processing.
  17260. */
  17261. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17262. /**
  17263. * Default configuration related to image processing available in the standard Material.
  17264. */
  17265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17266. /**
  17267. * Gets the image processing configuration used either in this material.
  17268. */
  17269. /**
  17270. * Sets the Default image processing configuration used either in the this material.
  17271. *
  17272. * If sets to null, the scene one is in use.
  17273. */
  17274. imageProcessingConfiguration: ImageProcessingConfiguration;
  17275. /**
  17276. * Attaches a new image processing configuration to the Standard Material.
  17277. * @param configuration
  17278. */
  17279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17280. /** @hidden */
  17281. protected _reset(): void;
  17282. /**
  17283. * Instantiates a particle system.
  17284. * 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.
  17285. * @param name The name of the particle system
  17286. */
  17287. constructor(name: string);
  17288. /**
  17289. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17290. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17291. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17292. * @returns the emitter
  17293. */
  17294. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17295. /**
  17296. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17297. * @param radius The radius of the hemisphere to emit from
  17298. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17299. * @returns the emitter
  17300. */
  17301. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17302. /**
  17303. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17304. * @param radius The radius of the sphere to emit from
  17305. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17306. * @returns the emitter
  17307. */
  17308. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17309. /**
  17310. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17311. * @param radius The radius of the sphere to emit from
  17312. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17313. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17314. * @returns the emitter
  17315. */
  17316. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17317. /**
  17318. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17319. * @param radius The radius of the emission cylinder
  17320. * @param height The height of the emission cylinder
  17321. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17322. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17323. * @returns the emitter
  17324. */
  17325. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17326. /**
  17327. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17328. * @param radius The radius of the cylinder to emit from
  17329. * @param height The height of the emission cylinder
  17330. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17331. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17332. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17333. * @returns the emitter
  17334. */
  17335. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17336. /**
  17337. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17338. * @param radius The radius of the cone to emit from
  17339. * @param angle The base angle of the cone
  17340. * @returns the emitter
  17341. */
  17342. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17343. /**
  17344. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17345. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17346. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17347. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17348. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17349. * @returns the emitter
  17350. */
  17351. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17352. }
  17353. }
  17354. declare module BABYLON {
  17355. /**
  17356. * This represents a GPU particle system in Babylon
  17357. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17358. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17359. */
  17360. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17361. /**
  17362. * The layer mask we are rendering the particles through.
  17363. */
  17364. layerMask: number;
  17365. private _capacity;
  17366. private _activeCount;
  17367. private _currentActiveCount;
  17368. private _accumulatedCount;
  17369. private _renderEffect;
  17370. private _updateEffect;
  17371. private _buffer0;
  17372. private _buffer1;
  17373. private _spriteBuffer;
  17374. private _updateVAO;
  17375. private _renderVAO;
  17376. private _targetIndex;
  17377. private _sourceBuffer;
  17378. private _targetBuffer;
  17379. private _engine;
  17380. private _currentRenderId;
  17381. private _started;
  17382. private _stopped;
  17383. private _timeDelta;
  17384. private _randomTexture;
  17385. private _randomTexture2;
  17386. private _attributesStrideSize;
  17387. private _updateEffectOptions;
  17388. private _randomTextureSize;
  17389. private _actualFrame;
  17390. private readonly _rawTextureWidth;
  17391. /**
  17392. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17393. */
  17394. static readonly IsSupported: boolean;
  17395. /**
  17396. * An event triggered when the system is disposed.
  17397. */
  17398. onDisposeObservable: Observable<GPUParticleSystem>;
  17399. /**
  17400. * Gets the maximum number of particles active at the same time.
  17401. * @returns The max number of active particles.
  17402. */
  17403. getCapacity(): number;
  17404. /**
  17405. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17406. * to override the particles.
  17407. */
  17408. forceDepthWrite: boolean;
  17409. /**
  17410. * Gets or set the number of active particles
  17411. */
  17412. activeParticleCount: number;
  17413. private _preWarmDone;
  17414. /**
  17415. * Is this system ready to be used/rendered
  17416. * @return true if the system is ready
  17417. */
  17418. isReady(): boolean;
  17419. /**
  17420. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17421. * @returns True if it has been started, otherwise false.
  17422. */
  17423. isStarted(): boolean;
  17424. /**
  17425. * Starts the particle system and begins to emit
  17426. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17427. */
  17428. start(delay?: number): void;
  17429. /**
  17430. * Stops the particle system.
  17431. */
  17432. stop(): void;
  17433. /**
  17434. * Remove all active particles
  17435. */
  17436. reset(): void;
  17437. /**
  17438. * Returns the string "GPUParticleSystem"
  17439. * @returns a string containing the class name
  17440. */
  17441. getClassName(): string;
  17442. private _colorGradientsTexture;
  17443. private _removeGradient;
  17444. /**
  17445. * Adds a new color gradient
  17446. * @param gradient defines the gradient to use (between 0 and 1)
  17447. * @param color defines the color to affect to the specified gradient
  17448. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17449. * @returns the current particle system
  17450. */
  17451. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  17452. /**
  17453. * Remove a specific color gradient
  17454. * @param gradient defines the gradient to remove
  17455. * @returns the current particle system
  17456. */
  17457. removeColorGradient(gradient: number): GPUParticleSystem;
  17458. private _angularSpeedGradientsTexture;
  17459. private _sizeGradientsTexture;
  17460. private _velocityGradientsTexture;
  17461. private _limitVelocityGradientsTexture;
  17462. private _dragGradientsTexture;
  17463. private _addFactorGradient;
  17464. /**
  17465. * Adds a new size gradient
  17466. * @param gradient defines the gradient to use (between 0 and 1)
  17467. * @param factor defines the size factor to affect to the specified gradient
  17468. * @returns the current particle system
  17469. */
  17470. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  17471. /**
  17472. * Remove a specific size gradient
  17473. * @param gradient defines the gradient to remove
  17474. * @returns the current particle system
  17475. */
  17476. removeSizeGradient(gradient: number): GPUParticleSystem;
  17477. /**
  17478. * Adds a new angular speed gradient
  17479. * @param gradient defines the gradient to use (between 0 and 1)
  17480. * @param factor defines the angular speed to affect to the specified gradient
  17481. * @returns the current particle system
  17482. */
  17483. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  17484. /**
  17485. * Remove a specific angular speed gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  17490. /**
  17491. * Adds a new velocity gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param factor defines the velocity to affect to the specified gradient
  17494. * @returns the current particle system
  17495. */
  17496. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  17497. /**
  17498. * Remove a specific velocity gradient
  17499. * @param gradient defines the gradient to remove
  17500. * @returns the current particle system
  17501. */
  17502. removeVelocityGradient(gradient: number): GPUParticleSystem;
  17503. /**
  17504. * Adds a new limit velocity gradient
  17505. * @param gradient defines the gradient to use (between 0 and 1)
  17506. * @param factor defines the limit velocity value to affect to the specified gradient
  17507. * @returns the current particle system
  17508. */
  17509. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  17510. /**
  17511. * Remove a specific limit velocity gradient
  17512. * @param gradient defines the gradient to remove
  17513. * @returns the current particle system
  17514. */
  17515. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  17516. /**
  17517. * Adds a new drag gradient
  17518. * @param gradient defines the gradient to use (between 0 and 1)
  17519. * @param factor defines the drag value to affect to the specified gradient
  17520. * @returns the current particle system
  17521. */
  17522. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  17523. /**
  17524. * Remove a specific drag gradient
  17525. * @param gradient defines the gradient to remove
  17526. * @returns the current particle system
  17527. */
  17528. removeDragGradient(gradient: number): GPUParticleSystem;
  17529. /**
  17530. * Not supported by GPUParticleSystem
  17531. * @param gradient defines the gradient to use (between 0 and 1)
  17532. * @param factor defines the emit rate value to affect to the specified gradient
  17533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17534. * @returns the current particle system
  17535. */
  17536. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17537. /**
  17538. * Not supported by GPUParticleSystem
  17539. * @param gradient defines the gradient to remove
  17540. * @returns the current particle system
  17541. */
  17542. removeEmitRateGradient(gradient: number): IParticleSystem;
  17543. /**
  17544. * Not supported by GPUParticleSystem
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param factor defines the start size value to affect to the specified gradient
  17547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17548. * @returns the current particle system
  17549. */
  17550. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17551. /**
  17552. * Not supported by GPUParticleSystem
  17553. * @param gradient defines the gradient to remove
  17554. * @returns the current particle system
  17555. */
  17556. removeStartSizeGradient(gradient: number): IParticleSystem;
  17557. /**
  17558. * Instantiates a GPU particle system.
  17559. * 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.
  17560. * @param name The name of the particle system
  17561. * @param options The options used to create the system
  17562. * @param scene The scene the particle system belongs to
  17563. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17564. */
  17565. constructor(name: string, options: Partial<{
  17566. capacity: number;
  17567. randomTextureSize: number;
  17568. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  17569. protected _reset(): void;
  17570. private _createUpdateVAO;
  17571. private _createRenderVAO;
  17572. private _initialize;
  17573. /** @hidden */
  17574. _recreateUpdateEffect(): void;
  17575. /** @hidden */
  17576. _recreateRenderEffect(): void;
  17577. /**
  17578. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17579. * @param preWarm defines if we are in the pre-warmimg phase
  17580. */
  17581. animate(preWarm?: boolean): void;
  17582. private _createFactorGradientTexture;
  17583. private _createSizeGradientTexture;
  17584. private _createAngularSpeedGradientTexture;
  17585. private _createVelocityGradientTexture;
  17586. private _createLimitVelocityGradientTexture;
  17587. private _createDragGradientTexture;
  17588. private _createColorGradientTexture;
  17589. /**
  17590. * Renders the particle system in its current state
  17591. * @param preWarm defines if the system should only update the particles but not render them
  17592. * @returns the current number of particles
  17593. */
  17594. render(preWarm?: boolean): number;
  17595. /**
  17596. * Rebuilds the particle system
  17597. */
  17598. rebuild(): void;
  17599. private _releaseBuffers;
  17600. private _releaseVAOs;
  17601. /**
  17602. * Disposes the particle system and free the associated resources
  17603. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17604. */
  17605. dispose(disposeTexture?: boolean): void;
  17606. /**
  17607. * Clones the particle system.
  17608. * @param name The name of the cloned object
  17609. * @param newEmitter The new emitter to use
  17610. * @returns the cloned particle system
  17611. */
  17612. clone(name: string, newEmitter: any): GPUParticleSystem;
  17613. /**
  17614. * Serializes the particle system to a JSON object.
  17615. * @returns the JSON object
  17616. */
  17617. serialize(): any;
  17618. /**
  17619. * Parses a JSON object to create a GPU particle system.
  17620. * @param parsedParticleSystem The JSON object to parse
  17621. * @param scene The scene to create the particle system in
  17622. * @param rootUrl The root url to use to load external dependencies like texture
  17623. * @returns the parsed GPU particle system
  17624. */
  17625. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17626. }
  17627. }
  17628. declare module BABYLON {
  17629. /**
  17630. * Interface representing a particle system in Babylon.js.
  17631. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17632. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17633. */
  17634. interface IParticleSystem {
  17635. /**
  17636. * List of animations used by the particle system.
  17637. */
  17638. animations: Animation[];
  17639. /**
  17640. * The id of the Particle system.
  17641. */
  17642. id: string;
  17643. /**
  17644. * The name of the Particle system.
  17645. */
  17646. name: string;
  17647. /**
  17648. * The emitter represents the Mesh or position we are attaching the particle system to.
  17649. */
  17650. emitter: Nullable<AbstractMesh | Vector3>;
  17651. /**
  17652. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17653. */
  17654. isBillboardBased: boolean;
  17655. /**
  17656. * The rendering group used by the Particle system to chose when to render.
  17657. */
  17658. renderingGroupId: number;
  17659. /**
  17660. * The layer mask we are rendering the particles through.
  17661. */
  17662. layerMask: number;
  17663. /**
  17664. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17665. */
  17666. updateSpeed: number;
  17667. /**
  17668. * The amount of time the particle system is running (depends of the overall update speed).
  17669. */
  17670. targetStopDuration: number;
  17671. /**
  17672. * The texture used to render each particle. (this can be a spritesheet)
  17673. */
  17674. particleTexture: Nullable<Texture>;
  17675. /**
  17676. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17677. */
  17678. blendMode: number;
  17679. /**
  17680. * Minimum life time of emitting particles.
  17681. */
  17682. minLifeTime: number;
  17683. /**
  17684. * Maximum life time of emitting particles.
  17685. */
  17686. maxLifeTime: number;
  17687. /**
  17688. * Minimum Size of emitting particles.
  17689. */
  17690. minSize: number;
  17691. /**
  17692. * Maximum Size of emitting particles.
  17693. */
  17694. maxSize: number;
  17695. /**
  17696. * Minimum scale of emitting particles on X axis.
  17697. */
  17698. minScaleX: number;
  17699. /**
  17700. * Maximum scale of emitting particles on X axis.
  17701. */
  17702. maxScaleX: number;
  17703. /**
  17704. * Minimum scale of emitting particles on Y axis.
  17705. */
  17706. minScaleY: number;
  17707. /**
  17708. * Maximum scale of emitting particles on Y axis.
  17709. */
  17710. maxScaleY: number;
  17711. /**
  17712. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17713. */
  17714. color1: Color4;
  17715. /**
  17716. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17717. */
  17718. color2: Color4;
  17719. /**
  17720. * Color the particle will have at the end of its lifetime.
  17721. */
  17722. colorDead: Color4;
  17723. /**
  17724. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17725. */
  17726. emitRate: number;
  17727. /**
  17728. * You can use gravity if you want to give an orientation to your particles.
  17729. */
  17730. gravity: Vector3;
  17731. /**
  17732. * Minimum power of emitting particles.
  17733. */
  17734. minEmitPower: number;
  17735. /**
  17736. * Maximum power of emitting particles.
  17737. */
  17738. maxEmitPower: number;
  17739. /**
  17740. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17741. */
  17742. minAngularSpeed: number;
  17743. /**
  17744. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17745. */
  17746. maxAngularSpeed: number;
  17747. /**
  17748. * Gets or sets the minimal initial rotation in radians.
  17749. */
  17750. minInitialRotation: number;
  17751. /**
  17752. * Gets or sets the maximal initial rotation in radians.
  17753. */
  17754. maxInitialRotation: number;
  17755. /**
  17756. * The particle emitter type defines the emitter used by the particle system.
  17757. * It can be for example box, sphere, or cone...
  17758. */
  17759. particleEmitterType: Nullable<IParticleEmitterType>;
  17760. /**
  17761. * 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
  17762. */
  17763. preWarmCycles: number;
  17764. /**
  17765. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17766. */
  17767. preWarmStepOffset: number;
  17768. /**
  17769. * 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)
  17770. */
  17771. spriteCellChangeSpeed: number;
  17772. /**
  17773. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17774. */
  17775. startSpriteCellID: number;
  17776. /**
  17777. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17778. */
  17779. endSpriteCellID: number;
  17780. /**
  17781. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17782. */
  17783. spriteCellWidth: number;
  17784. /**
  17785. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17786. */
  17787. spriteCellHeight: number;
  17788. /**
  17789. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17790. */
  17791. spriteRandomStartCell: boolean;
  17792. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17793. translationPivot: Vector2;
  17794. /**
  17795. * Gets or sets a texture used to add random noise to particle positions
  17796. */
  17797. noiseTexture: Nullable<BaseTexture>;
  17798. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17799. noiseStrength: Vector3;
  17800. /**
  17801. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17802. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  17803. */
  17804. billboardMode: number;
  17805. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17806. limitVelocityDamping: number;
  17807. /**
  17808. * Gets the maximum number of particles active at the same time.
  17809. * @returns The max number of active particles.
  17810. */
  17811. getCapacity(): number;
  17812. /**
  17813. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17814. * @returns True if it has been started, otherwise false.
  17815. */
  17816. isStarted(): boolean;
  17817. /**
  17818. * Animates the particle system for this frame.
  17819. */
  17820. animate(): void;
  17821. /**
  17822. * Renders the particle system in its current state.
  17823. * @returns the current number of particles
  17824. */
  17825. render(): number;
  17826. /**
  17827. * Dispose the particle system and frees its associated resources.
  17828. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17829. */
  17830. dispose(disposeTexture?: boolean): void;
  17831. /**
  17832. * Clones the particle system.
  17833. * @param name The name of the cloned object
  17834. * @param newEmitter The new emitter to use
  17835. * @returns the cloned particle system
  17836. */
  17837. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17838. /**
  17839. * Serializes the particle system to a JSON object.
  17840. * @returns the JSON object
  17841. */
  17842. serialize(): any;
  17843. /**
  17844. * Rebuild the particle system
  17845. */
  17846. rebuild(): void;
  17847. /**
  17848. * Starts the particle system and begins to emit
  17849. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17850. */
  17851. start(delay?: number): void;
  17852. /**
  17853. * Stops the particle system.
  17854. */
  17855. stop(): void;
  17856. /**
  17857. * Remove all active particles
  17858. */
  17859. reset(): void;
  17860. /**
  17861. * Is this system ready to be used/rendered
  17862. * @return true if the system is ready
  17863. */
  17864. isReady(): boolean;
  17865. /**
  17866. * Adds a new color gradient
  17867. * @param gradient defines the gradient to use (between 0 and 1)
  17868. * @param color defines the color to affect to the specified gradient
  17869. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17870. * @returns the current particle system
  17871. */
  17872. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17873. /**
  17874. * Remove a specific color gradient
  17875. * @param gradient defines the gradient to remove
  17876. * @returns the current particle system
  17877. */
  17878. removeColorGradient(gradient: number): IParticleSystem;
  17879. /**
  17880. * Adds a new size gradient
  17881. * @param gradient defines the gradient to use (between 0 and 1)
  17882. * @param factor defines the size factor to affect to the specified gradient
  17883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17884. * @returns the current particle system
  17885. */
  17886. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17887. /**
  17888. * Remove a specific size gradient
  17889. * @param gradient defines the gradient to remove
  17890. * @returns the current particle system
  17891. */
  17892. removeSizeGradient(gradient: number): IParticleSystem;
  17893. /**
  17894. * Gets the current list of color gradients.
  17895. * You must use addColorGradient and removeColorGradient to udpate this list
  17896. * @returns the list of color gradients
  17897. */
  17898. getColorGradients(): Nullable<Array<ColorGradient>>;
  17899. /**
  17900. * Gets the current list of size gradients.
  17901. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17902. * @returns the list of size gradients
  17903. */
  17904. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17905. /**
  17906. * Gets the current list of angular speed gradients.
  17907. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17908. * @returns the list of angular speed gradients
  17909. */
  17910. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17911. /**
  17912. * Adds a new angular speed gradient
  17913. * @param gradient defines the gradient to use (between 0 and 1)
  17914. * @param factor defines the angular speed to affect to the specified gradient
  17915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17916. * @returns the current particle system
  17917. */
  17918. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17919. /**
  17920. * Remove a specific angular speed gradient
  17921. * @param gradient defines the gradient to remove
  17922. * @returns the current particle system
  17923. */
  17924. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17925. /**
  17926. * Gets the current list of velocity gradients.
  17927. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17928. * @returns the list of velocity gradients
  17929. */
  17930. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17931. /**
  17932. * Adds a new velocity gradient
  17933. * @param gradient defines the gradient to use (between 0 and 1)
  17934. * @param factor defines the velocity to affect to the specified gradient
  17935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17936. * @returns the current particle system
  17937. */
  17938. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17939. /**
  17940. * Remove a specific velocity gradient
  17941. * @param gradient defines the gradient to remove
  17942. * @returns the current particle system
  17943. */
  17944. removeVelocityGradient(gradient: number): IParticleSystem;
  17945. /**
  17946. * Gets the current list of limit velocity gradients.
  17947. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17948. * @returns the list of limit velocity gradients
  17949. */
  17950. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17951. /**
  17952. * Adds a new limit velocity gradient
  17953. * @param gradient defines the gradient to use (between 0 and 1)
  17954. * @param factor defines the limit velocity to affect to the specified gradient
  17955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17956. * @returns the current particle system
  17957. */
  17958. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17959. /**
  17960. * Remove a specific limit velocity gradient
  17961. * @param gradient defines the gradient to remove
  17962. * @returns the current particle system
  17963. */
  17964. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17965. /**
  17966. * Adds a new drag gradient
  17967. * @param gradient defines the gradient to use (between 0 and 1)
  17968. * @param factor defines the drag to affect to the specified gradient
  17969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17970. * @returns the current particle system
  17971. */
  17972. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17973. /**
  17974. * Remove a specific drag gradient
  17975. * @param gradient defines the gradient to remove
  17976. * @returns the current particle system
  17977. */
  17978. removeDragGradient(gradient: number): IParticleSystem;
  17979. /**
  17980. * Gets the current list of drag gradients.
  17981. * You must use addDragGradient and removeDragGradient to udpate this list
  17982. * @returns the list of drag gradients
  17983. */
  17984. getDragGradients(): Nullable<Array<FactorGradient>>;
  17985. /**
  17986. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17987. * @param gradient defines the gradient to use (between 0 and 1)
  17988. * @param factor defines the emit rate to affect to the specified gradient
  17989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17990. * @returns the current particle system
  17991. */
  17992. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17993. /**
  17994. * Remove a specific emit rate gradient
  17995. * @param gradient defines the gradient to remove
  17996. * @returns the current particle system
  17997. */
  17998. removeEmitRateGradient(gradient: number): IParticleSystem;
  17999. /**
  18000. * Gets the current list of emit rate gradients.
  18001. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18002. * @returns the list of emit rate gradients
  18003. */
  18004. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18005. /**
  18006. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18007. * @param gradient defines the gradient to use (between 0 and 1)
  18008. * @param factor defines the start size to affect to the specified gradient
  18009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18010. * @returns the current particle system
  18011. */
  18012. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18013. /**
  18014. * Remove a specific start size gradient
  18015. * @param gradient defines the gradient to remove
  18016. * @returns the current particle system
  18017. */
  18018. removeStartSizeGradient(gradient: number): IParticleSystem;
  18019. /**
  18020. * Gets the current list of start size gradients.
  18021. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18022. * @returns the list of start size gradients
  18023. */
  18024. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18025. /**
  18026. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18027. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18028. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18029. * @returns the emitter
  18030. */
  18031. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18032. /**
  18033. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18034. * @param radius The radius of the hemisphere to emit from
  18035. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18036. * @returns the emitter
  18037. */
  18038. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18039. /**
  18040. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18041. * @param radius The radius of the sphere to emit from
  18042. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18043. * @returns the emitter
  18044. */
  18045. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18046. /**
  18047. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18048. * @param radius The radius of the sphere to emit from
  18049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18051. * @returns the emitter
  18052. */
  18053. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18054. /**
  18055. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18056. * @param radius The radius of the emission cylinder
  18057. * @param height The height of the emission cylinder
  18058. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18059. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18060. * @returns the emitter
  18061. */
  18062. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18063. /**
  18064. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18065. * @param radius The radius of the cylinder to emit from
  18066. * @param height The height of the emission cylinder
  18067. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18070. * @returns the emitter
  18071. */
  18072. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18073. /**
  18074. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18075. * @param radius The radius of the cone to emit from
  18076. * @param angle The base angle of the cone
  18077. * @returns the emitter
  18078. */
  18079. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18080. /**
  18081. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18084. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18085. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18086. * @returns the emitter
  18087. */
  18088. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18089. /**
  18090. * Get hosting scene
  18091. * @returns the scene
  18092. */
  18093. getScene(): Scene;
  18094. }
  18095. }
  18096. declare module BABYLON {
  18097. /**
  18098. * A particle represents one of the element emitted by a particle system.
  18099. * This is mainly define by its coordinates, direction, velocity and age.
  18100. */
  18101. class Particle {
  18102. /**
  18103. * The particle system the particle belongs to.
  18104. */
  18105. particleSystem: ParticleSystem;
  18106. /**
  18107. * The world position of the particle in the scene.
  18108. */
  18109. position: Vector3;
  18110. /**
  18111. * The world direction of the particle in the scene.
  18112. */
  18113. direction: Vector3;
  18114. /**
  18115. * The color of the particle.
  18116. */
  18117. color: Color4;
  18118. /**
  18119. * The color change of the particle per step.
  18120. */
  18121. colorStep: Color4;
  18122. /**
  18123. * Defines how long will the life of the particle be.
  18124. */
  18125. lifeTime: number;
  18126. /**
  18127. * The current age of the particle.
  18128. */
  18129. age: number;
  18130. /**
  18131. * The current size of the particle.
  18132. */
  18133. size: number;
  18134. /**
  18135. * The current scale of the particle.
  18136. */
  18137. scale: Vector2;
  18138. /**
  18139. * The current angle of the particle.
  18140. */
  18141. angle: number;
  18142. /**
  18143. * Defines how fast is the angle changing.
  18144. */
  18145. angularSpeed: number;
  18146. /**
  18147. * Defines the cell index used by the particle to be rendered from a sprite.
  18148. */
  18149. cellIndex: number;
  18150. /** @hidden */
  18151. _randomCellOffset?: number;
  18152. /** @hidden */
  18153. _initialDirection: Nullable<Vector3>;
  18154. /** @hidden */
  18155. _initialStartSpriteCellID: number;
  18156. _initialEndSpriteCellID: number;
  18157. /** @hidden */
  18158. _currentColorGradient: Nullable<ColorGradient>;
  18159. /** @hidden */
  18160. _currentColor1: Color4;
  18161. /** @hidden */
  18162. _currentColor2: Color4;
  18163. /** @hidden */
  18164. _currentSizeGradient: Nullable<FactorGradient>;
  18165. /** @hidden */
  18166. _currentSize1: number;
  18167. /** @hidden */
  18168. _currentSize2: number;
  18169. /** @hidden */
  18170. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18171. /** @hidden */
  18172. _currentAngularSpeed1: number;
  18173. /** @hidden */
  18174. _currentAngularSpeed2: number;
  18175. /** @hidden */
  18176. _currentVelocityGradient: Nullable<FactorGradient>;
  18177. /** @hidden */
  18178. _currentVelocity1: number;
  18179. /** @hidden */
  18180. _currentVelocity2: number;
  18181. /** @hidden */
  18182. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18183. /** @hidden */
  18184. _currentLimitVelocity1: number;
  18185. /** @hidden */
  18186. _currentLimitVelocity2: number;
  18187. /** @hidden */
  18188. _currentDragGradient: Nullable<FactorGradient>;
  18189. /** @hidden */
  18190. _currentDrag1: number;
  18191. /** @hidden */
  18192. _currentDrag2: number;
  18193. /**
  18194. * Creates a new instance Particle
  18195. * @param particleSystem the particle system the particle belongs to
  18196. */
  18197. constructor(
  18198. /**
  18199. * The particle system the particle belongs to.
  18200. */
  18201. particleSystem: ParticleSystem);
  18202. private updateCellInfoFromSystem;
  18203. /**
  18204. * Defines how the sprite cell index is updated for the particle
  18205. */
  18206. updateCellIndex(): void;
  18207. /** @hidden */
  18208. _reset(): void;
  18209. /**
  18210. * Copy the properties of particle to another one.
  18211. * @param other the particle to copy the information to.
  18212. */
  18213. copyTo(other: Particle): void;
  18214. }
  18215. }
  18216. declare module BABYLON {
  18217. /**
  18218. * This class is made for on one-liner static method to help creating particle system set.
  18219. */
  18220. class ParticleHelper {
  18221. /**
  18222. * Gets or sets base Assets URL
  18223. */
  18224. static BaseAssetsUrl: string;
  18225. /**
  18226. * Create a default particle system that you can tweak
  18227. * @param emitter defines the emitter to use
  18228. * @param capacity defines the system capacity (default is 500 particles)
  18229. * @param scene defines the hosting scene
  18230. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  18231. * @returns the new Particle system
  18232. */
  18233. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  18234. /**
  18235. * This is the main static method (one-liner) of this helper to create different particle systems
  18236. * @param type This string represents the type to the particle system to create
  18237. * @param scene The scene where the particle system should live
  18238. * @param gpu If the system will use gpu
  18239. * @returns the ParticleSystemSet created
  18240. */
  18241. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  18242. /**
  18243. * Static function used to export a particle system to a ParticleSystemSet variable.
  18244. * Please note that the emitter shape is not exported
  18245. * @param system defines the particle systems to export
  18246. */
  18247. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  18248. }
  18249. }
  18250. declare module BABYLON {
  18251. /**
  18252. * This represents a particle system in Babylon.
  18253. * 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.
  18254. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  18255. * @example https://doc.babylonjs.com/babylon101/particles
  18256. */
  18257. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  18258. /**
  18259. * This function can be defined to provide custom update for active particles.
  18260. * This function will be called instead of regular update (age, position, color, etc.).
  18261. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  18262. */
  18263. updateFunction: (particles: Particle[]) => void;
  18264. private _emitterWorldMatrix;
  18265. /**
  18266. * This function can be defined to specify initial direction for every new particle.
  18267. * It by default use the emitterType defined function
  18268. */
  18269. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  18270. /**
  18271. * This function can be defined to specify initial position for every new particle.
  18272. * It by default use the emitterType defined function
  18273. */
  18274. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  18275. /**
  18276. * An event triggered when the system is disposed
  18277. */
  18278. onDisposeObservable: Observable<ParticleSystem>;
  18279. private _onDisposeObserver;
  18280. /**
  18281. * Sets a callback that will be triggered when the system is disposed
  18282. */
  18283. onDispose: () => void;
  18284. private _particles;
  18285. private _epsilon;
  18286. private _capacity;
  18287. private _stockParticles;
  18288. private _newPartsExcess;
  18289. private _vertexData;
  18290. private _vertexBuffer;
  18291. private _vertexBuffers;
  18292. private _spriteBuffer;
  18293. private _indexBuffer;
  18294. private _effect;
  18295. private _customEffect;
  18296. private _cachedDefines;
  18297. private _scaledColorStep;
  18298. private _colorDiff;
  18299. private _scaledDirection;
  18300. private _scaledGravity;
  18301. private _currentRenderId;
  18302. private _alive;
  18303. private _useInstancing;
  18304. private _started;
  18305. private _stopped;
  18306. private _actualFrame;
  18307. private _scaledUpdateSpeed;
  18308. private _vertexBufferSize;
  18309. /** @hidden */
  18310. _currentEmitRateGradient: Nullable<FactorGradient>;
  18311. /** @hidden */
  18312. _currentEmitRate1: number;
  18313. /** @hidden */
  18314. _currentEmitRate2: number;
  18315. /** @hidden */
  18316. _currentStartSizeGradient: Nullable<FactorGradient>;
  18317. /** @hidden */
  18318. _currentStartSize1: number;
  18319. /** @hidden */
  18320. _currentStartSize2: number;
  18321. /**
  18322. * 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.
  18323. */
  18324. subEmitters: ParticleSystem[];
  18325. /**
  18326. * The current active Sub-systems, this property is used by the root particle system only.
  18327. */
  18328. activeSubSystems: Array<ParticleSystem>;
  18329. private _rootParticleSystem;
  18330. /**
  18331. * Gets the current list of active particles
  18332. */
  18333. readonly particles: Particle[];
  18334. /**
  18335. * Returns the string "ParticleSystem"
  18336. * @returns a string containing the class name
  18337. */
  18338. getClassName(): string;
  18339. /**
  18340. * Instantiates a particle system.
  18341. * 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.
  18342. * @param name The name of the particle system
  18343. * @param capacity The max number of particles alive at the same time
  18344. * @param scene The scene the particle system belongs to
  18345. * @param customEffect a custom effect used to change the way particles are rendered by default
  18346. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18347. * @param epsilon Offset used to render the particles
  18348. */
  18349. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18350. private _addFactorGradient;
  18351. private _removeFactorGradient;
  18352. /**
  18353. * Adds a new life time gradient
  18354. * @param gradient defines the gradient to use (between 0 and 1)
  18355. * @param factor defines the life time factor to affect to the specified gradient
  18356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18357. * @returns the current particle system
  18358. */
  18359. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18360. /**
  18361. * Remove a specific life time gradient
  18362. * @param gradient defines the gradient to remove
  18363. * @returns the current particle system
  18364. */
  18365. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18366. /**
  18367. * Adds a new size gradient
  18368. * @param gradient defines the gradient to use (between 0 and 1)
  18369. * @param factor defines the size factor to affect to the specified gradient
  18370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18371. * @returns the current particle system
  18372. */
  18373. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18374. /**
  18375. * Remove a specific size gradient
  18376. * @param gradient defines the gradient to remove
  18377. * @returns the current particle system
  18378. */
  18379. removeSizeGradient(gradient: number): IParticleSystem;
  18380. /**
  18381. * Adds a new angular speed gradient
  18382. * @param gradient defines the gradient to use (between 0 and 1)
  18383. * @param factor defines the angular speed to affect to the specified gradient
  18384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18385. * @returns the current particle system
  18386. */
  18387. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18388. /**
  18389. * Remove a specific angular speed gradient
  18390. * @param gradient defines the gradient to remove
  18391. * @returns the current particle system
  18392. */
  18393. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18394. /**
  18395. * Adds a new velocity gradient
  18396. * @param gradient defines the gradient to use (between 0 and 1)
  18397. * @param factor defines the velocity to affect to the specified gradient
  18398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18399. * @returns the current particle system
  18400. */
  18401. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18402. /**
  18403. * Remove a specific velocity gradient
  18404. * @param gradient defines the gradient to remove
  18405. * @returns the current particle system
  18406. */
  18407. removeVelocityGradient(gradient: number): IParticleSystem;
  18408. /**
  18409. * Adds a new limit velocity gradient
  18410. * @param gradient defines the gradient to use (between 0 and 1)
  18411. * @param factor defines the limit velocity value to affect to the specified gradient
  18412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18413. * @returns the current particle system
  18414. */
  18415. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18416. /**
  18417. * Remove a specific limit velocity gradient
  18418. * @param gradient defines the gradient to remove
  18419. * @returns the current particle system
  18420. */
  18421. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18422. /**
  18423. * Adds a new drag gradient
  18424. * @param gradient defines the gradient to use (between 0 and 1)
  18425. * @param factor defines the drag value to affect to the specified gradient
  18426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18427. * @returns the current particle system
  18428. */
  18429. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18430. /**
  18431. * Remove a specific drag gradient
  18432. * @param gradient defines the gradient to remove
  18433. * @returns the current particle system
  18434. */
  18435. removeDragGradient(gradient: number): IParticleSystem;
  18436. /**
  18437. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18438. * @param gradient defines the gradient to use (between 0 and 1)
  18439. * @param factor defines the emit rate value to affect to the specified gradient
  18440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18441. * @returns the current particle system
  18442. */
  18443. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18444. /**
  18445. * Remove a specific emit rate gradient
  18446. * @param gradient defines the gradient to remove
  18447. * @returns the current particle system
  18448. */
  18449. removeEmitRateGradient(gradient: number): IParticleSystem;
  18450. /**
  18451. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18452. * @param gradient defines the gradient to use (between 0 and 1)
  18453. * @param factor defines the start size value to affect to the specified gradient
  18454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18455. * @returns the current particle system
  18456. */
  18457. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18458. /**
  18459. * Remove a specific start size gradient
  18460. * @param gradient defines the gradient to remove
  18461. * @returns the current particle system
  18462. */
  18463. removeStartSizeGradient(gradient: number): IParticleSystem;
  18464. /**
  18465. * Adds a new color gradient
  18466. * @param gradient defines the gradient to use (between 0 and 1)
  18467. * @param color defines the color to affect to the specified gradient
  18468. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18469. */
  18470. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  18471. /**
  18472. * Remove a specific color gradient
  18473. * @param gradient defines the gradient to remove
  18474. */
  18475. removeColorGradient(gradient: number): IParticleSystem;
  18476. private _fetchR;
  18477. protected _reset(): void;
  18478. private _resetEffect;
  18479. private _createVertexBuffers;
  18480. private _createIndexBuffer;
  18481. /**
  18482. * Gets the maximum number of particles active at the same time.
  18483. * @returns The max number of active particles.
  18484. */
  18485. getCapacity(): number;
  18486. /**
  18487. * Gets whether there are still active particles in the system.
  18488. * @returns True if it is alive, otherwise false.
  18489. */
  18490. isAlive(): boolean;
  18491. /**
  18492. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18493. * @returns True if it has been started, otherwise false.
  18494. */
  18495. isStarted(): boolean;
  18496. /**
  18497. * Starts the particle system and begins to emit
  18498. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18499. */
  18500. start(delay?: number): void;
  18501. /**
  18502. * Stops the particle system.
  18503. * @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.
  18504. */
  18505. stop(stopSubEmitters?: boolean): void;
  18506. /**
  18507. * Remove all active particles
  18508. */
  18509. reset(): void;
  18510. /**
  18511. * @hidden (for internal use only)
  18512. */
  18513. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18514. /**
  18515. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18516. * Its lifetime will start back at 0.
  18517. */
  18518. recycleParticle: (particle: Particle) => void;
  18519. private _stopSubEmitters;
  18520. private _createParticle;
  18521. private _removeFromRoot;
  18522. private _emitFromParticle;
  18523. private _update;
  18524. /** @hidden */
  18525. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  18526. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18527. private _getEffect;
  18528. /**
  18529. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18530. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18531. */
  18532. animate(preWarmOnly?: boolean): void;
  18533. private _appendParticleVertices;
  18534. /**
  18535. * Rebuilds the particle system.
  18536. */
  18537. rebuild(): void;
  18538. /**
  18539. * Is this system ready to be used/rendered
  18540. * @return true if the system is ready
  18541. */
  18542. isReady(): boolean;
  18543. /**
  18544. * Renders the particle system in its current state.
  18545. * @returns the current number of particles
  18546. */
  18547. render(): number;
  18548. /**
  18549. * Disposes the particle system and free the associated resources
  18550. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18551. */
  18552. dispose(disposeTexture?: boolean): void;
  18553. /**
  18554. * Clones the particle system.
  18555. * @param name The name of the cloned object
  18556. * @param newEmitter The new emitter to use
  18557. * @returns the cloned particle system
  18558. */
  18559. clone(name: string, newEmitter: any): ParticleSystem;
  18560. /**
  18561. * Serializes the particle system to a JSON object.
  18562. * @returns the JSON object
  18563. */
  18564. serialize(): any;
  18565. /** @hidden */
  18566. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18567. /** @hidden */
  18568. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18569. /**
  18570. * Parses a JSON object to create a particle system.
  18571. * @param parsedParticleSystem The JSON object to parse
  18572. * @param scene The scene to create the particle system in
  18573. * @param rootUrl The root url to use to load external dependencies like texture
  18574. * @returns the Parsed particle system
  18575. */
  18576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. interface Engine {
  18581. /**
  18582. * Create an effect to use with particle systems.
  18583. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  18584. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  18585. * @param uniformsNames defines a list of attribute names
  18586. * @param samplers defines an array of string used to represent textures
  18587. * @param defines defines the string containing the defines to use to compile the shaders
  18588. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  18589. * @param onCompiled defines a function to call when the effect creation is successful
  18590. * @param onError defines a function to call when the effect creation has failed
  18591. * @returns the new Effect
  18592. */
  18593. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  18594. }
  18595. }
  18596. declare module BABYLON {
  18597. /**
  18598. * Represents a set of particle systems working together to create a specific effect
  18599. */
  18600. class ParticleSystemSet implements IDisposable {
  18601. private _emitterCreationOptions;
  18602. private _emitterNode;
  18603. /**
  18604. * Gets the particle system list
  18605. */
  18606. systems: IParticleSystem[];
  18607. /**
  18608. * Gets the emitter node used with this set
  18609. */
  18610. readonly emitterNode: Nullable<TransformNode>;
  18611. /**
  18612. * Creates a new emitter mesh as a sphere
  18613. * @param options defines the options used to create the sphere
  18614. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  18615. * @param scene defines the hosting scene
  18616. */
  18617. setEmitterAsSphere(options: {
  18618. diameter: number;
  18619. segments: number;
  18620. color: Color3;
  18621. }, renderingGroupId: number, scene: Scene): void;
  18622. /**
  18623. * Starts all particle systems of the set
  18624. * @param emitter defines an optional mesh to use as emitter for the particle systems
  18625. */
  18626. start(emitter?: AbstractMesh): void;
  18627. /**
  18628. * Release all associated resources
  18629. */
  18630. dispose(): void;
  18631. /**
  18632. * Serialize the set into a JSON compatible object
  18633. * @returns a JSON compatible representation of the set
  18634. */
  18635. serialize(): any;
  18636. /**
  18637. * Parse a new ParticleSystemSet from a serialized source
  18638. * @param data defines a JSON compatible representation of the set
  18639. * @param scene defines the hosting scene
  18640. * @param gpu defines if we want GPU particles or CPU particles
  18641. * @returns a new ParticleSystemSet
  18642. */
  18643. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  18644. }
  18645. }
  18646. declare module BABYLON {
  18647. /**
  18648. * Represents one particle of a solid particle system.
  18649. */
  18650. class SolidParticle {
  18651. /**
  18652. * particle global index
  18653. */
  18654. idx: number;
  18655. /**
  18656. * The color of the particle
  18657. */
  18658. color: Nullable<Color4>;
  18659. /**
  18660. * The world space position of the particle.
  18661. */
  18662. position: Vector3;
  18663. /**
  18664. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18665. */
  18666. rotation: Vector3;
  18667. /**
  18668. * The world space rotation quaternion of the particle.
  18669. */
  18670. rotationQuaternion: Nullable<Quaternion>;
  18671. /**
  18672. * The scaling of the particle.
  18673. */
  18674. scaling: Vector3;
  18675. /**
  18676. * The uvs of the particle.
  18677. */
  18678. uvs: Vector4;
  18679. /**
  18680. * The current speed of the particle.
  18681. */
  18682. velocity: Vector3;
  18683. /**
  18684. * The pivot point in the particle local space.
  18685. */
  18686. pivot: Vector3;
  18687. /**
  18688. * Must the particle be translated from its pivot point in its local space ?
  18689. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18690. * Default : false
  18691. */
  18692. translateFromPivot: boolean;
  18693. /**
  18694. * Is the particle active or not ?
  18695. */
  18696. alive: boolean;
  18697. /**
  18698. * Is the particle visible or not ?
  18699. */
  18700. isVisible: boolean;
  18701. /**
  18702. * Index of this particle in the global "positions" array (Internal use)
  18703. * @hidden
  18704. */
  18705. _pos: number;
  18706. /**
  18707. * @hidden Index of this particle in the global "indices" array (Internal use)
  18708. */
  18709. _ind: number;
  18710. /**
  18711. * @hidden ModelShape of this particle (Internal use)
  18712. */
  18713. _model: ModelShape;
  18714. /**
  18715. * ModelShape id of this particle
  18716. */
  18717. shapeId: number;
  18718. /**
  18719. * Index of the particle in its shape id (Internal use)
  18720. */
  18721. idxInShape: number;
  18722. /**
  18723. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  18724. */
  18725. _modelBoundingInfo: BoundingInfo;
  18726. /**
  18727. * @hidden Particle BoundingInfo object (Internal use)
  18728. */
  18729. _boundingInfo: BoundingInfo;
  18730. /**
  18731. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  18732. */
  18733. _sps: SolidParticleSystem;
  18734. /**
  18735. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  18736. */
  18737. _stillInvisible: boolean;
  18738. /**
  18739. * @hidden Last computed particle rotation matrix
  18740. */
  18741. _rotationMatrix: number[];
  18742. /**
  18743. * Parent particle Id, if any.
  18744. * Default null.
  18745. */
  18746. parentId: Nullable<number>;
  18747. /**
  18748. * @hidden Internal global position in the SPS.
  18749. */
  18750. _globalPosition: Vector3;
  18751. /**
  18752. * Creates a Solid Particle object.
  18753. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18754. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18755. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18756. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18757. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18758. * @param shapeId (integer) is the model shape identifier in the SPS.
  18759. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18760. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18761. */
  18762. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18763. /**
  18764. * Legacy support, changed scale to scaling
  18765. */
  18766. /**
  18767. * Legacy support, changed scale to scaling
  18768. */
  18769. scale: Vector3;
  18770. /**
  18771. * Legacy support, changed quaternion to rotationQuaternion
  18772. */
  18773. /**
  18774. * Legacy support, changed quaternion to rotationQuaternion
  18775. */
  18776. quaternion: Nullable<Quaternion>;
  18777. /**
  18778. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18779. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18780. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18781. * @returns true if it intersects
  18782. */
  18783. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18784. }
  18785. /**
  18786. * Represents the shape of the model used by one particle of a solid particle system.
  18787. * SPS internal tool, don't use it manually.
  18788. */
  18789. class ModelShape {
  18790. /**
  18791. * The shape id
  18792. * @hidden
  18793. */
  18794. shapeID: number;
  18795. /**
  18796. * flat array of model positions (internal use)
  18797. * @hidden
  18798. */
  18799. _shape: Vector3[];
  18800. /**
  18801. * flat array of model UVs (internal use)
  18802. * @hidden
  18803. */
  18804. _shapeUV: number[];
  18805. /**
  18806. * length of the shape in the model indices array (internal use)
  18807. * @hidden
  18808. */
  18809. _indicesLength: number;
  18810. /**
  18811. * Custom position function (internal use)
  18812. * @hidden
  18813. */
  18814. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18815. /**
  18816. * Custom vertex function (internal use)
  18817. * @hidden
  18818. */
  18819. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18820. /**
  18821. * 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.
  18822. * SPS internal tool, don't use it manually.
  18823. * @hidden
  18824. */
  18825. 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>);
  18826. }
  18827. /**
  18828. * Represents a Depth Sorted Particle in the solid particle system.
  18829. */
  18830. class DepthSortedParticle {
  18831. /**
  18832. * Index of the particle in the "indices" array
  18833. */
  18834. ind: number;
  18835. /**
  18836. * Length of the particle shape in the "indices" array
  18837. */
  18838. indicesLength: number;
  18839. /**
  18840. * Squared distance from the particle to the camera
  18841. */
  18842. sqDistance: number;
  18843. }
  18844. }
  18845. declare module BABYLON {
  18846. /**
  18847. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18848. *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.
  18849. * The SPS is also a particle system. It provides some methods to manage the particles.
  18850. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18851. *
  18852. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18853. */
  18854. class SolidParticleSystem implements IDisposable {
  18855. /**
  18856. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18857. * Example : var p = SPS.particles[i];
  18858. */
  18859. particles: SolidParticle[];
  18860. /**
  18861. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18862. */
  18863. nbParticles: number;
  18864. /**
  18865. * If the particles must ever face the camera (default false). Useful for planar particles.
  18866. */
  18867. billboard: boolean;
  18868. /**
  18869. * Recompute normals when adding a shape
  18870. */
  18871. recomputeNormals: boolean;
  18872. /**
  18873. * This a counter ofr your own usage. It's not set by any SPS functions.
  18874. */
  18875. counter: number;
  18876. /**
  18877. * The SPS name. This name is also given to the underlying mesh.
  18878. */
  18879. name: string;
  18880. /**
  18881. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18882. */
  18883. mesh: Mesh;
  18884. /**
  18885. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18886. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18887. */
  18888. vars: any;
  18889. /**
  18890. * This array is populated when the SPS is set as 'pickable'.
  18891. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18892. * Each element of this array is an object `{idx: int, faceId: int}`.
  18893. * `idx` is the picked particle index in the `SPS.particles` array
  18894. * `faceId` is the picked face index counted within this particle.
  18895. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18896. */
  18897. pickedParticles: {
  18898. idx: number;
  18899. faceId: number;
  18900. }[];
  18901. /**
  18902. * This array is populated when `enableDepthSort` is set to true.
  18903. * Each element of this array is an instance of the class DepthSortedParticle.
  18904. */
  18905. depthSortedParticles: DepthSortedParticle[];
  18906. /**
  18907. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18908. * @hidden
  18909. */
  18910. _bSphereOnly: boolean;
  18911. /**
  18912. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18913. * @hidden
  18914. */
  18915. _bSphereRadiusFactor: number;
  18916. private _scene;
  18917. private _positions;
  18918. private _indices;
  18919. private _normals;
  18920. private _colors;
  18921. private _uvs;
  18922. private _indices32;
  18923. private _positions32;
  18924. private _normals32;
  18925. private _fixedNormal32;
  18926. private _colors32;
  18927. private _uvs32;
  18928. private _index;
  18929. private _updatable;
  18930. private _pickable;
  18931. private _isVisibilityBoxLocked;
  18932. private _alwaysVisible;
  18933. private _depthSort;
  18934. private _shapeCounter;
  18935. private _copy;
  18936. private _shape;
  18937. private _shapeUV;
  18938. private _color;
  18939. private _computeParticleColor;
  18940. private _computeParticleTexture;
  18941. private _computeParticleRotation;
  18942. private _computeParticleVertex;
  18943. private _computeBoundingBox;
  18944. private _depthSortParticles;
  18945. private _cam_axisZ;
  18946. private _cam_axisY;
  18947. private _cam_axisX;
  18948. private _axisZ;
  18949. private _camera;
  18950. private _particle;
  18951. private _camDir;
  18952. private _camInvertedPosition;
  18953. private _rotMatrix;
  18954. private _invertMatrix;
  18955. private _rotated;
  18956. private _quaternion;
  18957. private _vertex;
  18958. private _normal;
  18959. private _yaw;
  18960. private _pitch;
  18961. private _roll;
  18962. private _halfroll;
  18963. private _halfpitch;
  18964. private _halfyaw;
  18965. private _sinRoll;
  18966. private _cosRoll;
  18967. private _sinPitch;
  18968. private _cosPitch;
  18969. private _sinYaw;
  18970. private _cosYaw;
  18971. private _mustUnrotateFixedNormals;
  18972. private _minimum;
  18973. private _maximum;
  18974. private _minBbox;
  18975. private _maxBbox;
  18976. private _particlesIntersect;
  18977. private _depthSortFunction;
  18978. private _needs32Bits;
  18979. private _pivotBackTranslation;
  18980. private _scaledPivot;
  18981. private _particleHasParent;
  18982. private _parent;
  18983. /**
  18984. * Creates a SPS (Solid Particle System) object.
  18985. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18986. * @param scene (Scene) is the scene in which the SPS is added.
  18987. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18988. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18989. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18990. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18991. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18992. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18993. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18994. */
  18995. constructor(name: string, scene: Scene, options?: {
  18996. updatable?: boolean;
  18997. isPickable?: boolean;
  18998. enableDepthSort?: boolean;
  18999. particleIntersection?: boolean;
  19000. boundingSphereOnly?: boolean;
  19001. bSphereRadiusFactor?: number;
  19002. });
  19003. /**
  19004. * Builds the SPS underlying mesh. Returns a standard Mesh.
  19005. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  19006. * @returns the created mesh
  19007. */
  19008. buildMesh(): Mesh;
  19009. /**
  19010. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  19011. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  19012. * Thus the particles generated from `digest()` have their property `position` set yet.
  19013. * @param mesh ( Mesh ) is the mesh to be digested
  19014. * @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
  19015. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  19016. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  19017. * @returns the current SPS
  19018. */
  19019. digest(mesh: Mesh, options?: {
  19020. facetNb?: number;
  19021. number?: number;
  19022. delta?: number;
  19023. }): SolidParticleSystem;
  19024. private _unrotateFixedNormals;
  19025. private _resetCopy;
  19026. private _meshBuilder;
  19027. private _posToShape;
  19028. private _uvsToShapeUV;
  19029. private _addParticle;
  19030. /**
  19031. * Adds some particles to the SPS from the model shape. Returns the shape id.
  19032. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  19033. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  19034. * @param nb (positive integer) the number of particles to be created from this model
  19035. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  19036. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  19037. * @returns the number of shapes in the system
  19038. */
  19039. addShape(mesh: Mesh, nb: number, options?: {
  19040. positionFunction?: any;
  19041. vertexFunction?: any;
  19042. }): number;
  19043. private _rebuildParticle;
  19044. /**
  19045. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  19046. * @returns the SPS.
  19047. */
  19048. rebuildMesh(): SolidParticleSystem;
  19049. /**
  19050. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  19051. * This method calls `updateParticle()` for each particle of the SPS.
  19052. * For an animated SPS, it is usually called within the render loop.
  19053. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  19054. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  19055. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  19056. * @returns the SPS.
  19057. */
  19058. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  19059. private _quaternionRotationYPR;
  19060. private _quaternionToRotationMatrix;
  19061. /**
  19062. * Disposes the SPS.
  19063. */
  19064. dispose(): void;
  19065. /**
  19066. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  19067. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19068. * @returns the SPS.
  19069. */
  19070. refreshVisibleSize(): SolidParticleSystem;
  19071. /**
  19072. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  19073. * @param size the size (float) of the visibility box
  19074. * note : this doesn't lock the SPS mesh bounding box.
  19075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19076. */
  19077. setVisibilityBox(size: number): void;
  19078. /**
  19079. * Gets whether the SPS as always visible or not
  19080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19081. */
  19082. /**
  19083. * Sets the SPS as always visible or not
  19084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19085. */
  19086. isAlwaysVisible: boolean;
  19087. /**
  19088. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19089. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19090. */
  19091. /**
  19092. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  19093. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  19094. */
  19095. isVisibilityBoxLocked: boolean;
  19096. /**
  19097. * Tells to `setParticles()` to compute the particle rotations or not.
  19098. * Default value : true. The SPS is faster when it's set to false.
  19099. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19100. */
  19101. /**
  19102. * Gets if `setParticles()` computes the particle rotations or not.
  19103. * Default value : true. The SPS is faster when it's set to false.
  19104. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  19105. */
  19106. computeParticleRotation: boolean;
  19107. /**
  19108. * Tells to `setParticles()` to compute the particle colors or not.
  19109. * Default value : true. The SPS is faster when it's set to false.
  19110. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19111. */
  19112. /**
  19113. * Gets if `setParticles()` computes the particle colors or not.
  19114. * Default value : true. The SPS is faster when it's set to false.
  19115. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  19116. */
  19117. computeParticleColor: boolean;
  19118. /**
  19119. * Gets if `setParticles()` computes the particle textures or not.
  19120. * Default value : true. The SPS is faster when it's set to false.
  19121. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  19122. */
  19123. computeParticleTexture: boolean;
  19124. /**
  19125. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  19126. * Default value : false. The SPS is faster when it's set to false.
  19127. * Note : the particle custom vertex positions aren't stored values.
  19128. */
  19129. /**
  19130. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  19131. * Default value : false. The SPS is faster when it's set to false.
  19132. * Note : the particle custom vertex positions aren't stored values.
  19133. */
  19134. computeParticleVertex: boolean;
  19135. /**
  19136. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  19137. */
  19138. /**
  19139. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  19140. */
  19141. computeBoundingBox: boolean;
  19142. /**
  19143. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  19144. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19145. * Default : `true`
  19146. */
  19147. /**
  19148. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  19149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  19150. * Default : `true`
  19151. */
  19152. depthSortParticles: boolean;
  19153. /**
  19154. * This function does nothing. It may be overwritten to set all the particle first values.
  19155. * The SPS doesn't call this function, you may have to call it by your own.
  19156. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19157. */
  19158. initParticles(): void;
  19159. /**
  19160. * This function does nothing. It may be overwritten to recycle a particle.
  19161. * The SPS doesn't call this function, you may have to call it by your own.
  19162. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19163. * @param particle The particle to recycle
  19164. * @returns the recycled particle
  19165. */
  19166. recycleParticle(particle: SolidParticle): SolidParticle;
  19167. /**
  19168. * Updates a particle : this function should be overwritten by the user.
  19169. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  19170. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  19171. * @example : just set a particle position or velocity and recycle conditions
  19172. * @param particle The particle to update
  19173. * @returns the updated particle
  19174. */
  19175. updateParticle(particle: SolidParticle): SolidParticle;
  19176. /**
  19177. * Updates a vertex of a particle : it can be overwritten by the user.
  19178. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  19179. * @param particle the current particle
  19180. * @param vertex the current index of the current particle
  19181. * @param pt the index of the current vertex in the particle shape
  19182. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  19183. * @example : just set a vertex particle position
  19184. * @returns the updated vertex
  19185. */
  19186. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  19187. /**
  19188. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  19189. * This does nothing and may be overwritten by the user.
  19190. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19191. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19192. * @param update the boolean update value actually passed to setParticles()
  19193. */
  19194. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19195. /**
  19196. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  19197. * This will be passed three parameters.
  19198. * This does nothing and may be overwritten by the user.
  19199. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19200. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  19201. * @param update the boolean update value actually passed to setParticles()
  19202. */
  19203. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  19204. }
  19205. }
  19206. declare module BABYLON {
  19207. interface PhysicsImpostorJoint {
  19208. mainImpostor: PhysicsImpostor;
  19209. connectedImpostor: PhysicsImpostor;
  19210. joint: PhysicsJoint;
  19211. }
  19212. class PhysicsEngine {
  19213. private _physicsPlugin;
  19214. gravity: Vector3;
  19215. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  19216. setGravity(gravity: Vector3): void;
  19217. /**
  19218. * Set the time step of the physics engine.
  19219. * default is 1/60.
  19220. * To slow it down, enter 1/600 for example.
  19221. * To speed it up, 1/30
  19222. * @param {number} newTimeStep the new timestep to apply to this world.
  19223. */
  19224. setTimeStep(newTimeStep?: number): void;
  19225. /**
  19226. * Get the time step of the physics engine.
  19227. */
  19228. getTimeStep(): number;
  19229. dispose(): void;
  19230. getPhysicsPluginName(): string;
  19231. static Epsilon: number;
  19232. private _impostors;
  19233. private _joints;
  19234. /**
  19235. * Adding a new impostor for the impostor tracking.
  19236. * This will be done by the impostor itself.
  19237. * @param {PhysicsImpostor} impostor the impostor to add
  19238. */
  19239. addImpostor(impostor: PhysicsImpostor): void;
  19240. /**
  19241. * Remove an impostor from the engine.
  19242. * This impostor and its mesh will not longer be updated by the physics engine.
  19243. * @param {PhysicsImpostor} impostor the impostor to remove
  19244. */
  19245. removeImpostor(impostor: PhysicsImpostor): void;
  19246. /**
  19247. * Add a joint to the physics engine
  19248. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  19249. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  19250. * @param {PhysicsJoint} the joint that will connect both impostors.
  19251. */
  19252. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19253. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19254. /**
  19255. * Called by the scene. no need to call it.
  19256. * @hidden
  19257. */
  19258. _step(delta: number): void;
  19259. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19260. getImpostors(): Array<PhysicsImpostor>;
  19261. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19262. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19263. }
  19264. interface IPhysicsEnginePlugin {
  19265. world: any;
  19266. name: string;
  19267. setGravity(gravity: Vector3): void;
  19268. setTimeStep(timeStep: number): void;
  19269. getTimeStep(): number;
  19270. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19271. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19274. removePhysicsBody(impostor: PhysicsImpostor): void;
  19275. generateJoint(joint: PhysicsImpostorJoint): void;
  19276. removeJoint(joint: PhysicsImpostorJoint): void;
  19277. isSupported(): boolean;
  19278. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19279. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19281. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19282. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19283. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19284. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19285. getBodyMass(impostor: PhysicsImpostor): number;
  19286. getBodyFriction(impostor: PhysicsImpostor): number;
  19287. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19288. getBodyRestitution(impostor: PhysicsImpostor): number;
  19289. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19290. sleepBody(impostor: PhysicsImpostor): void;
  19291. wakeUpBody(impostor: PhysicsImpostor): void;
  19292. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19293. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19295. getRadius(impostor: PhysicsImpostor): number;
  19296. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19297. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19298. dispose(): void;
  19299. }
  19300. }
  19301. declare module BABYLON {
  19302. class PhysicsHelper {
  19303. private _scene;
  19304. private _physicsEngine;
  19305. constructor(scene: Scene);
  19306. /**
  19307. * @param {Vector3} origin the origin of the explosion
  19308. * @param {number} radius the explosion radius
  19309. * @param {number} strength the explosion strength
  19310. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19311. */
  19312. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19313. /**
  19314. * @param {Vector3} origin the origin of the explosion
  19315. * @param {number} radius the explosion radius
  19316. * @param {number} strength the explosion strength
  19317. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19318. */
  19319. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19320. /**
  19321. * @param {Vector3} origin the origin of the explosion
  19322. * @param {number} radius the explosion radius
  19323. * @param {number} strength the explosion strength
  19324. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19325. */
  19326. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  19327. /**
  19328. * @param {Vector3} origin the origin of the updraft
  19329. * @param {number} radius the radius of the updraft
  19330. * @param {number} strength the strength of the updraft
  19331. * @param {number} height the height of the updraft
  19332. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  19333. */
  19334. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  19335. /**
  19336. * @param {Vector3} origin the of the vortex
  19337. * @param {number} radius the radius of the vortex
  19338. * @param {number} strength the strength of the vortex
  19339. * @param {number} height the height of the vortex
  19340. */
  19341. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  19342. }
  19343. /***** Radial explosion *****/
  19344. class PhysicsRadialExplosionEvent {
  19345. private _scene;
  19346. private _sphere;
  19347. private _sphereOptions;
  19348. private _rays;
  19349. private _dataFetched;
  19350. constructor(scene: Scene);
  19351. /**
  19352. * Returns the data related to the radial explosion event (sphere & rays).
  19353. * @returns {PhysicsRadialExplosionEventData}
  19354. */
  19355. getData(): PhysicsRadialExplosionEventData;
  19356. /**
  19357. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  19358. * @param impostor
  19359. * @param {Vector3} origin the origin of the explosion
  19360. * @param {number} radius the explosion radius
  19361. * @param {number} strength the explosion strength
  19362. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  19363. * @returns {Nullable<PhysicsForceAndContactPoint>}
  19364. */
  19365. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  19366. /**
  19367. * Disposes the sphere.
  19368. * @param {bolean} force
  19369. */
  19370. dispose(force?: boolean): void;
  19371. /*** Helpers ***/
  19372. private _prepareSphere;
  19373. private _intersectsWithSphere;
  19374. }
  19375. /***** Gravitational Field *****/
  19376. class PhysicsGravitationalFieldEvent {
  19377. private _physicsHelper;
  19378. private _scene;
  19379. private _origin;
  19380. private _radius;
  19381. private _strength;
  19382. private _falloff;
  19383. private _tickCallback;
  19384. private _sphere;
  19385. private _dataFetched;
  19386. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  19387. /**
  19388. * Returns the data related to the gravitational field event (sphere).
  19389. * @returns {PhysicsGravitationalFieldEventData}
  19390. */
  19391. getData(): PhysicsGravitationalFieldEventData;
  19392. /**
  19393. * Enables the gravitational field.
  19394. */
  19395. enable(): void;
  19396. /**
  19397. * Disables the gravitational field.
  19398. */
  19399. disable(): void;
  19400. /**
  19401. * Disposes the sphere.
  19402. * @param {bolean} force
  19403. */
  19404. dispose(force?: boolean): void;
  19405. private _tick;
  19406. }
  19407. /***** Updraft *****/
  19408. class PhysicsUpdraftEvent {
  19409. private _scene;
  19410. private _origin;
  19411. private _radius;
  19412. private _strength;
  19413. private _height;
  19414. private _updraftMode;
  19415. private _physicsEngine;
  19416. private _originTop;
  19417. private _originDirection;
  19418. private _tickCallback;
  19419. private _cylinder;
  19420. private _cylinderPosition;
  19421. private _dataFetched;
  19422. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  19423. /**
  19424. * Returns the data related to the updraft event (cylinder).
  19425. * @returns {PhysicsUpdraftEventData}
  19426. */
  19427. getData(): PhysicsUpdraftEventData;
  19428. /**
  19429. * Enables the updraft.
  19430. */
  19431. enable(): void;
  19432. /**
  19433. * Disables the cortex.
  19434. */
  19435. disable(): void;
  19436. /**
  19437. * Disposes the sphere.
  19438. * @param {bolean} force
  19439. */
  19440. dispose(force?: boolean): void;
  19441. private getImpostorForceAndContactPoint;
  19442. private _tick;
  19443. /*** Helpers ***/
  19444. private _prepareCylinder;
  19445. private _intersectsWithCylinder;
  19446. }
  19447. /***** Vortex *****/
  19448. class PhysicsVortexEvent {
  19449. private _scene;
  19450. private _origin;
  19451. private _radius;
  19452. private _strength;
  19453. private _height;
  19454. private _physicsEngine;
  19455. private _originTop;
  19456. private _centripetalForceThreshold;
  19457. private _updraftMultiplier;
  19458. private _tickCallback;
  19459. private _cylinder;
  19460. private _cylinderPosition;
  19461. private _dataFetched;
  19462. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  19463. /**
  19464. * Returns the data related to the vortex event (cylinder).
  19465. * @returns {PhysicsVortexEventData}
  19466. */
  19467. getData(): PhysicsVortexEventData;
  19468. /**
  19469. * Enables the vortex.
  19470. */
  19471. enable(): void;
  19472. /**
  19473. * Disables the cortex.
  19474. */
  19475. disable(): void;
  19476. /**
  19477. * Disposes the sphere.
  19478. * @param {bolean} force
  19479. */
  19480. dispose(force?: boolean): void;
  19481. private getImpostorForceAndContactPoint;
  19482. private _tick;
  19483. /*** Helpers ***/
  19484. private _prepareCylinder;
  19485. private _intersectsWithCylinder;
  19486. }
  19487. /***** Enums *****/
  19488. /**
  19489. * The strenght of the force in correspondence to the distance of the affected object
  19490. */
  19491. enum PhysicsRadialImpulseFalloff {
  19492. /** Defines that impulse is constant in strength across it's whole radius */
  19493. Constant = 0,
  19494. /** DEfines that impulse gets weaker if it's further from the origin */
  19495. Linear = 1
  19496. }
  19497. /**
  19498. * The strenght of the force in correspondence to the distance of the affected object
  19499. */
  19500. enum PhysicsUpdraftMode {
  19501. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  19502. Center = 0,
  19503. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  19504. Perpendicular = 1
  19505. }
  19506. /***** Data interfaces *****/
  19507. interface PhysicsForceAndContactPoint {
  19508. force: Vector3;
  19509. contactPoint: Vector3;
  19510. }
  19511. interface PhysicsRadialExplosionEventData {
  19512. sphere: Mesh;
  19513. rays: Array<Ray>;
  19514. }
  19515. interface PhysicsGravitationalFieldEventData {
  19516. sphere: Mesh;
  19517. }
  19518. interface PhysicsUpdraftEventData {
  19519. cylinder: Mesh;
  19520. }
  19521. interface PhysicsVortexEventData {
  19522. cylinder: Mesh;
  19523. }
  19524. }
  19525. declare module BABYLON {
  19526. interface PhysicsImpostorParameters {
  19527. mass: number;
  19528. friction?: number;
  19529. restitution?: number;
  19530. nativeOptions?: any;
  19531. ignoreParent?: boolean;
  19532. disableBidirectionalTransformation?: boolean;
  19533. }
  19534. interface IPhysicsEnabledObject {
  19535. position: Vector3;
  19536. rotationQuaternion: Nullable<Quaternion>;
  19537. scaling: Vector3;
  19538. rotation?: Vector3;
  19539. parent?: any;
  19540. getBoundingInfo(): BoundingInfo;
  19541. computeWorldMatrix(force: boolean): Matrix;
  19542. getWorldMatrix?(): Matrix;
  19543. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19544. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19545. getIndices?(): Nullable<IndicesArray>;
  19546. getScene?(): Scene;
  19547. getAbsolutePosition(): Vector3;
  19548. getAbsolutePivotPoint(): Vector3;
  19549. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19550. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19551. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19552. getClassName(): string;
  19553. }
  19554. class PhysicsImpostor {
  19555. object: IPhysicsEnabledObject;
  19556. type: number;
  19557. private _options;
  19558. private _scene?;
  19559. static DEFAULT_OBJECT_SIZE: Vector3;
  19560. static IDENTITY_QUATERNION: Quaternion;
  19561. private _physicsEngine;
  19562. private _physicsBody;
  19563. private _bodyUpdateRequired;
  19564. private _onBeforePhysicsStepCallbacks;
  19565. private _onAfterPhysicsStepCallbacks;
  19566. private _onPhysicsCollideCallbacks;
  19567. private _deltaPosition;
  19568. private _deltaRotation;
  19569. private _deltaRotationConjugated;
  19570. private _parent;
  19571. private _isDisposed;
  19572. private static _tmpVecs;
  19573. private static _tmpQuat;
  19574. readonly isDisposed: boolean;
  19575. mass: number;
  19576. friction: number;
  19577. restitution: number;
  19578. uniqueId: number;
  19579. private _joints;
  19580. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19581. /**
  19582. * This function will completly initialize this impostor.
  19583. * It will create a new body - but only if this mesh has no parent.
  19584. * If it has, this impostor will not be used other than to define the impostor
  19585. * of the child mesh.
  19586. * @hidden
  19587. */
  19588. _init(): void;
  19589. private _getPhysicsParent;
  19590. /**
  19591. * Should a new body be generated.
  19592. */
  19593. isBodyInitRequired(): boolean;
  19594. setScalingUpdated(updated: boolean): void;
  19595. /**
  19596. * Force a regeneration of this or the parent's impostor's body.
  19597. * Use under cautious - This will remove all joints already implemented.
  19598. */
  19599. forceUpdate(): void;
  19600. /**
  19601. * Gets the body that holds this impostor. Either its own, or its parent.
  19602. */
  19603. /**
  19604. * Set the physics body. Used mainly by the physics engine/plugin
  19605. */
  19606. physicsBody: any;
  19607. parent: Nullable<PhysicsImpostor>;
  19608. resetUpdateFlags(): void;
  19609. getObjectExtendSize(): Vector3;
  19610. getObjectCenter(): Vector3;
  19611. /**
  19612. * Get a specific parametes from the options parameter.
  19613. */
  19614. getParam(paramName: string): any;
  19615. /**
  19616. * Sets a specific parameter in the options given to the physics plugin
  19617. */
  19618. setParam(paramName: string, value: number): void;
  19619. /**
  19620. * Specifically change the body's mass option. Won't recreate the physics body object
  19621. */
  19622. setMass(mass: number): void;
  19623. getLinearVelocity(): Nullable<Vector3>;
  19624. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19625. getAngularVelocity(): Nullable<Vector3>;
  19626. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19627. /**
  19628. * Execute a function with the physics plugin native code.
  19629. * Provide a function the will have two variables - the world object and the physics body object.
  19630. */
  19631. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19632. /**
  19633. * Register a function that will be executed before the physics world is stepping forward.
  19634. */
  19635. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19636. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19637. /**
  19638. * Register a function that will be executed after the physics step
  19639. */
  19640. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19641. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19642. /**
  19643. * register a function that will be executed when this impostor collides against a different body.
  19644. */
  19645. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19646. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19647. private _tmpQuat;
  19648. private _tmpQuat2;
  19649. getParentsRotation(): Quaternion;
  19650. /**
  19651. * this function is executed by the physics engine.
  19652. */
  19653. beforeStep: () => void;
  19654. /**
  19655. * this function is executed by the physics engine.
  19656. */
  19657. afterStep: () => void;
  19658. /**
  19659. * Legacy collision detection event support
  19660. */
  19661. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19662. onCollide: (e: {
  19663. body: any;
  19664. }) => void;
  19665. /**
  19666. * Apply a force
  19667. */
  19668. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19669. /**
  19670. * Apply an impulse
  19671. */
  19672. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19673. /**
  19674. * A help function to create a joint.
  19675. */
  19676. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19677. /**
  19678. * Add a joint to this impostor with a different impostor.
  19679. */
  19680. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19681. /**
  19682. * Will keep this body still, in a sleep mode.
  19683. */
  19684. sleep(): PhysicsImpostor;
  19685. /**
  19686. * Wake the body up.
  19687. */
  19688. wakeUp(): PhysicsImpostor;
  19689. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19690. dispose(): void;
  19691. setDeltaPosition(position: Vector3): void;
  19692. setDeltaRotation(rotation: Quaternion): void;
  19693. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19694. getRadius(): number;
  19695. /**
  19696. * Sync a bone with this impostor
  19697. * @param bone The bone to sync to the impostor.
  19698. * @param boneMesh The mesh that the bone is influencing.
  19699. * @param jointPivot The pivot of the joint / bone in local space.
  19700. * @param distToJoint Optional distance from the impostor to the joint.
  19701. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19702. */
  19703. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19704. /**
  19705. * Sync impostor to a bone
  19706. * @param bone The bone that the impostor will be synced to.
  19707. * @param boneMesh The mesh that the bone is influencing.
  19708. * @param jointPivot The pivot of the joint / bone in local space.
  19709. * @param distToJoint Optional distance from the impostor to the joint.
  19710. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19711. * @param boneAxis Optional vector3 axis the bone is aligned with
  19712. */
  19713. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19714. static NoImpostor: number;
  19715. static SphereImpostor: number;
  19716. static BoxImpostor: number;
  19717. static PlaneImpostor: number;
  19718. static MeshImpostor: number;
  19719. static CylinderImpostor: number;
  19720. static ParticleImpostor: number;
  19721. static HeightmapImpostor: number;
  19722. }
  19723. }
  19724. declare module BABYLON {
  19725. interface PhysicsJointData {
  19726. mainPivot?: Vector3;
  19727. connectedPivot?: Vector3;
  19728. mainAxis?: Vector3;
  19729. connectedAxis?: Vector3;
  19730. collision?: boolean;
  19731. nativeParams?: any;
  19732. }
  19733. /**
  19734. * This is a holder class for the physics joint created by the physics plugin.
  19735. * It holds a set of functions to control the underlying joint.
  19736. */
  19737. class PhysicsJoint {
  19738. type: number;
  19739. jointData: PhysicsJointData;
  19740. private _physicsJoint;
  19741. protected _physicsPlugin: IPhysicsEnginePlugin;
  19742. constructor(type: number, jointData: PhysicsJointData);
  19743. physicsJoint: any;
  19744. physicsPlugin: IPhysicsEnginePlugin;
  19745. /**
  19746. * Execute a function that is physics-plugin specific.
  19747. * @param {Function} func the function that will be executed.
  19748. * It accepts two parameters: the physics world and the physics joint.
  19749. */
  19750. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19751. static DistanceJoint: number;
  19752. static HingeJoint: number;
  19753. static BallAndSocketJoint: number;
  19754. static WheelJoint: number;
  19755. static SliderJoint: number;
  19756. static PrismaticJoint: number;
  19757. static UniversalJoint: number;
  19758. static Hinge2Joint: number;
  19759. static PointToPointJoint: number;
  19760. static SpringJoint: number;
  19761. static LockJoint: number;
  19762. }
  19763. /**
  19764. * A class representing a physics distance joint.
  19765. */
  19766. class DistanceJoint extends PhysicsJoint {
  19767. constructor(jointData: DistanceJointData);
  19768. /**
  19769. * Update the predefined distance.
  19770. */
  19771. updateDistance(maxDistance: number, minDistance?: number): void;
  19772. }
  19773. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19774. constructor(type: number, jointData: PhysicsJointData);
  19775. /**
  19776. * Set the motor values.
  19777. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19778. * @param {number} force the force to apply
  19779. * @param {number} maxForce max force for this motor.
  19780. */
  19781. setMotor(force?: number, maxForce?: number): void;
  19782. /**
  19783. * Set the motor's limits.
  19784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19785. */
  19786. setLimit(upperLimit: number, lowerLimit?: number): void;
  19787. }
  19788. /**
  19789. * This class represents a single hinge physics joint
  19790. */
  19791. class HingeJoint extends MotorEnabledJoint {
  19792. constructor(jointData: PhysicsJointData);
  19793. /**
  19794. * Set the motor values.
  19795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19796. * @param {number} force the force to apply
  19797. * @param {number} maxForce max force for this motor.
  19798. */
  19799. setMotor(force?: number, maxForce?: number): void;
  19800. /**
  19801. * Set the motor's limits.
  19802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19803. */
  19804. setLimit(upperLimit: number, lowerLimit?: number): void;
  19805. }
  19806. /**
  19807. * This class represents a dual hinge physics joint (same as wheel joint)
  19808. */
  19809. class Hinge2Joint extends MotorEnabledJoint {
  19810. constructor(jointData: PhysicsJointData);
  19811. /**
  19812. * Set the motor values.
  19813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19814. * @param {number} force the force to apply
  19815. * @param {number} maxForce max force for this motor.
  19816. * @param {motorIndex} the motor's index, 0 or 1.
  19817. */
  19818. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19819. /**
  19820. * Set the motor limits.
  19821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19822. * @param {number} upperLimit the upper limit
  19823. * @param {number} lowerLimit lower limit
  19824. * @param {motorIndex} the motor's index, 0 or 1.
  19825. */
  19826. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19827. }
  19828. interface IMotorEnabledJoint {
  19829. physicsJoint: any;
  19830. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19831. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19832. }
  19833. interface DistanceJointData extends PhysicsJointData {
  19834. maxDistance: number;
  19835. }
  19836. interface SpringJointData extends PhysicsJointData {
  19837. length: number;
  19838. stiffness: number;
  19839. damping: number;
  19840. /** this callback will be called when applying the force to the impostors. */
  19841. forceApplicationCallback: () => void;
  19842. }
  19843. }
  19844. declare module BABYLON {
  19845. /**
  19846. * Class used to store all common mesh properties
  19847. */
  19848. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19849. /** No occlusion */
  19850. static OCCLUSION_TYPE_NONE: number;
  19851. /** Occlusion set to optimisitic */
  19852. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19853. /** Occlusion set to strict */
  19854. static OCCLUSION_TYPE_STRICT: number;
  19855. /** Use an accurante occlusion algorithm */
  19856. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19857. /** Use a conservative occlusion algorithm */
  19858. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19859. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19860. static readonly CULLINGSTRATEGY_STANDARD: number;
  19861. /** Culling strategy with bounding sphere only and then frustum culling */
  19862. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19863. /**
  19864. * No billboard
  19865. */
  19866. static readonly BILLBOARDMODE_NONE: number;
  19867. /** Billboard on X axis */
  19868. static readonly BILLBOARDMODE_X: number;
  19869. /** Billboard on Y axis */
  19870. static readonly BILLBOARDMODE_Y: number;
  19871. /** Billboard on Z axis */
  19872. static readonly BILLBOARDMODE_Z: number;
  19873. /** Billboard on all axes */
  19874. static readonly BILLBOARDMODE_ALL: number;
  19875. private _facetPositions;
  19876. private _facetNormals;
  19877. private _facetPartitioning;
  19878. private _facetNb;
  19879. private _partitioningSubdivisions;
  19880. private _partitioningBBoxRatio;
  19881. private _facetDataEnabled;
  19882. private _facetParameters;
  19883. private _bbSize;
  19884. private _subDiv;
  19885. private _facetDepthSort;
  19886. private _facetDepthSortEnabled;
  19887. private _depthSortedIndices;
  19888. private _depthSortedFacets;
  19889. private _facetDepthSortFunction;
  19890. private _facetDepthSortFrom;
  19891. private _facetDepthSortOrigin;
  19892. private _invertedMatrix;
  19893. /** Gets ot sets the culling strategy to use to find visible meshes */
  19894. cullingStrategy: number;
  19895. /**
  19896. * Gets the number of facets in the mesh
  19897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19898. */
  19899. readonly facetNb: number;
  19900. /**
  19901. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19903. */
  19904. partitioningSubdivisions: number;
  19905. /**
  19906. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19907. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19909. */
  19910. partitioningBBoxRatio: number;
  19911. /**
  19912. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19913. * Works only for updatable meshes.
  19914. * Doesn't work with multi-materials
  19915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19916. */
  19917. mustDepthSortFacets: boolean;
  19918. /**
  19919. * The location (Vector3) where the facet depth sort must be computed from.
  19920. * By default, the active camera position.
  19921. * Used only when facet depth sort is enabled
  19922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19923. */
  19924. facetDepthSortFrom: Vector3;
  19925. /**
  19926. * gets a boolean indicating if facetData is enabled
  19927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19928. */
  19929. readonly isFacetDataEnabled: boolean;
  19930. /** @hidden */
  19931. _updateNonUniformScalingState(value: boolean): boolean;
  19932. /**
  19933. * An event triggered when this mesh collides with another one
  19934. */
  19935. onCollideObservable: Observable<AbstractMesh>;
  19936. private _onCollideObserver;
  19937. /** Set a function to call when this mesh collides with another one */
  19938. onCollide: () => void;
  19939. /**
  19940. * An event triggered when the collision's position changes
  19941. */
  19942. onCollisionPositionChangeObservable: Observable<Vector3>;
  19943. private _onCollisionPositionChangeObserver;
  19944. /** Set a function to call when the collision's position changes */
  19945. onCollisionPositionChange: () => void;
  19946. /**
  19947. * An event triggered when material is changed
  19948. */
  19949. onMaterialChangedObservable: Observable<AbstractMesh>;
  19950. /**
  19951. * Gets or sets the orientation for POV movement & rotation
  19952. */
  19953. definedFacingForward: boolean;
  19954. /**
  19955. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19956. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19957. * * 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.
  19958. * @see http://doc.babylonjs.com/features/occlusionquery
  19959. */
  19960. occlusionQueryAlgorithmType: number;
  19961. /**
  19962. * 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:
  19963. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19964. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19965. * * 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.
  19966. * @see http://doc.babylonjs.com/features/occlusionquery
  19967. */
  19968. occlusionType: number;
  19969. /**
  19970. * 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.
  19971. * The default value is -1 which means don't break the query and wait till the result
  19972. * @see http://doc.babylonjs.com/features/occlusionquery
  19973. */
  19974. occlusionRetryCount: number;
  19975. /** @hidden */
  19976. _occlusionInternalRetryCounter: number;
  19977. /** @hidden */
  19978. _isOccluded: boolean;
  19979. /**
  19980. * 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
  19981. * @see http://doc.babylonjs.com/features/occlusionquery
  19982. */
  19983. isOccluded: boolean;
  19984. /** @hidden */
  19985. _isOcclusionQueryInProgress: boolean;
  19986. /**
  19987. * Flag to check the progress status of the query
  19988. * @see http://doc.babylonjs.com/features/occlusionquery
  19989. */
  19990. readonly isOcclusionQueryInProgress: boolean;
  19991. /** @hidden */
  19992. _occlusionQuery: Nullable<WebGLQuery>;
  19993. private _visibility;
  19994. /**
  19995. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19996. */
  19997. /**
  19998. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19999. */
  20000. visibility: number;
  20001. /** Gets or sets the alpha index used to sort transparent meshes
  20002. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  20003. */
  20004. alphaIndex: number;
  20005. /**
  20006. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  20007. */
  20008. isVisible: boolean;
  20009. /**
  20010. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  20011. */
  20012. isPickable: boolean;
  20013. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  20014. showSubMeshesBoundingBox: boolean;
  20015. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  20016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  20017. */
  20018. isBlocker: boolean;
  20019. /**
  20020. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  20021. */
  20022. enablePointerMoveEvents: boolean;
  20023. /**
  20024. * Specifies the rendering group id for this mesh (0 by default)
  20025. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  20026. */
  20027. renderingGroupId: number;
  20028. private _material;
  20029. /** Gets or sets current material */
  20030. material: Nullable<Material>;
  20031. private _receiveShadows;
  20032. /**
  20033. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  20034. * @see http://doc.babylonjs.com/babylon101/shadows
  20035. */
  20036. receiveShadows: boolean;
  20037. /** Defines color to use when rendering outline */
  20038. outlineColor: Color3;
  20039. /** Define width to use when rendering outline */
  20040. outlineWidth: number;
  20041. /** Defines color to use when rendering overlay */
  20042. overlayColor: Color3;
  20043. /** Defines alpha to use when rendering overlay */
  20044. overlayAlpha: number;
  20045. private _hasVertexAlpha;
  20046. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  20047. hasVertexAlpha: boolean;
  20048. private _useVertexColors;
  20049. /** 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) */
  20050. useVertexColors: boolean;
  20051. private _computeBonesUsingShaders;
  20052. /**
  20053. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  20054. */
  20055. computeBonesUsingShaders: boolean;
  20056. private _numBoneInfluencers;
  20057. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  20058. numBoneInfluencers: number;
  20059. private _applyFog;
  20060. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  20061. applyFog: boolean;
  20062. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  20063. useOctreeForRenderingSelection: boolean;
  20064. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  20065. useOctreeForPicking: boolean;
  20066. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  20067. useOctreeForCollisions: boolean;
  20068. private _layerMask;
  20069. /**
  20070. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  20071. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  20072. */
  20073. layerMask: number;
  20074. /**
  20075. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  20076. */
  20077. alwaysSelectAsActiveMesh: boolean;
  20078. /**
  20079. * Gets or sets the current action manager
  20080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20081. */
  20082. actionManager: Nullable<ActionManager>;
  20083. /**
  20084. * Gets or sets impostor used for physic simulation
  20085. * @see http://doc.babylonjs.com/features/physics_engine
  20086. */
  20087. physicsImpostor: Nullable<PhysicsImpostor>;
  20088. private _checkCollisions;
  20089. private _collisionMask;
  20090. private _collisionGroup;
  20091. /**
  20092. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  20093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20094. */
  20095. ellipsoid: Vector3;
  20096. /**
  20097. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  20098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20099. */
  20100. ellipsoidOffset: Vector3;
  20101. private _collider;
  20102. private _oldPositionForCollisions;
  20103. private _diffPositionForCollisions;
  20104. /**
  20105. * Gets or sets a collision mask used to mask collisions (default is -1).
  20106. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20107. */
  20108. collisionMask: number;
  20109. /**
  20110. * Gets or sets the current collision group mask (-1 by default).
  20111. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  20112. */
  20113. collisionGroup: number;
  20114. /**
  20115. * Defines edge width used when edgesRenderer is enabled
  20116. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20117. */
  20118. edgesWidth: number;
  20119. /**
  20120. * Defines edge color used when edgesRenderer is enabled
  20121. * @see https://www.babylonjs-playground.com/#10OJSG#13
  20122. */
  20123. edgesColor: Color4;
  20124. /** @hidden */
  20125. _edgesRenderer: Nullable<IEdgesRenderer>;
  20126. private _collisionsTransformMatrix;
  20127. private _collisionsScalingMatrix;
  20128. /** @hidden */
  20129. _masterMesh: Nullable<AbstractMesh>;
  20130. /** @hidden */
  20131. _boundingInfo: Nullable<BoundingInfo>;
  20132. /** @hidden */
  20133. _renderId: number;
  20134. /**
  20135. * Gets or sets the list of subMeshes
  20136. * @see http://doc.babylonjs.com/how_to/multi_materials
  20137. */
  20138. subMeshes: SubMesh[];
  20139. /** @hidden */
  20140. _submeshesOctree: Octree<SubMesh>;
  20141. /** @hidden */
  20142. _intersectionsInProgress: AbstractMesh[];
  20143. /** @hidden */
  20144. _unIndexed: boolean;
  20145. /** @hidden */
  20146. _lightSources: Light[];
  20147. /** @hidden */
  20148. readonly _positions: Nullable<Vector3[]>;
  20149. /** @hidden */
  20150. _waitingActions: any;
  20151. /** @hidden */
  20152. _waitingFreezeWorldMatrix: Nullable<boolean>;
  20153. private _skeleton;
  20154. /** @hidden */
  20155. _bonesTransformMatrices: Nullable<Float32Array>;
  20156. /**
  20157. * Gets or sets a skeleton to apply skining transformations
  20158. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  20159. */
  20160. skeleton: Nullable<Skeleton>;
  20161. /**
  20162. * An event triggered when the mesh is rebuilt.
  20163. */
  20164. onRebuildObservable: Observable<AbstractMesh>;
  20165. /**
  20166. * Creates a new AbstractMesh
  20167. * @param name defines the name of the mesh
  20168. * @param scene defines the hosting scene
  20169. */
  20170. constructor(name: string, scene?: Nullable<Scene>);
  20171. /**
  20172. * Returns the string "AbstractMesh"
  20173. * @returns "AbstractMesh"
  20174. */
  20175. getClassName(): string;
  20176. /**
  20177. * Gets a string representation of the current mesh
  20178. * @param fullDetails defines a boolean indicating if full details must be included
  20179. * @returns a string representation of the current mesh
  20180. */
  20181. toString(fullDetails?: boolean): string;
  20182. /** @hidden */
  20183. _rebuild(): void;
  20184. /** @hidden */
  20185. _resyncLightSources(): void;
  20186. /** @hidden */
  20187. _resyncLighSource(light: Light): void;
  20188. /** @hidden */
  20189. _unBindEffect(): void;
  20190. /** @hidden */
  20191. _removeLightSource(light: Light): void;
  20192. private _markSubMeshesAsDirty;
  20193. /** @hidden */
  20194. _markSubMeshesAsLightDirty(): void;
  20195. /** @hidden */
  20196. _markSubMeshesAsAttributesDirty(): void;
  20197. /** @hidden */
  20198. _markSubMeshesAsMiscDirty(): void;
  20199. /**
  20200. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  20201. */
  20202. scaling: Vector3;
  20203. /**
  20204. * Returns true if the mesh is blocked. Implemented by child classes
  20205. */
  20206. readonly isBlocked: boolean;
  20207. /**
  20208. * Returns the mesh itself by default. Implemented by child classes
  20209. * @param camera defines the camera to use to pick the right LOD level
  20210. * @returns the currentAbstractMesh
  20211. */
  20212. getLOD(camera: Camera): Nullable<AbstractMesh>;
  20213. /**
  20214. * Returns 0 by default. Implemented by child classes
  20215. * @returns an integer
  20216. */
  20217. getTotalVertices(): number;
  20218. /**
  20219. * Returns null by default. Implemented by child classes
  20220. * @returns null
  20221. */
  20222. getIndices(): Nullable<IndicesArray>;
  20223. /**
  20224. * Returns the array of the requested vertex data kind. Implemented by child classes
  20225. * @param kind defines the vertex data kind to use
  20226. * @returns null
  20227. */
  20228. getVerticesData(kind: string): Nullable<FloatArray>;
  20229. /**
  20230. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20231. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20232. * Note that a new underlying VertexBuffer object is created each call.
  20233. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20234. * @param kind defines vertex data kind:
  20235. * * BABYLON.VertexBuffer.PositionKind
  20236. * * BABYLON.VertexBuffer.UVKind
  20237. * * BABYLON.VertexBuffer.UV2Kind
  20238. * * BABYLON.VertexBuffer.UV3Kind
  20239. * * BABYLON.VertexBuffer.UV4Kind
  20240. * * BABYLON.VertexBuffer.UV5Kind
  20241. * * BABYLON.VertexBuffer.UV6Kind
  20242. * * BABYLON.VertexBuffer.ColorKind
  20243. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20244. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20245. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20246. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20247. * @param data defines the data source
  20248. * @param updatable defines if the data must be flagged as updatable (or static)
  20249. * @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
  20250. * @returns the current mesh
  20251. */
  20252. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  20253. /**
  20254. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20255. * If the mesh has no geometry, it is simply returned as it is.
  20256. * @param kind defines vertex data kind:
  20257. * * BABYLON.VertexBuffer.PositionKind
  20258. * * BABYLON.VertexBuffer.UVKind
  20259. * * BABYLON.VertexBuffer.UV2Kind
  20260. * * BABYLON.VertexBuffer.UV3Kind
  20261. * * BABYLON.VertexBuffer.UV4Kind
  20262. * * BABYLON.VertexBuffer.UV5Kind
  20263. * * BABYLON.VertexBuffer.UV6Kind
  20264. * * BABYLON.VertexBuffer.ColorKind
  20265. * * BABYLON.VertexBuffer.MatricesIndicesKind
  20266. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20267. * * BABYLON.VertexBuffer.MatricesWeightsKind
  20268. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20269. * @param data defines the data source
  20270. * @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
  20271. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  20272. * @returns the current mesh
  20273. */
  20274. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  20275. /**
  20276. * Sets the mesh indices,
  20277. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20278. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20279. * @param totalVertices Defines the total number of vertices
  20280. * @returns the current mesh
  20281. */
  20282. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  20283. /**
  20284. * Gets a boolean indicating if specific vertex data is present
  20285. * @param kind defines the vertex data kind to use
  20286. * @returns true is data kind is present
  20287. */
  20288. isVerticesDataPresent(kind: string): boolean;
  20289. /**
  20290. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  20291. * @returns a BoundingInfo
  20292. */
  20293. getBoundingInfo(): BoundingInfo;
  20294. /**
  20295. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  20296. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  20297. * @returns the current mesh
  20298. */
  20299. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  20300. /**
  20301. * Overwrite the current bounding info
  20302. * @param boundingInfo defines the new bounding info
  20303. * @returns the current mesh
  20304. */
  20305. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  20306. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  20307. readonly useBones: boolean;
  20308. /** @hidden */
  20309. _preActivate(): void;
  20310. /** @hidden */
  20311. _preActivateForIntermediateRendering(renderId: number): void;
  20312. /** @hidden */
  20313. _activate(renderId: number): void;
  20314. /**
  20315. * Gets the current world matrix
  20316. * @returns a Matrix
  20317. */
  20318. getWorldMatrix(): Matrix;
  20319. /** @hidden */
  20320. _getWorldMatrixDeterminant(): number;
  20321. /**
  20322. * Perform relative position change from the point of view of behind the front of the mesh.
  20323. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20324. * Supports definition of mesh facing forward or backward
  20325. * @param amountRight defines the distance on the right axis
  20326. * @param amountUp defines the distance on the up axis
  20327. * @param amountForward defines the distance on the forward axis
  20328. * @returns the current mesh
  20329. */
  20330. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  20331. /**
  20332. * Calculate relative position change from the point of view of behind the front of the mesh.
  20333. * This is performed taking into account the meshes current rotation, so you do not have to care.
  20334. * Supports definition of mesh facing forward or backward
  20335. * @param amountRight defines the distance on the right axis
  20336. * @param amountUp defines the distance on the up axis
  20337. * @param amountForward defines the distance on the forward axis
  20338. * @returns the new displacement vector
  20339. */
  20340. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  20341. /**
  20342. * Perform relative rotation change from the point of view of behind the front of the mesh.
  20343. * Supports definition of mesh facing forward or backward
  20344. * @param flipBack defines the flip
  20345. * @param twirlClockwise defines the twirl
  20346. * @param tiltRight defines the tilt
  20347. * @returns the current mesh
  20348. */
  20349. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  20350. /**
  20351. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  20352. * Supports definition of mesh facing forward or backward.
  20353. * @param flipBack defines the flip
  20354. * @param twirlClockwise defines the twirl
  20355. * @param tiltRight defines the tilt
  20356. * @returns the new rotation vector
  20357. */
  20358. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  20359. /**
  20360. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  20361. * @param includeDescendants Include bounding info from descendants as well (true by default)
  20362. * @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
  20363. * @returns the new bounding vectors
  20364. */
  20365. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  20366. min: Vector3;
  20367. max: Vector3;
  20368. };
  20369. /** @hidden */
  20370. _updateBoundingInfo(): AbstractMesh;
  20371. /** @hidden */
  20372. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  20373. /** @hidden */
  20374. protected _afterComputeWorldMatrix(): void;
  20375. /**
  20376. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20377. * A mesh is in the frustum if its bounding box intersects the frustum
  20378. * @param frustumPlanes defines the frustum to test
  20379. * @returns true if the mesh is in the frustum planes
  20380. */
  20381. isInFrustum(frustumPlanes: Plane[]): boolean;
  20382. /**
  20383. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  20384. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  20385. * @param frustumPlanes defines the frustum to test
  20386. * @returns true if the mesh is completely in the frustum planes
  20387. */
  20388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20389. /**
  20390. * True if the mesh intersects another mesh or a SolidParticle object
  20391. * @param mesh defines a target mesh or SolidParticle to test
  20392. * @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)
  20393. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  20394. * @returns true if there is an intersection
  20395. */
  20396. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  20397. /**
  20398. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  20399. * @param point defines the point to test
  20400. * @returns true if there is an intersection
  20401. */
  20402. intersectsPoint(point: Vector3): boolean;
  20403. /**
  20404. * Gets the current physics impostor
  20405. * @see http://doc.babylonjs.com/features/physics_engine
  20406. * @returns a physics impostor or null
  20407. */
  20408. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  20409. /**
  20410. * Gets the position of the current mesh in camera space
  20411. * @param camera defines the camera to use
  20412. * @returns a position
  20413. */
  20414. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  20415. /**
  20416. * Returns the distance from the mesh to the active camera
  20417. * @param camera defines the camera to use
  20418. * @returns the distance
  20419. */
  20420. getDistanceToCamera(camera?: Nullable<Camera>): number;
  20421. /**
  20422. * Apply a physic impulse to the mesh
  20423. * @param force defines the force to apply
  20424. * @param contactPoint defines where to apply the force
  20425. * @returns the current mesh
  20426. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20427. */
  20428. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  20429. /**
  20430. * Creates a physic joint between two meshes
  20431. * @param otherMesh defines the other mesh to use
  20432. * @param pivot1 defines the pivot to use on this mesh
  20433. * @param pivot2 defines the pivot to use on the other mesh
  20434. * @param options defines additional options (can be plugin dependent)
  20435. * @returns the current mesh
  20436. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  20437. */
  20438. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  20439. /**
  20440. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  20441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20442. */
  20443. checkCollisions: boolean;
  20444. /**
  20445. * Gets Collider object used to compute collisions (not physics)
  20446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20447. */
  20448. readonly collider: Collider;
  20449. /**
  20450. * Move the mesh using collision engine
  20451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  20452. * @param displacement defines the requested displacement vector
  20453. * @returns the current mesh
  20454. */
  20455. moveWithCollisions(displacement: Vector3): AbstractMesh;
  20456. private _onCollisionPositionChange;
  20457. /**
  20458. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  20459. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20460. * @param maxCapacity defines the maximum size of each block (64 by default)
  20461. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  20462. * @returns the new octree
  20463. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  20464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  20465. */
  20466. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  20467. /** @hidden */
  20468. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  20469. /** @hidden */
  20470. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  20471. /** @hidden */
  20472. _checkCollision(collider: Collider): AbstractMesh;
  20473. /** @hidden */
  20474. _generatePointsArray(): boolean;
  20475. /**
  20476. * Checks if the passed Ray intersects with the mesh
  20477. * @param ray defines the ray to use
  20478. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20479. * @returns the picking info
  20480. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20481. */
  20482. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20483. /**
  20484. * Clones the current mesh
  20485. * @param name defines the mesh name
  20486. * @param newParent defines the new mesh parent
  20487. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20488. * @returns the new mesh
  20489. */
  20490. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20491. /**
  20492. * Disposes all the submeshes of the current meshnp
  20493. * @returns the current mesh
  20494. */
  20495. releaseSubMeshes(): AbstractMesh;
  20496. /**
  20497. * Releases resources associated with this abstract mesh.
  20498. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20499. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20500. */
  20501. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20502. /**
  20503. * Adds the passed mesh as a child to the current mesh
  20504. * @param mesh defines the child mesh
  20505. * @returns the current mesh
  20506. */
  20507. addChild(mesh: AbstractMesh): AbstractMesh;
  20508. /**
  20509. * Removes the passed mesh from the current mesh children list
  20510. * @param mesh defines the child mesh
  20511. * @returns the current mesh
  20512. */
  20513. removeChild(mesh: AbstractMesh): AbstractMesh;
  20514. /** @hidden */
  20515. private _initFacetData;
  20516. /**
  20517. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20518. * This method can be called within the render loop.
  20519. * 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
  20520. * @returns the current mesh
  20521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20522. */
  20523. updateFacetData(): AbstractMesh;
  20524. /**
  20525. * Returns the facetLocalNormals array.
  20526. * The normals are expressed in the mesh local spac
  20527. * @returns an array of Vector3
  20528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20529. */
  20530. getFacetLocalNormals(): Vector3[];
  20531. /**
  20532. * Returns the facetLocalPositions array.
  20533. * The facet positions are expressed in the mesh local space
  20534. * @returns an array of Vector3
  20535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20536. */
  20537. getFacetLocalPositions(): Vector3[];
  20538. /**
  20539. * Returns the facetLocalPartioning array
  20540. * @returns an array of array of numbers
  20541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20542. */
  20543. getFacetLocalPartitioning(): number[][];
  20544. /**
  20545. * Returns the i-th facet position in the world system.
  20546. * This method allocates a new Vector3 per call
  20547. * @param i defines the facet index
  20548. * @returns a new Vector3
  20549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20550. */
  20551. getFacetPosition(i: number): Vector3;
  20552. /**
  20553. * Sets the reference Vector3 with the i-th facet position in the world system
  20554. * @param i defines the facet index
  20555. * @param ref defines the target vector
  20556. * @returns the current mesh
  20557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20558. */
  20559. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20560. /**
  20561. * Returns the i-th facet normal in the world system.
  20562. * This method allocates a new Vector3 per call
  20563. * @param i defines the facet index
  20564. * @returns a new Vector3
  20565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20566. */
  20567. getFacetNormal(i: number): Vector3;
  20568. /**
  20569. * Sets the reference Vector3 with the i-th facet normal in the world system
  20570. * @param i defines the facet index
  20571. * @param ref defines the target vector
  20572. * @returns the current mesh
  20573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20574. */
  20575. getFacetNormalToRef(i: number, ref: Vector3): this;
  20576. /**
  20577. * 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)
  20578. * @param x defines x coordinate
  20579. * @param y defines y coordinate
  20580. * @param z defines z coordinate
  20581. * @returns the array of facet indexes
  20582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20583. */
  20584. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20585. /**
  20586. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20587. * @param projected sets as the (x,y,z) world projection on the facet
  20588. * @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
  20589. * @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
  20590. * @param x defines x coordinate
  20591. * @param y defines y coordinate
  20592. * @param z defines z coordinate
  20593. * @returns the face index if found (or null instead)
  20594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20595. */
  20596. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20597. /**
  20598. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20599. * @param projected sets as the (x,y,z) local projection on the facet
  20600. * @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
  20601. * @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
  20602. * @param x defines x coordinate
  20603. * @param y defines y coordinate
  20604. * @param z defines z coordinate
  20605. * @returns the face index if found (or null instead)
  20606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20607. */
  20608. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20609. /**
  20610. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20611. * @returns the parameters
  20612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20613. */
  20614. getFacetDataParameters(): any;
  20615. /**
  20616. * Disables the feature FacetData and frees the related memory
  20617. * @returns the current mesh
  20618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20619. */
  20620. disableFacetData(): AbstractMesh;
  20621. /**
  20622. * Updates the AbstractMesh indices array
  20623. * @param indices defines the data source
  20624. * @returns the current mesh
  20625. */
  20626. updateIndices(indices: IndicesArray): AbstractMesh;
  20627. /**
  20628. * Creates new normals data for the mesh
  20629. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20630. * @returns the current mesh
  20631. */
  20632. createNormals(updatable: boolean): AbstractMesh;
  20633. /**
  20634. * Align the mesh with a normal
  20635. * @param normal defines the normal to use
  20636. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20637. * @returns the current mesh
  20638. */
  20639. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20640. /** @hidden */
  20641. _checkOcclusionQuery(): void;
  20642. }
  20643. }
  20644. declare module BABYLON {
  20645. class Buffer {
  20646. private _engine;
  20647. private _buffer;
  20648. /** @hidden */
  20649. _data: Nullable<DataArray>;
  20650. private _updatable;
  20651. private _instanced;
  20652. /**
  20653. * Gets the byte stride.
  20654. */
  20655. readonly byteStride: number;
  20656. /**
  20657. * Constructor
  20658. * @param engine the engine
  20659. * @param data the data to use for this buffer
  20660. * @param updatable whether the data is updatable
  20661. * @param stride the stride (optional)
  20662. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20663. * @param instanced whether the buffer is instanced (optional)
  20664. * @param useBytes set to true if the stride in in bytes (optional)
  20665. */
  20666. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20667. /**
  20668. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20669. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20670. * @param offset defines offset in the buffer (0 by default)
  20671. * @param size defines the size in floats of attributes (position is 3 for instance)
  20672. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20673. * @param instanced defines if the vertex buffer contains indexed data
  20674. * @param useBytes defines if the offset and stride are in bytes
  20675. * @returns the new vertex buffer
  20676. */
  20677. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20678. isUpdatable(): boolean;
  20679. getData(): Nullable<DataArray>;
  20680. getBuffer(): Nullable<WebGLBuffer>;
  20681. /**
  20682. * Gets the stride in float32 units (i.e. byte stride / 4).
  20683. * May not be an integer if the byte stride is not divisible by 4.
  20684. * DEPRECATED. Use byteStride instead.
  20685. * @returns the stride in float32 units
  20686. */
  20687. getStrideSize(): number;
  20688. create(data?: Nullable<DataArray>): void;
  20689. /** @hidden */
  20690. _rebuild(): void;
  20691. update(data: DataArray): void;
  20692. /**
  20693. * Updates the data directly.
  20694. * @param data the new data
  20695. * @param offset the new offset
  20696. * @param vertexCount the vertex count (optional)
  20697. * @param useBytes set to true if the offset is in bytes
  20698. */
  20699. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20700. dispose(): void;
  20701. }
  20702. }
  20703. declare module BABYLON {
  20704. class CSG {
  20705. private polygons;
  20706. matrix: Matrix;
  20707. position: Vector3;
  20708. rotation: Vector3;
  20709. rotationQuaternion: Nullable<Quaternion>;
  20710. scaling: Vector3;
  20711. static FromMesh(mesh: Mesh): CSG;
  20712. private static FromPolygons;
  20713. clone(): CSG;
  20714. union(csg: CSG): CSG;
  20715. unionInPlace(csg: CSG): void;
  20716. subtract(csg: CSG): CSG;
  20717. subtractInPlace(csg: CSG): void;
  20718. intersect(csg: CSG): CSG;
  20719. intersectInPlace(csg: CSG): void;
  20720. inverse(): CSG;
  20721. inverseInPlace(): void;
  20722. copyTransformAttributes(csg: CSG): CSG;
  20723. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20724. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20725. }
  20726. }
  20727. declare module BABYLON {
  20728. /**
  20729. * Class used to store geometry data (vertex buffers + index buffer)
  20730. */
  20731. class Geometry implements IGetSetVerticesData {
  20732. /**
  20733. * Gets or sets the unique ID of the geometry
  20734. */
  20735. id: string;
  20736. /**
  20737. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20738. */
  20739. delayLoadState: number;
  20740. /**
  20741. * Gets the file containing the data to load when running in delay load state
  20742. */
  20743. delayLoadingFile: Nullable<string>;
  20744. /**
  20745. * Callback called when the geometry is updated
  20746. */
  20747. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20748. private _scene;
  20749. private _engine;
  20750. private _meshes;
  20751. private _totalVertices;
  20752. /** @hidden */
  20753. _indices: IndicesArray;
  20754. /** @hidden */
  20755. _vertexBuffers: {
  20756. [key: string]: VertexBuffer;
  20757. };
  20758. private _isDisposed;
  20759. private _extend;
  20760. private _boundingBias;
  20761. /** @hidden */
  20762. _delayInfo: Array<string>;
  20763. private _indexBuffer;
  20764. private _indexBufferIsUpdatable;
  20765. /** @hidden */
  20766. _boundingInfo: Nullable<BoundingInfo>;
  20767. /** @hidden */
  20768. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20769. /** @hidden */
  20770. _softwareSkinningRenderId: number;
  20771. private _vertexArrayObjects;
  20772. private _updatable;
  20773. /** @hidden */
  20774. _positions: Nullable<Vector3[]>;
  20775. /**
  20776. * 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
  20777. */
  20778. /**
  20779. * 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
  20780. */
  20781. boundingBias: Vector2;
  20782. /**
  20783. * Static function used to attach a new empty geometry to a mesh
  20784. * @param mesh defines the mesh to attach the geometry to
  20785. * @returns the new {BABYLON.Geometry}
  20786. */
  20787. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20788. /**
  20789. * Creates a new geometry
  20790. * @param id defines the unique ID
  20791. * @param scene defines the hosting scene
  20792. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20793. * @param updatable defines if geometry must be updatable (false by default)
  20794. * @param mesh defines the mesh that will be associated with the geometry
  20795. */
  20796. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20797. /**
  20798. * Gets the current extend of the geometry
  20799. */
  20800. readonly extend: {
  20801. minimum: Vector3;
  20802. maximum: Vector3;
  20803. };
  20804. /**
  20805. * Gets the hosting scene
  20806. * @returns the hosting {BABYLON.Scene}
  20807. */
  20808. getScene(): Scene;
  20809. /**
  20810. * Gets the hosting engine
  20811. * @returns the hosting {BABYLON.Engine}
  20812. */
  20813. getEngine(): Engine;
  20814. /**
  20815. * Defines if the geometry is ready to use
  20816. * @returns true if the geometry is ready to be used
  20817. */
  20818. isReady(): boolean;
  20819. /**
  20820. * Gets a value indicating that the geometry should not be serialized
  20821. */
  20822. readonly doNotSerialize: boolean;
  20823. /** @hidden */
  20824. _rebuild(): void;
  20825. /**
  20826. * Affects all geometry data in one call
  20827. * @param vertexData defines the geometry data
  20828. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20829. */
  20830. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20831. /**
  20832. * Set specific vertex data
  20833. * @param kind defines the data kind (Position, normal, etc...)
  20834. * @param data defines the vertex data to use
  20835. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20836. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20837. */
  20838. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20839. /**
  20840. * Removes a specific vertex data
  20841. * @param kind defines the data kind (Position, normal, etc...)
  20842. */
  20843. removeVerticesData(kind: string): void;
  20844. /**
  20845. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20846. * @param buffer defines the vertex buffer to use
  20847. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20848. */
  20849. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20850. /**
  20851. * Update a specific vertex buffer
  20852. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20853. * It will do nothing if the buffer is not updatable
  20854. * @param kind defines the data kind (Position, normal, etc...)
  20855. * @param data defines the data to use
  20856. * @param offset defines the offset in the target buffer where to store the data
  20857. * @param useBytes set to true if the offset is in bytes
  20858. */
  20859. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20860. /**
  20861. * Update a specific vertex buffer
  20862. * This function will create a new buffer if the current one is not updatable
  20863. * @param kind defines the data kind (Position, normal, etc...)
  20864. * @param data defines the data to use
  20865. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20866. */
  20867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20868. private _updateBoundingInfo;
  20869. /** @hidden */
  20870. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20871. /**
  20872. * Gets total number of vertices
  20873. * @returns the total number of vertices
  20874. */
  20875. getTotalVertices(): number;
  20876. /**
  20877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20878. * @param kind defines the data kind (Position, normal, etc...)
  20879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20881. * @returns a float array containing vertex data
  20882. */
  20883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20884. /**
  20885. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20886. * @param kind defines the data kind (Position, normal, etc...)
  20887. * @returns true if the vertex buffer with the specified kind is updatable
  20888. */
  20889. isVertexBufferUpdatable(kind: string): boolean;
  20890. /**
  20891. * Gets a specific vertex buffer
  20892. * @param kind defines the data kind (Position, normal, etc...)
  20893. * @returns a {BABYLON.VertexBuffer}
  20894. */
  20895. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20896. /**
  20897. * Returns all vertex buffers
  20898. * @return an object holding all vertex buffers indexed by kind
  20899. */
  20900. getVertexBuffers(): Nullable<{
  20901. [key: string]: VertexBuffer;
  20902. }>;
  20903. /**
  20904. * Gets a boolean indicating if specific vertex buffer is present
  20905. * @param kind defines the data kind (Position, normal, etc...)
  20906. * @returns true if data is present
  20907. */
  20908. isVerticesDataPresent(kind: string): boolean;
  20909. /**
  20910. * Gets a list of all attached data kinds (Position, normal, etc...)
  20911. * @returns a list of string containing all kinds
  20912. */
  20913. getVerticesDataKinds(): string[];
  20914. /**
  20915. * Update index buffer
  20916. * @param indices defines the indices to store in the index buffer
  20917. * @param offset defines the offset in the target buffer where to store the data
  20918. */
  20919. updateIndices(indices: IndicesArray, offset?: number): void;
  20920. /**
  20921. * Creates a new index buffer
  20922. * @param indices defines the indices to store in the index buffer
  20923. * @param totalVertices defines the total number of vertices (could be null)
  20924. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20925. */
  20926. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20927. /**
  20928. * Return the total number of indices
  20929. * @returns the total number of indices
  20930. */
  20931. getTotalIndices(): number;
  20932. /**
  20933. * Gets the index buffer array
  20934. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20936. * @returns the index buffer array
  20937. */
  20938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20939. /**
  20940. * Gets the index buffer
  20941. * @return the index buffer
  20942. */
  20943. getIndexBuffer(): Nullable<WebGLBuffer>;
  20944. /** @hidden */
  20945. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20946. /**
  20947. * Release the associated resources for a specific mesh
  20948. * @param mesh defines the source mesh
  20949. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20950. */
  20951. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20952. /**
  20953. * Apply current geometry to a given mesh
  20954. * @param mesh defines the mesh to apply geometry to
  20955. */
  20956. applyToMesh(mesh: Mesh): void;
  20957. private _updateExtend;
  20958. private _applyToMesh;
  20959. private notifyUpdate;
  20960. /**
  20961. * Load the geometry if it was flagged as delay loaded
  20962. * @param scene defines the hosting scene
  20963. * @param onLoaded defines a callback called when the geometry is loaded
  20964. */
  20965. load(scene: Scene, onLoaded?: () => void): void;
  20966. private _queueLoad;
  20967. /**
  20968. * Invert the geometry to move from a right handed system to a left handed one.
  20969. */
  20970. toLeftHanded(): void;
  20971. /** @hidden */
  20972. _resetPointsArrayCache(): void;
  20973. /** @hidden */
  20974. _generatePointsArray(): boolean;
  20975. /**
  20976. * Gets a value indicating if the geometry is disposed
  20977. * @returns true if the geometry was disposed
  20978. */
  20979. isDisposed(): boolean;
  20980. private _disposeVertexArrayObjects;
  20981. /**
  20982. * Free all associated resources
  20983. */
  20984. dispose(): void;
  20985. /**
  20986. * Clone the current geometry into a new geometry
  20987. * @param id defines the unique ID of the new geometry
  20988. * @returns a new geometry object
  20989. */
  20990. copy(id: string): Geometry;
  20991. /**
  20992. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20993. * @return a JSON representation of the current geometry data (without the vertices data)
  20994. */
  20995. serialize(): any;
  20996. private toNumberArray;
  20997. /**
  20998. * Serialize all vertices data into a JSON oject
  20999. * @returns a JSON representation of the current geometry data
  21000. */
  21001. serializeVerticeData(): any;
  21002. /**
  21003. * Extracts a clone of a mesh geometry
  21004. * @param mesh defines the source mesh
  21005. * @param id defines the unique ID of the new geometry object
  21006. * @returns the new geometry object
  21007. */
  21008. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21009. /**
  21010. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21011. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21012. * Be aware Math.random() could cause collisions, but:
  21013. * "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"
  21014. * @returns a string containing a new GUID
  21015. */
  21016. static RandomId(): string;
  21017. /** @hidden */
  21018. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21019. private static _CleanMatricesWeights;
  21020. /**
  21021. * Create a new geometry from persisted data (Using .babylon file format)
  21022. * @param parsedVertexData defines the persisted data
  21023. * @param scene defines the hosting scene
  21024. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21025. * @returns the new geometry object
  21026. */
  21027. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21028. }
  21029. /**
  21030. * Abstract class used to provide common services for all typed geometries
  21031. * @hidden
  21032. */
  21033. class _PrimitiveGeometry extends Geometry {
  21034. private _canBeRegenerated;
  21035. private _beingRegenerated;
  21036. /**
  21037. * Creates a new typed geometry
  21038. * @param id defines the unique ID of the geometry
  21039. * @param scene defines the hosting scene
  21040. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21041. * @param mesh defines the hosting mesh (can be null)
  21042. */
  21043. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21044. /**
  21045. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21046. * @returns true if the geometry can be regenerated
  21047. */
  21048. canBeRegenerated(): boolean;
  21049. /**
  21050. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21051. */
  21052. regenerate(): void;
  21053. /**
  21054. * Clone the geometry
  21055. * @param id defines the unique ID of the new geometry
  21056. * @returns the new geometry
  21057. */
  21058. asNewGeometry(id: string): Geometry;
  21059. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21060. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21061. /** @hidden */
  21062. _regenerateVertexData(): VertexData;
  21063. copy(id: string): Geometry;
  21064. serialize(): any;
  21065. }
  21066. /**
  21067. * Creates a ribbon geometry
  21068. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21069. */
  21070. class RibbonGeometry extends _PrimitiveGeometry {
  21071. /**
  21072. * Defines the array of paths to use
  21073. */
  21074. pathArray: Vector3[][];
  21075. /**
  21076. * Defines if the last and first points of each path in your pathArray must be joined
  21077. */
  21078. closeArray: boolean;
  21079. /**
  21080. * Defines if the last and first points of each path in your pathArray must be joined
  21081. */
  21082. closePath: boolean;
  21083. /**
  21084. * Defines the offset between points
  21085. */
  21086. offset: number;
  21087. /**
  21088. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21089. */
  21090. side: number;
  21091. /**
  21092. * Creates a ribbon geometry
  21093. * @param id defines the unique ID of the geometry
  21094. * @param scene defines the hosting scene
  21095. * @param pathArray defines the array of paths to use
  21096. * @param closeArray defines if the last path and the first path must be joined
  21097. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21098. * @param offset defines the offset between points
  21099. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21100. * @param mesh defines the hosting mesh (can be null)
  21101. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21102. */
  21103. constructor(id: string, scene: Scene,
  21104. /**
  21105. * Defines the array of paths to use
  21106. */
  21107. pathArray: Vector3[][],
  21108. /**
  21109. * Defines if the last and first points of each path in your pathArray must be joined
  21110. */
  21111. closeArray: boolean,
  21112. /**
  21113. * Defines if the last and first points of each path in your pathArray must be joined
  21114. */
  21115. closePath: boolean,
  21116. /**
  21117. * Defines the offset between points
  21118. */
  21119. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21120. /**
  21121. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21122. */
  21123. side?: number);
  21124. /** @hidden */
  21125. _regenerateVertexData(): VertexData;
  21126. copy(id: string): Geometry;
  21127. }
  21128. /**
  21129. * Creates a box geometry
  21130. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21131. */
  21132. class BoxGeometry extends _PrimitiveGeometry {
  21133. /**
  21134. * Defines the zise of the box (width, height and depth are the same)
  21135. */
  21136. size: number;
  21137. /**
  21138. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21139. */
  21140. side: number;
  21141. /**
  21142. * Creates a box geometry
  21143. * @param id defines the unique ID of the geometry
  21144. * @param scene defines the hosting scene
  21145. * @param size defines the zise of the box (width, height and depth are the same)
  21146. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21147. * @param mesh defines the hosting mesh (can be null)
  21148. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21149. */
  21150. constructor(id: string, scene: Scene,
  21151. /**
  21152. * Defines the zise of the box (width, height and depth are the same)
  21153. */
  21154. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21155. /**
  21156. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21157. */
  21158. side?: number);
  21159. /** @hidden */
  21160. _regenerateVertexData(): VertexData;
  21161. copy(id: string): Geometry;
  21162. serialize(): any;
  21163. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21164. }
  21165. /**
  21166. * Creates a sphere geometry
  21167. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21168. */
  21169. class SphereGeometry extends _PrimitiveGeometry {
  21170. /**
  21171. * Defines the number of segments to use to create the sphere
  21172. */
  21173. segments: number;
  21174. /**
  21175. * Defines the diameter of the sphere
  21176. */
  21177. diameter: number;
  21178. /**
  21179. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21180. */
  21181. side: number;
  21182. /**
  21183. * Create a new sphere geometry
  21184. * @param id defines the unique ID of the geometry
  21185. * @param scene defines the hosting scene
  21186. * @param segments defines the number of segments to use to create the sphere
  21187. * @param diameter defines the diameter of the sphere
  21188. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21189. * @param mesh defines the hosting mesh (can be null)
  21190. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21191. */
  21192. constructor(id: string, scene: Scene,
  21193. /**
  21194. * Defines the number of segments to use to create the sphere
  21195. */
  21196. segments: number,
  21197. /**
  21198. * Defines the diameter of the sphere
  21199. */
  21200. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21201. /**
  21202. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21203. */
  21204. side?: number);
  21205. /** @hidden */
  21206. _regenerateVertexData(): VertexData;
  21207. copy(id: string): Geometry;
  21208. serialize(): any;
  21209. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21210. }
  21211. /**
  21212. * Creates a disc geometry
  21213. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21214. */
  21215. class DiscGeometry extends _PrimitiveGeometry {
  21216. /**
  21217. * Defines the radius of the disc
  21218. */
  21219. radius: number;
  21220. /**
  21221. * Defines the tesselation factor to apply to the disc
  21222. */
  21223. tessellation: number;
  21224. /**
  21225. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21226. */
  21227. side: number;
  21228. /**
  21229. * Creates a new disc geometry
  21230. * @param id defines the unique ID of the geometry
  21231. * @param scene defines the hosting scene
  21232. * @param radius defines the radius of the disc
  21233. * @param tessellation defines the tesselation factor to apply to the disc
  21234. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21235. * @param mesh defines the hosting mesh (can be null)
  21236. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21237. */
  21238. constructor(id: string, scene: Scene,
  21239. /**
  21240. * Defines the radius of the disc
  21241. */
  21242. radius: number,
  21243. /**
  21244. * Defines the tesselation factor to apply to the disc
  21245. */
  21246. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21247. /**
  21248. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21249. */
  21250. side?: number);
  21251. /** @hidden */
  21252. _regenerateVertexData(): VertexData;
  21253. copy(id: string): Geometry;
  21254. }
  21255. /**
  21256. * Creates a new cylinder geometry
  21257. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  21258. */
  21259. class CylinderGeometry extends _PrimitiveGeometry {
  21260. /**
  21261. * Defines the height of the cylinder
  21262. */
  21263. height: number;
  21264. /**
  21265. * Defines the diameter of the cylinder's top cap
  21266. */
  21267. diameterTop: number;
  21268. /**
  21269. * Defines the diameter of the cylinder's bottom cap
  21270. */
  21271. diameterBottom: number;
  21272. /**
  21273. * Defines the tessellation factor to apply to the cylinder
  21274. */
  21275. tessellation: number;
  21276. /**
  21277. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21278. */
  21279. subdivisions: number;
  21280. /**
  21281. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21282. */
  21283. side: number;
  21284. /**
  21285. * Creates a new cylinder geometry
  21286. * @param id defines the unique ID of the geometry
  21287. * @param scene defines the hosting scene
  21288. * @param height defines the height of the cylinder
  21289. * @param diameterTop defines the diameter of the cylinder's top cap
  21290. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  21291. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  21292. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  21293. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21294. * @param mesh defines the hosting mesh (can be null)
  21295. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21296. */
  21297. constructor(id: string, scene: Scene,
  21298. /**
  21299. * Defines the height of the cylinder
  21300. */
  21301. height: number,
  21302. /**
  21303. * Defines the diameter of the cylinder's top cap
  21304. */
  21305. diameterTop: number,
  21306. /**
  21307. * Defines the diameter of the cylinder's bottom cap
  21308. */
  21309. diameterBottom: number,
  21310. /**
  21311. * Defines the tessellation factor to apply to the cylinder
  21312. */
  21313. tessellation: number,
  21314. /**
  21315. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  21316. */
  21317. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21318. /**
  21319. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21320. */
  21321. side?: number);
  21322. /** @hidden */
  21323. _regenerateVertexData(): VertexData;
  21324. copy(id: string): Geometry;
  21325. serialize(): any;
  21326. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  21327. }
  21328. /**
  21329. * Creates a new torus geometry
  21330. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  21331. */
  21332. class TorusGeometry extends _PrimitiveGeometry {
  21333. /**
  21334. * Defines the diameter of the torus
  21335. */
  21336. diameter: number;
  21337. /**
  21338. * Defines the thickness of the torus (ie. internal diameter)
  21339. */
  21340. thickness: number;
  21341. /**
  21342. * Defines the tesselation factor to apply to the torus
  21343. */
  21344. tessellation: number;
  21345. /**
  21346. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21347. */
  21348. side: number;
  21349. /**
  21350. * Creates a new torus geometry
  21351. * @param id defines the unique ID of the geometry
  21352. * @param scene defines the hosting scene
  21353. * @param diameter defines the diameter of the torus
  21354. * @param thickness defines the thickness of the torus (ie. internal diameter)
  21355. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  21356. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21357. * @param mesh defines the hosting mesh (can be null)
  21358. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21359. */
  21360. constructor(id: string, scene: Scene,
  21361. /**
  21362. * Defines the diameter of the torus
  21363. */
  21364. diameter: number,
  21365. /**
  21366. * Defines the thickness of the torus (ie. internal diameter)
  21367. */
  21368. thickness: number,
  21369. /**
  21370. * Defines the tesselation factor to apply to the torus
  21371. */
  21372. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21373. /**
  21374. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21375. */
  21376. side?: number);
  21377. /** @hidden */
  21378. _regenerateVertexData(): VertexData;
  21379. copy(id: string): Geometry;
  21380. serialize(): any;
  21381. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  21382. }
  21383. /**
  21384. * Creates a new ground geometry
  21385. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  21386. */
  21387. class GroundGeometry extends _PrimitiveGeometry {
  21388. /**
  21389. * Defines the width of the ground
  21390. */
  21391. width: number;
  21392. /**
  21393. * Defines the height of the ground
  21394. */
  21395. height: number;
  21396. /**
  21397. * Defines the subdivisions to apply to the ground
  21398. */
  21399. subdivisions: number;
  21400. /**
  21401. * Creates a new ground geometry
  21402. * @param id defines the unique ID of the geometry
  21403. * @param scene defines the hosting scene
  21404. * @param width defines the width of the ground
  21405. * @param height defines the height of the ground
  21406. * @param subdivisions defines the subdivisions to apply to the ground
  21407. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21408. * @param mesh defines the hosting mesh (can be null)
  21409. */
  21410. constructor(id: string, scene: Scene,
  21411. /**
  21412. * Defines the width of the ground
  21413. */
  21414. width: number,
  21415. /**
  21416. * Defines the height of the ground
  21417. */
  21418. height: number,
  21419. /**
  21420. * Defines the subdivisions to apply to the ground
  21421. */
  21422. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21423. /** @hidden */
  21424. _regenerateVertexData(): VertexData;
  21425. copy(id: string): Geometry;
  21426. serialize(): any;
  21427. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  21428. }
  21429. /**
  21430. * Creates a tiled ground geometry
  21431. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  21432. */
  21433. class TiledGroundGeometry extends _PrimitiveGeometry {
  21434. /**
  21435. * Defines the minimum value on X axis
  21436. */
  21437. xmin: number;
  21438. /**
  21439. * Defines the minimum value on Z axis
  21440. */
  21441. zmin: number;
  21442. /**
  21443. * Defines the maximum value on X axis
  21444. */
  21445. xmax: number;
  21446. /**
  21447. * Defines the maximum value on Z axis
  21448. */
  21449. zmax: number;
  21450. /**
  21451. * Defines the subdivisions to apply to the ground
  21452. */
  21453. subdivisions: {
  21454. w: number;
  21455. h: number;
  21456. };
  21457. /**
  21458. * Defines the precision to use when computing the tiles
  21459. */
  21460. precision: {
  21461. w: number;
  21462. h: number;
  21463. };
  21464. /**
  21465. * Creates a tiled ground geometry
  21466. * @param id defines the unique ID of the geometry
  21467. * @param scene defines the hosting scene
  21468. * @param xmin defines the minimum value on X axis
  21469. * @param zmin defines the minimum value on Z axis
  21470. * @param xmax defines the maximum value on X axis
  21471. * @param zmax defines the maximum value on Z axis
  21472. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  21473. * @param precision defines the precision to use when computing the tiles
  21474. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21475. * @param mesh defines the hosting mesh (can be null)
  21476. */
  21477. constructor(id: string, scene: Scene,
  21478. /**
  21479. * Defines the minimum value on X axis
  21480. */
  21481. xmin: number,
  21482. /**
  21483. * Defines the minimum value on Z axis
  21484. */
  21485. zmin: number,
  21486. /**
  21487. * Defines the maximum value on X axis
  21488. */
  21489. xmax: number,
  21490. /**
  21491. * Defines the maximum value on Z axis
  21492. */
  21493. zmax: number,
  21494. /**
  21495. * Defines the subdivisions to apply to the ground
  21496. */
  21497. subdivisions: {
  21498. w: number;
  21499. h: number;
  21500. },
  21501. /**
  21502. * Defines the precision to use when computing the tiles
  21503. */
  21504. precision: {
  21505. w: number;
  21506. h: number;
  21507. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21508. /** @hidden */
  21509. _regenerateVertexData(): VertexData;
  21510. copy(id: string): Geometry;
  21511. }
  21512. /**
  21513. * Creates a plane geometry
  21514. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21515. */
  21516. class PlaneGeometry extends _PrimitiveGeometry {
  21517. /**
  21518. * Defines the size of the plane (width === height)
  21519. */
  21520. size: number;
  21521. /**
  21522. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21523. */
  21524. side: number;
  21525. /**
  21526. * Creates a plane geometry
  21527. * @param id defines the unique ID of the geometry
  21528. * @param scene defines the hosting scene
  21529. * @param size defines the size of the plane (width === height)
  21530. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21531. * @param mesh defines the hosting mesh (can be null)
  21532. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21533. */
  21534. constructor(id: string, scene: Scene,
  21535. /**
  21536. * Defines the size of the plane (width === height)
  21537. */
  21538. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21539. /**
  21540. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21541. */
  21542. side?: number);
  21543. /** @hidden */
  21544. _regenerateVertexData(): VertexData;
  21545. copy(id: string): Geometry;
  21546. serialize(): any;
  21547. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21548. }
  21549. /**
  21550. * Creates a torus knot geometry
  21551. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21552. */
  21553. class TorusKnotGeometry extends _PrimitiveGeometry {
  21554. /**
  21555. * Defines the radius of the torus knot
  21556. */
  21557. radius: number;
  21558. /**
  21559. * Defines the thickness of the torus knot tube
  21560. */
  21561. tube: number;
  21562. /**
  21563. * Defines the number of radial segments
  21564. */
  21565. radialSegments: number;
  21566. /**
  21567. * Defines the number of tubular segments
  21568. */
  21569. tubularSegments: number;
  21570. /**
  21571. * Defines the first number of windings
  21572. */
  21573. p: number;
  21574. /**
  21575. * Defines the second number of windings
  21576. */
  21577. q: number;
  21578. /**
  21579. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21580. */
  21581. side: number;
  21582. /**
  21583. * Creates a torus knot geometry
  21584. * @param id defines the unique ID of the geometry
  21585. * @param scene defines the hosting scene
  21586. * @param radius defines the radius of the torus knot
  21587. * @param tube defines the thickness of the torus knot tube
  21588. * @param radialSegments defines the number of radial segments
  21589. * @param tubularSegments defines the number of tubular segments
  21590. * @param p defines the first number of windings
  21591. * @param q defines the second number of windings
  21592. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21593. * @param mesh defines the hosting mesh (can be null)
  21594. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21595. */
  21596. constructor(id: string, scene: Scene,
  21597. /**
  21598. * Defines the radius of the torus knot
  21599. */
  21600. radius: number,
  21601. /**
  21602. * Defines the thickness of the torus knot tube
  21603. */
  21604. tube: number,
  21605. /**
  21606. * Defines the number of radial segments
  21607. */
  21608. radialSegments: number,
  21609. /**
  21610. * Defines the number of tubular segments
  21611. */
  21612. tubularSegments: number,
  21613. /**
  21614. * Defines the first number of windings
  21615. */
  21616. p: number,
  21617. /**
  21618. * Defines the second number of windings
  21619. */
  21620. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21621. /**
  21622. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21623. */
  21624. side?: number);
  21625. /** @hidden */
  21626. _regenerateVertexData(): VertexData;
  21627. copy(id: string): Geometry;
  21628. serialize(): any;
  21629. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21630. }
  21631. }
  21632. declare module BABYLON {
  21633. class GroundMesh extends Mesh {
  21634. generateOctree: boolean;
  21635. private _heightQuads;
  21636. /** @hidden */
  21637. _subdivisionsX: number;
  21638. /** @hidden */
  21639. _subdivisionsY: number;
  21640. /** @hidden */
  21641. _width: number;
  21642. /** @hidden */
  21643. _height: number;
  21644. /** @hidden */
  21645. _minX: number;
  21646. /** @hidden */
  21647. _maxX: number;
  21648. /** @hidden */
  21649. _minZ: number;
  21650. /** @hidden */
  21651. _maxZ: number;
  21652. constructor(name: string, scene: Scene);
  21653. getClassName(): string;
  21654. readonly subdivisions: number;
  21655. readonly subdivisionsX: number;
  21656. readonly subdivisionsY: number;
  21657. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21658. /**
  21659. * Returns a height (y) value in the Worl system :
  21660. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21661. * Returns the ground y position if (x, z) are outside the ground surface.
  21662. */
  21663. getHeightAtCoordinates(x: number, z: number): number;
  21664. /**
  21665. * Returns a normalized vector (Vector3) orthogonal to the ground
  21666. * at the ground coordinates (x, z) expressed in the World system.
  21667. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21668. */
  21669. getNormalAtCoordinates(x: number, z: number): Vector3;
  21670. /**
  21671. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21672. * at the ground coordinates (x, z) expressed in the World system.
  21673. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21674. * Returns the GroundMesh.
  21675. */
  21676. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21677. /**
  21678. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21679. * if the ground has been updated.
  21680. * This can be used in the render loop.
  21681. * Returns the GroundMesh.
  21682. */
  21683. updateCoordinateHeights(): GroundMesh;
  21684. private _getFacetAt;
  21685. private _initHeightQuads;
  21686. private _computeHeightQuads;
  21687. serialize(serializationObject: any): void;
  21688. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21689. }
  21690. }
  21691. declare module BABYLON {
  21692. /**
  21693. * Creates an instance based on a source mesh.
  21694. */
  21695. class InstancedMesh extends AbstractMesh {
  21696. private _sourceMesh;
  21697. private _currentLOD;
  21698. constructor(name: string, source: Mesh);
  21699. /**
  21700. * Returns the string "InstancedMesh".
  21701. */
  21702. getClassName(): string;
  21703. readonly receiveShadows: boolean;
  21704. readonly material: Nullable<Material>;
  21705. readonly visibility: number;
  21706. readonly skeleton: Nullable<Skeleton>;
  21707. renderingGroupId: number;
  21708. /**
  21709. * Returns the total number of vertices (integer).
  21710. */
  21711. getTotalVertices(): number;
  21712. readonly sourceMesh: Mesh;
  21713. /**
  21714. * Is this node ready to be used/rendered
  21715. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21716. * @return {boolean} is it ready
  21717. */
  21718. isReady(completeCheck?: boolean): boolean;
  21719. /**
  21720. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21721. */
  21722. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21723. /**
  21724. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21725. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21726. * The `data` are either a numeric array either a Float32Array.
  21727. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21728. * 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).
  21729. * Note that a new underlying VertexBuffer object is created each call.
  21730. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21731. *
  21732. * Possible `kind` values :
  21733. * - BABYLON.VertexBuffer.PositionKind
  21734. * - BABYLON.VertexBuffer.UVKind
  21735. * - BABYLON.VertexBuffer.UV2Kind
  21736. * - BABYLON.VertexBuffer.UV3Kind
  21737. * - BABYLON.VertexBuffer.UV4Kind
  21738. * - BABYLON.VertexBuffer.UV5Kind
  21739. * - BABYLON.VertexBuffer.UV6Kind
  21740. * - BABYLON.VertexBuffer.ColorKind
  21741. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21742. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21743. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21744. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21745. *
  21746. * Returns the Mesh.
  21747. */
  21748. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21749. /**
  21750. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21751. * If the mesh has no geometry, it is simply returned as it is.
  21752. * The `data` are either a numeric array either a Float32Array.
  21753. * No new underlying VertexBuffer object is created.
  21754. * 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.
  21755. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21756. *
  21757. * Possible `kind` values :
  21758. * - BABYLON.VertexBuffer.PositionKind
  21759. * - BABYLON.VertexBuffer.UVKind
  21760. * - BABYLON.VertexBuffer.UV2Kind
  21761. * - BABYLON.VertexBuffer.UV3Kind
  21762. * - BABYLON.VertexBuffer.UV4Kind
  21763. * - BABYLON.VertexBuffer.UV5Kind
  21764. * - BABYLON.VertexBuffer.UV6Kind
  21765. * - BABYLON.VertexBuffer.ColorKind
  21766. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21767. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21768. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21769. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21770. *
  21771. * Returns the Mesh.
  21772. */
  21773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21774. /**
  21775. * Sets the mesh indices.
  21776. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21777. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21778. * This method creates a new index buffer each call.
  21779. * Returns the Mesh.
  21780. */
  21781. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21782. /**
  21783. * Boolean : True if the mesh owns the requested kind of data.
  21784. */
  21785. isVerticesDataPresent(kind: string): boolean;
  21786. /**
  21787. * Returns an array of indices (IndicesArray).
  21788. */
  21789. getIndices(): Nullable<IndicesArray>;
  21790. readonly _positions: Nullable<Vector3[]>;
  21791. /**
  21792. * Sets a new updated BoundingInfo to the mesh.
  21793. * Returns the mesh.
  21794. */
  21795. refreshBoundingInfo(): InstancedMesh;
  21796. /** @hidden */
  21797. _preActivate(): InstancedMesh;
  21798. /** @hidden */
  21799. _activate(renderId: number): InstancedMesh;
  21800. /**
  21801. * Returns the current associated LOD AbstractMesh.
  21802. */
  21803. getLOD(camera: Camera): AbstractMesh;
  21804. /** @hidden */
  21805. _syncSubMeshes(): InstancedMesh;
  21806. /** @hidden */
  21807. _generatePointsArray(): boolean;
  21808. /**
  21809. * Creates a new InstancedMesh from the current mesh.
  21810. * - name (string) : the cloned mesh name
  21811. * - newParent (optional Node) : the optional Node to parent the clone to.
  21812. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21813. *
  21814. * Returns the clone.
  21815. */
  21816. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21817. /**
  21818. * Disposes the InstancedMesh.
  21819. * Returns nothing.
  21820. */
  21821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21822. }
  21823. }
  21824. declare module BABYLON {
  21825. class LinesMesh extends Mesh {
  21826. useVertexColor?: boolean | undefined;
  21827. useVertexAlpha?: boolean | undefined;
  21828. color: Color3;
  21829. alpha: number;
  21830. /**
  21831. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21832. * This margin is expressed in world space coordinates, so its value may vary.
  21833. * Default value is 0.1
  21834. * @returns the intersection Threshold value.
  21835. */
  21836. /**
  21837. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21838. * This margin is expressed in world space coordinates, so its value may vary.
  21839. * @param value the new threshold to apply
  21840. */
  21841. intersectionThreshold: number;
  21842. private _intersectionThreshold;
  21843. private _colorShader;
  21844. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21845. /**
  21846. * Returns the string "LineMesh"
  21847. */
  21848. getClassName(): string;
  21849. /**
  21850. * @hidden
  21851. */
  21852. /**
  21853. * @hidden
  21854. */
  21855. material: Material;
  21856. /**
  21857. * @hidden
  21858. */
  21859. readonly checkCollisions: boolean;
  21860. createInstance(name: string): InstancedMesh;
  21861. /** @hidden */
  21862. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21863. /** @hidden */
  21864. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21865. dispose(doNotRecurse?: boolean): void;
  21866. /**
  21867. * Returns a new LineMesh object cloned from the current one.
  21868. */
  21869. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21870. }
  21871. }
  21872. declare module BABYLON {
  21873. /**
  21874. * @hidden
  21875. **/
  21876. class _InstancesBatch {
  21877. mustReturn: boolean;
  21878. visibleInstances: Nullable<InstancedMesh[]>[];
  21879. renderSelf: boolean[];
  21880. }
  21881. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21882. static _FRONTSIDE: number;
  21883. static _BACKSIDE: number;
  21884. static _DOUBLESIDE: number;
  21885. static _DEFAULTSIDE: number;
  21886. static _NO_CAP: number;
  21887. static _CAP_START: number;
  21888. static _CAP_END: number;
  21889. static _CAP_ALL: number;
  21890. /**
  21891. * Mesh side orientation : usually the external or front surface
  21892. */
  21893. static readonly FRONTSIDE: number;
  21894. /**
  21895. * Mesh side orientation : usually the internal or back surface
  21896. */
  21897. static readonly BACKSIDE: number;
  21898. /**
  21899. * Mesh side orientation : both internal and external or front and back surfaces
  21900. */
  21901. static readonly DOUBLESIDE: number;
  21902. /**
  21903. * Mesh side orientation : by default, `FRONTSIDE`
  21904. */
  21905. static readonly DEFAULTSIDE: number;
  21906. /**
  21907. * Mesh cap setting : no cap
  21908. */
  21909. static readonly NO_CAP: number;
  21910. /**
  21911. * Mesh cap setting : one cap at the beginning of the mesh
  21912. */
  21913. static readonly CAP_START: number;
  21914. /**
  21915. * Mesh cap setting : one cap at the end of the mesh
  21916. */
  21917. static readonly CAP_END: number;
  21918. /**
  21919. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21920. */
  21921. static readonly CAP_ALL: number;
  21922. private _onBeforeRenderObservable;
  21923. private _onAfterRenderObservable;
  21924. private _onBeforeDrawObservable;
  21925. /**
  21926. * An event triggered before rendering the mesh
  21927. */
  21928. readonly onBeforeRenderObservable: Observable<Mesh>;
  21929. /**
  21930. * An event triggered after rendering the mesh
  21931. */
  21932. readonly onAfterRenderObservable: Observable<Mesh>;
  21933. /**
  21934. * An event triggered before drawing the mesh
  21935. */
  21936. readonly onBeforeDrawObservable: Observable<Mesh>;
  21937. private _onBeforeDrawObserver;
  21938. onBeforeDraw: () => void;
  21939. delayLoadState: number;
  21940. instances: InstancedMesh[];
  21941. delayLoadingFile: string;
  21942. /** @hidden */
  21943. _binaryInfo: any;
  21944. private _LODLevels;
  21945. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21946. private _morphTargetManager;
  21947. morphTargetManager: Nullable<MorphTargetManager>;
  21948. /** @hidden */
  21949. _geometry: Nullable<Geometry>;
  21950. /** @hidden */
  21951. _delayInfo: Array<string>;
  21952. /** @hidden */
  21953. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21954. /** @hidden */
  21955. _visibleInstances: any;
  21956. private _renderIdForInstances;
  21957. private _batchCache;
  21958. private _instancesBufferSize;
  21959. private _instancesBuffer;
  21960. private _instancesData;
  21961. private _overridenInstanceCount;
  21962. private _effectiveMaterial;
  21963. /** @hidden */
  21964. _shouldGenerateFlatShading: boolean;
  21965. private _preActivateId;
  21966. /** @hidden */
  21967. _originalBuilderSideOrientation: number;
  21968. overrideMaterialSideOrientation: Nullable<number>;
  21969. private _areNormalsFrozen;
  21970. private _sourcePositions;
  21971. private _sourceNormals;
  21972. private _source;
  21973. readonly source: Nullable<Mesh>;
  21974. isUnIndexed: boolean;
  21975. /**
  21976. * @constructor
  21977. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21978. * @param {Scene} scene The scene to add this mesh to.
  21979. * @param {Node} parent The parent of this mesh, if it has one
  21980. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21981. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21982. * When false, achieved by calling a clone(), also passing False.
  21983. * This will make creation of children, recursive.
  21984. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21985. */
  21986. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21987. /**
  21988. * Returns the string "Mesh".
  21989. */
  21990. getClassName(): string;
  21991. /**
  21992. * Returns a string.
  21993. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21994. */
  21995. toString(fullDetails?: boolean): string;
  21996. /** @hidden */
  21997. _unBindEffect(): void;
  21998. /**
  21999. * True if the mesh has some Levels Of Details (LOD).
  22000. * Returns a boolean.
  22001. */
  22002. readonly hasLODLevels: boolean;
  22003. /**
  22004. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  22005. * @returns an array of {BABYLON.MeshLODLevel}
  22006. */
  22007. getLODLevels(): MeshLODLevel[];
  22008. private _sortLODLevels;
  22009. /**
  22010. * Add a mesh as LOD level triggered at the given distance.
  22011. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22012. * @param distance The distance from the center of the object to show this level
  22013. * @param mesh The mesh to be added as LOD level (can be null)
  22014. * @return This mesh (for chaining)
  22015. */
  22016. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  22017. /**
  22018. * Returns the LOD level mesh at the passed distance or null if not found.
  22019. * It is related to the method `addLODLevel(distance, mesh)`.
  22020. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22021. * Returns an object Mesh or `null`.
  22022. */
  22023. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  22024. /**
  22025. * Remove a mesh from the LOD array
  22026. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  22027. * @param {Mesh} mesh The mesh to be removed.
  22028. * @return {Mesh} This mesh (for chaining)
  22029. */
  22030. removeLODLevel(mesh: Mesh): Mesh;
  22031. /**
  22032. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  22033. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  22034. */
  22035. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  22036. /**
  22037. * Returns the mesh internal Geometry object.
  22038. */
  22039. readonly geometry: Nullable<Geometry>;
  22040. /**
  22041. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  22042. */
  22043. getTotalVertices(): number;
  22044. /**
  22045. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  22046. * 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.
  22047. * You can force the copy with forceCopy === true
  22048. * Returns null if the mesh has no geometry or no vertex buffer.
  22049. * Possible `kind` values :
  22050. * - BABYLON.VertexBuffer.PositionKind
  22051. * - BABYLON.VertexBuffer.UVKind
  22052. * - BABYLON.VertexBuffer.UV2Kind
  22053. * - BABYLON.VertexBuffer.UV3Kind
  22054. * - BABYLON.VertexBuffer.UV4Kind
  22055. * - BABYLON.VertexBuffer.UV5Kind
  22056. * - BABYLON.VertexBuffer.UV6Kind
  22057. * - BABYLON.VertexBuffer.ColorKind
  22058. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22059. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22060. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22061. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22062. */
  22063. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22064. /**
  22065. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  22066. * Returns `null` if the mesh has no geometry.
  22067. * Possible `kind` values :
  22068. * - BABYLON.VertexBuffer.PositionKind
  22069. * - BABYLON.VertexBuffer.UVKind
  22070. * - BABYLON.VertexBuffer.UV2Kind
  22071. * - BABYLON.VertexBuffer.UV3Kind
  22072. * - BABYLON.VertexBuffer.UV4Kind
  22073. * - BABYLON.VertexBuffer.UV5Kind
  22074. * - BABYLON.VertexBuffer.UV6Kind
  22075. * - BABYLON.VertexBuffer.ColorKind
  22076. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22077. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22078. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22079. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22080. */
  22081. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22082. isVerticesDataPresent(kind: string): boolean;
  22083. /**
  22084. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  22085. * Possible `kind` values :
  22086. * - BABYLON.VertexBuffer.PositionKind
  22087. * - BABYLON.VertexBuffer.UVKind
  22088. * - BABYLON.VertexBuffer.UV2Kind
  22089. * - BABYLON.VertexBuffer.UV3Kind
  22090. * - BABYLON.VertexBuffer.UV4Kind
  22091. * - BABYLON.VertexBuffer.UV5Kind
  22092. * - BABYLON.VertexBuffer.UV6Kind
  22093. * - BABYLON.VertexBuffer.ColorKind
  22094. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22095. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22096. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22097. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22098. */
  22099. isVertexBufferUpdatable(kind: string): boolean;
  22100. /**
  22101. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  22102. * Possible `kind` values :
  22103. * - BABYLON.VertexBuffer.PositionKind
  22104. * - BABYLON.VertexBuffer.UVKind
  22105. * - BABYLON.VertexBuffer.UV2Kind
  22106. * - BABYLON.VertexBuffer.UV3Kind
  22107. * - BABYLON.VertexBuffer.UV4Kind
  22108. * - BABYLON.VertexBuffer.UV5Kind
  22109. * - BABYLON.VertexBuffer.UV6Kind
  22110. * - BABYLON.VertexBuffer.ColorKind
  22111. * - BABYLON.VertexBuffer.MatricesIndicesKind
  22112. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  22113. * - BABYLON.VertexBuffer.MatricesWeightsKind
  22114. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  22115. */
  22116. getVerticesDataKinds(): string[];
  22117. /**
  22118. * Returns a positive integer : the total number of indices in this mesh geometry.
  22119. * Returns zero if the mesh has no geometry.
  22120. */
  22121. getTotalIndices(): number;
  22122. /**
  22123. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22124. * @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.
  22125. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22126. * @returns the indices array or an empty array if the mesh has no geometry
  22127. */
  22128. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22129. readonly isBlocked: boolean;
  22130. /**
  22131. * Determine if the current mesh is ready to be rendered
  22132. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  22133. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  22134. * @returns true if all associated assets are ready (material, textures, shaders)
  22135. */
  22136. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  22137. /**
  22138. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  22139. * This property is pertinent only for updatable parametric shapes.
  22140. */
  22141. readonly areNormalsFrozen: boolean;
  22142. /**
  22143. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22144. * It has no effect at all on other shapes.
  22145. * It prevents the mesh normals from being recomputed on next `positions` array update.
  22146. * Returns the Mesh.
  22147. */
  22148. freezeNormals(): Mesh;
  22149. /**
  22150. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  22151. * It has no effect at all on other shapes.
  22152. * It reactivates the mesh normals computation if it was previously frozen.
  22153. * Returns the Mesh.
  22154. */
  22155. unfreezeNormals(): Mesh;
  22156. /**
  22157. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  22158. */
  22159. overridenInstanceCount: number;
  22160. /** @hidden */
  22161. _preActivate(): Mesh;
  22162. /** @hidden */
  22163. _preActivateForIntermediateRendering(renderId: number): Mesh;
  22164. /** @hidden */
  22165. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  22166. /**
  22167. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22168. * This means the mesh underlying bounding box and sphere are recomputed.
  22169. * Returns the Mesh.
  22170. */
  22171. refreshBoundingInfo(): Mesh;
  22172. /** @hidden */
  22173. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  22174. private _getPositionData;
  22175. /** @hidden */
  22176. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  22177. subdivide(count: number): void;
  22178. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  22179. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  22180. /**
  22181. * Sets the mesh VertexBuffer.
  22182. * Returns the Mesh.
  22183. */
  22184. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  22185. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  22186. /**
  22187. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  22188. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  22189. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  22190. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  22191. * Returns the Mesh.
  22192. */
  22193. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  22194. /**
  22195. * Creates a un-shared specific occurence of the geometry for the mesh.
  22196. * Returns the Mesh.
  22197. */
  22198. makeGeometryUnique(): Mesh;
  22199. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  22200. /**
  22201. * Update the current index buffer
  22202. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22203. * Returns the Mesh.
  22204. */
  22205. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  22206. /**
  22207. * Invert the geometry to move from a right handed system to a left handed one.
  22208. * Returns the Mesh.
  22209. */
  22210. toLeftHanded(): Mesh;
  22211. /** @hidden */
  22212. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  22213. /** @hidden */
  22214. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  22215. /**
  22216. * Registers for this mesh a javascript function called just before the rendering process.
  22217. * This function is passed the current mesh.
  22218. * Return the Mesh.
  22219. */
  22220. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22221. /**
  22222. * Disposes a previously registered javascript function called before the rendering.
  22223. * This function is passed the current mesh.
  22224. * Returns the Mesh.
  22225. */
  22226. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  22227. /**
  22228. * Registers for this mesh a javascript function called just after the rendering is complete.
  22229. * This function is passed the current mesh.
  22230. * Returns the Mesh.
  22231. */
  22232. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22233. /**
  22234. * Disposes a previously registered javascript function called after the rendering.
  22235. * This function is passed the current mesh.
  22236. * Return the Mesh.
  22237. */
  22238. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  22239. /** @hidden */
  22240. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  22241. /** @hidden */
  22242. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  22243. /** @hidden */
  22244. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  22245. /**
  22246. * 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
  22247. * @param subMesh defines the subMesh to render
  22248. * @param enableAlphaMode defines if alpha mode can be changed
  22249. * @returns the current mesh
  22250. */
  22251. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22252. private _onBeforeDraw;
  22253. /**
  22254. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  22255. */
  22256. getEmittedParticleSystems(): IParticleSystem[];
  22257. /**
  22258. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  22259. */
  22260. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  22261. /**
  22262. * Normalize matrix weights so that all vertices have a total weight set to 1
  22263. */
  22264. cleanMatrixWeights(): void;
  22265. /** @hidden */
  22266. _checkDelayState(): Mesh;
  22267. private _queueLoad;
  22268. /**
  22269. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22270. * A mesh is in the frustum if its bounding box intersects the frustum
  22271. * @param frustumPlanes defines the frustum to test
  22272. * @returns true if the mesh is in the frustum planes
  22273. */
  22274. isInFrustum(frustumPlanes: Plane[]): boolean;
  22275. /**
  22276. * Sets the mesh material by the material or multiMaterial `id` property.
  22277. * The material `id` is a string identifying the material or the multiMaterial.
  22278. * This method returns the Mesh.
  22279. */
  22280. setMaterialByID(id: string): Mesh;
  22281. /**
  22282. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22283. */
  22284. getAnimatables(): IAnimatable[];
  22285. /**
  22286. * Modifies the mesh geometry according to the passed transformation matrix.
  22287. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22288. * The mesh normals are modified using the same transformation.
  22289. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  22290. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22291. * Returns the Mesh.
  22292. */
  22293. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22294. /**
  22295. * Modifies the mesh geometry according to its own current World Matrix.
  22296. * The mesh World Matrix is then reset.
  22297. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22298. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  22299. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22300. * Returns the Mesh.
  22301. */
  22302. bakeCurrentTransformIntoVertices(): Mesh;
  22303. readonly _positions: Nullable<Vector3[]>;
  22304. /** @hidden */
  22305. _resetPointsArrayCache(): Mesh;
  22306. /** @hidden */
  22307. _generatePointsArray(): boolean;
  22308. /**
  22309. * Returns a new Mesh object generated from the current mesh properties.
  22310. * This method must not get confused with createInstance().
  22311. * The parameter `name` is a string, the name given to the new mesh.
  22312. * The optional parameter `newParent` can be any Node object (default `null`).
  22313. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  22314. * 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.
  22315. */
  22316. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22317. /**
  22318. * Releases resources associated with this mesh.
  22319. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22320. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22321. */
  22322. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22323. /**
  22324. * Modifies the mesh geometry according to a displacement map.
  22325. * 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.
  22326. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22327. * This method returns nothing.
  22328. * @param url is a string, the URL from the image file is to be downloaded.
  22329. * @param minHeight is the lower limit of the displacement.
  22330. * @param maxHeight is the upper limit of the displacement.
  22331. * @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.
  22332. * @param uvOffset is an optional vector2 used to offset UV.
  22333. * @param uvScale is an optional vector2 used to scale UV.
  22334. * @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.
  22335. * @returns the Mesh.
  22336. */
  22337. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22338. /**
  22339. * Modifies the mesh geometry according to a displacementMap buffer.
  22340. * 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.
  22341. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22342. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22343. * @param heightMapWidth is the width of the buffer image.
  22344. * @param heightMapHeight is the height of the buffer image.
  22345. * @param minHeight is the lower limit of the displacement.
  22346. * @param maxHeight is the upper limit of the displacement.
  22347. * @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.
  22348. * @param uvOffset is an optional vector2 used to offset UV.
  22349. * @param uvScale is an optional vector2 used to scale UV.
  22350. * @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.
  22351. * @returns the Mesh.
  22352. */
  22353. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22354. /**
  22355. * Modify the mesh to get a flat shading rendering.
  22356. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22357. * This method returns the Mesh.
  22358. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22359. */
  22360. convertToFlatShadedMesh(): Mesh;
  22361. /**
  22362. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22363. * In other words, more vertices, no more indices and a single bigger VBO.
  22364. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22365. * Returns the Mesh.
  22366. */
  22367. convertToUnIndexedMesh(): Mesh;
  22368. /**
  22369. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  22370. * This method returns the Mesh.
  22371. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22372. */
  22373. flipFaces(flipNormals?: boolean): Mesh;
  22374. /**
  22375. * Creates a new InstancedMesh object from the mesh model.
  22376. * An instance shares the same properties and the same material than its model.
  22377. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  22378. * Only these properties of each instance can then be set individually :
  22379. * - position
  22380. * - rotation
  22381. * - rotationQuaternion
  22382. * - setPivotMatrix
  22383. * - scaling
  22384. *
  22385. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22386. * Warning : this method is not supported for Line mesh and LineSystem
  22387. */
  22388. createInstance(name: string): InstancedMesh;
  22389. /**
  22390. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22391. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22392. * This method returns the Mesh.
  22393. */
  22394. synchronizeInstances(): Mesh;
  22395. /**
  22396. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22397. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22398. * This should be used together with the simplification to avoid disappearing triangles.
  22399. * Returns the Mesh.
  22400. * @param successCallback an optional success callback to be called after the optimization finished.
  22401. */
  22402. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22403. serialize(serializationObject: any): void;
  22404. /** @hidden */
  22405. _syncGeometryWithMorphTargetManager(): void;
  22406. /**
  22407. * Returns a new Mesh object parsed from the source provided.
  22408. * The parameter `parsedMesh` is the source.
  22409. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22410. */
  22411. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22412. /**
  22413. * Creates a ribbon mesh.
  22414. * Please consider using the same method from the MeshBuilder class instead.
  22415. * 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.
  22416. *
  22417. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22418. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22419. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  22420. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  22421. * 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.
  22422. * 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.
  22423. * 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
  22424. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22425. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22426. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22427. */
  22428. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22429. /**
  22430. * Creates a plane polygonal mesh. By default, this is a disc.
  22431. * Please consider using the same method from the MeshBuilder class instead.
  22432. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  22433. * 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.
  22434. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22435. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22436. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22437. */
  22438. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22439. /**
  22440. * Creates a box mesh.
  22441. * Please consider using the same method from the MeshBuilder class instead.
  22442. * The parameter `size` sets the size (float) of each box side (default 1).
  22443. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22444. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22445. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22446. */
  22447. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22448. /**
  22449. * Creates a sphere mesh.
  22450. * Please consider using the same method from the MeshBuilder class instead.
  22451. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  22452. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  22453. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22454. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22455. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22456. */
  22457. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22458. /**
  22459. * Creates a cylinder or a cone mesh.
  22460. * Please consider using the same method from the MeshBuilder class instead.
  22461. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22462. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22463. * 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.
  22464. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22465. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22466. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22467. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22468. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22469. */
  22470. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22471. /**
  22472. * Creates a torus mesh.
  22473. * Please consider using the same method from the MeshBuilder class instead.
  22474. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  22475. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22476. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22477. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22478. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22479. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22480. */
  22481. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22482. /**
  22483. * Creates a torus knot mesh.
  22484. * Please consider using the same method from the MeshBuilder class instead.
  22485. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22486. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22487. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22488. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22489. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22490. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22491. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22492. */
  22493. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22494. /**
  22495. * Creates a line mesh.
  22496. * Please consider using the same method from the MeshBuilder class instead.
  22497. * 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.
  22498. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22499. * The parameter `points` is an array successive Vector3.
  22500. * 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
  22501. * When updating an instance, remember that only point positions can change, not the number of points.
  22502. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22503. */
  22504. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22505. /**
  22506. * Creates a dashed line mesh.
  22507. * Please consider using the same method from the MeshBuilder class instead.
  22508. * 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.
  22509. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22510. * The parameter `points` is an array successive Vector3.
  22511. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22512. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22513. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22514. * 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
  22515. * When updating an instance, remember that only point positions can change, not the number of points.
  22516. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22517. */
  22518. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22519. /**
  22520. * Creates a polygon mesh.
  22521. * Please consider using the same method from the MeshBuilder class instead.
  22522. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22523. * 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.
  22524. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22525. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22526. * Remember you can only change the shape positions, not their number when updating a polygon.
  22527. */
  22528. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22529. /**
  22530. * Creates an extruded polygon mesh, with depth in the Y direction.
  22531. * Please consider using the same method from the MeshBuilder class instead.
  22532. */
  22533. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22534. /**
  22535. * Creates an extruded shape mesh.
  22536. * 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.
  22537. * Please consider using the same method from the MeshBuilder class instead.
  22538. *
  22539. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22540. * 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
  22541. * extruded along the Z axis.
  22542. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22543. * 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.
  22544. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22545. * 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
  22546. * 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
  22547. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22548. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22549. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22550. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22551. */
  22552. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22553. /**
  22554. * Creates an custom extruded shape mesh.
  22555. * 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.
  22556. * Please consider using the same method from the MeshBuilder class instead.
  22557. *
  22558. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22559. * 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
  22560. * extruded along the Z axis.
  22561. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22562. * 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
  22563. * and the distance of this point from the begining of the path :
  22564. * ```javascript
  22565. * var rotationFunction = function(i, distance) {
  22566. * // do things
  22567. * return rotationValue; }
  22568. * ```
  22569. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22570. * 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
  22571. * and the distance of this point from the begining of the path :
  22572. * ```javascript
  22573. * var scaleFunction = function(i, distance) {
  22574. * // do things
  22575. * return scaleValue;}
  22576. * ```
  22577. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22578. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22579. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22580. * 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
  22581. * 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
  22582. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22583. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22584. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22585. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22586. */
  22587. 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;
  22588. /**
  22589. * Creates lathe mesh.
  22590. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22591. * Please consider using the same method from the MeshBuilder class instead.
  22592. * 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
  22593. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22594. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22595. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22596. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22597. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22599. */
  22600. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22601. /**
  22602. * Creates a plane mesh.
  22603. * Please consider using the same method from the MeshBuilder class instead.
  22604. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22605. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22606. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22607. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22608. */
  22609. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22610. /**
  22611. * Creates a ground mesh.
  22612. * Please consider using the same method from the MeshBuilder class instead.
  22613. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22614. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22615. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22616. */
  22617. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22618. /**
  22619. * Creates a tiled ground mesh.
  22620. * Please consider using the same method from the MeshBuilder class instead.
  22621. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22622. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22623. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22624. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22625. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22626. * numbers of subdivisions on the ground width and height of each tile.
  22627. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22628. */
  22629. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22630. w: number;
  22631. h: number;
  22632. }, precision: {
  22633. w: number;
  22634. h: number;
  22635. }, scene: Scene, updatable?: boolean): Mesh;
  22636. /**
  22637. * Creates a ground mesh from a height map.
  22638. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22639. * Please consider using the same method from the MeshBuilder class instead.
  22640. * The parameter `url` sets the URL of the height map image resource.
  22641. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22642. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22643. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22644. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22645. * 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).
  22646. * This function is passed the newly built mesh :
  22647. * ```javascript
  22648. * function(mesh) { // do things
  22649. * return; }
  22650. * ```
  22651. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22652. */
  22653. 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;
  22654. /**
  22655. * Creates a tube mesh.
  22656. * 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.
  22657. * Please consider using the same method from the MeshBuilder class instead.
  22658. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22659. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22660. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22661. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22662. * 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.
  22663. * It must return a radius value (positive float) :
  22664. * ```javascript
  22665. * var radiusFunction = function(i, distance) {
  22666. * // do things
  22667. * return radius; }
  22668. * ```
  22669. * 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
  22670. * 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
  22671. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22672. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22673. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22674. */
  22675. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22676. (i: number, distance: number): number;
  22677. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22678. /**
  22679. * Creates a polyhedron mesh.
  22680. * Please consider using the same method from the MeshBuilder class instead.
  22681. * 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
  22682. * to choose the wanted type.
  22683. * The parameter `size` (positive float, default 1) sets the polygon size.
  22684. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22685. * 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`.
  22686. * 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
  22687. * 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)`).
  22688. * 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
  22689. * 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.
  22690. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22691. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22692. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22693. */
  22694. static CreatePolyhedron(name: string, options: {
  22695. type?: number;
  22696. size?: number;
  22697. sizeX?: number;
  22698. sizeY?: number;
  22699. sizeZ?: number;
  22700. custom?: any;
  22701. faceUV?: Vector4[];
  22702. faceColors?: Color4[];
  22703. updatable?: boolean;
  22704. sideOrientation?: number;
  22705. }, scene: Scene): Mesh;
  22706. /**
  22707. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22708. * Please consider using the same method from the MeshBuilder class instead.
  22709. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22710. * 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`).
  22711. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22712. * 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.
  22713. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22714. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22715. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22716. */
  22717. static CreateIcoSphere(name: string, options: {
  22718. radius?: number;
  22719. flat?: boolean;
  22720. subdivisions?: number;
  22721. sideOrientation?: number;
  22722. updatable?: boolean;
  22723. }, scene: Scene): Mesh;
  22724. /**
  22725. * Creates a decal mesh.
  22726. * Please consider using the same method from the MeshBuilder class instead.
  22727. * 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.
  22728. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22729. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22730. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22731. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22732. */
  22733. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22734. /**
  22735. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22736. */
  22737. setPositionsForCPUSkinning(): Float32Array;
  22738. /**
  22739. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22740. */
  22741. setNormalsForCPUSkinning(): Float32Array;
  22742. /**
  22743. * Updates the vertex buffer by applying transformation from the bones.
  22744. * Returns the Mesh.
  22745. *
  22746. * @param {skeleton} skeleton to apply
  22747. */
  22748. applySkeleton(skeleton: Skeleton): Mesh;
  22749. /**
  22750. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22751. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22752. */
  22753. static MinMax(meshes: AbstractMesh[]): {
  22754. min: Vector3;
  22755. max: Vector3;
  22756. };
  22757. /**
  22758. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22759. */
  22760. static Center(meshesOrMinMaxVector: {
  22761. min: Vector3;
  22762. max: Vector3;
  22763. } | AbstractMesh[]): Vector3;
  22764. /**
  22765. * Merge the array of meshes into a single mesh for performance reasons.
  22766. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22767. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22768. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22769. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22770. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22771. */
  22772. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22773. }
  22774. }
  22775. declare module BABYLON {
  22776. /**
  22777. * Define an interface for all classes that will get and set the data on vertices
  22778. */
  22779. interface IGetSetVerticesData {
  22780. isVerticesDataPresent(kind: string): boolean;
  22781. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22782. /**
  22783. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22784. * @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.
  22785. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22786. * @returns the indices array or an empty array if the mesh has no geometry
  22787. */
  22788. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22789. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22790. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22791. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22792. }
  22793. /**
  22794. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22795. */
  22796. class VertexData {
  22797. /**
  22798. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22799. */
  22800. positions: Nullable<FloatArray>;
  22801. /**
  22802. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22803. */
  22804. normals: Nullable<FloatArray>;
  22805. /**
  22806. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22807. */
  22808. tangents: Nullable<FloatArray>;
  22809. /**
  22810. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22811. */
  22812. uvs: Nullable<FloatArray>;
  22813. /**
  22814. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22815. */
  22816. uvs2: Nullable<FloatArray>;
  22817. /**
  22818. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22819. */
  22820. uvs3: Nullable<FloatArray>;
  22821. /**
  22822. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22823. */
  22824. uvs4: Nullable<FloatArray>;
  22825. /**
  22826. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22827. */
  22828. uvs5: Nullable<FloatArray>;
  22829. /**
  22830. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22831. */
  22832. uvs6: Nullable<FloatArray>;
  22833. /**
  22834. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22835. */
  22836. colors: Nullable<FloatArray>;
  22837. /**
  22838. * 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).
  22839. */
  22840. matricesIndices: Nullable<FloatArray>;
  22841. /**
  22842. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22843. */
  22844. matricesWeights: Nullable<FloatArray>;
  22845. /**
  22846. * An array extending the number of possible indices
  22847. */
  22848. matricesIndicesExtra: Nullable<FloatArray>;
  22849. /**
  22850. * An array extending the number of possible weights when the number of indices is extended
  22851. */
  22852. matricesWeightsExtra: Nullable<FloatArray>;
  22853. /**
  22854. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22855. */
  22856. indices: Nullable<IndicesArray>;
  22857. /**
  22858. * Uses the passed data array to set the set the values for the specified kind of data
  22859. * @param data a linear array of floating numbers
  22860. * @param kind the type of data that is being set, eg positions, colors etc
  22861. */
  22862. set(data: FloatArray, kind: string): void;
  22863. /**
  22864. * Associates the vertexData to the passed Mesh.
  22865. * Sets it as updatable or not (default `false`)
  22866. * @param mesh the mesh the vertexData is applied to
  22867. * @param updatable when used and having the value true allows new data to update the vertexData
  22868. * @returns the VertexData
  22869. */
  22870. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22871. /**
  22872. * Associates the vertexData to the passed Geometry.
  22873. * Sets it as updatable or not (default `false`)
  22874. * @param geometry the geometry the vertexData is applied to
  22875. * @param updatable when used and having the value true allows new data to update the vertexData
  22876. * @returns VertexData
  22877. */
  22878. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22879. /**
  22880. * Updates the associated mesh
  22881. * @param mesh the mesh to be updated
  22882. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22883. * @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
  22884. * @returns VertexData
  22885. */
  22886. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22887. /**
  22888. * Updates the associated geometry
  22889. * @param geometry the geometry to be updated
  22890. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22891. * @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
  22892. * @returns VertexData.
  22893. */
  22894. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22895. private _applyTo;
  22896. private _update;
  22897. /**
  22898. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22899. * @param matrix the transforming matrix
  22900. * @returns the VertexData
  22901. */
  22902. transform(matrix: Matrix): VertexData;
  22903. /**
  22904. * Merges the passed VertexData into the current one
  22905. * @param other the VertexData to be merged into the current one
  22906. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22907. * @returns the modified VertexData
  22908. */
  22909. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22910. private _mergeElement;
  22911. private _validate;
  22912. /**
  22913. * Serializes the VertexData
  22914. * @returns a serialized object
  22915. */
  22916. serialize(): any;
  22917. /**
  22918. * Extracts the vertexData from a mesh
  22919. * @param mesh the mesh from which to extract the VertexData
  22920. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22921. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22922. * @returns the object VertexData associated to the passed mesh
  22923. */
  22924. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22925. /**
  22926. * Extracts the vertexData from the geometry
  22927. * @param geometry the geometry from which to extract the VertexData
  22928. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22929. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22930. * @returns the object VertexData associated to the passed mesh
  22931. */
  22932. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22933. private static _ExtractFrom;
  22934. /**
  22935. * Creates the VertexData for a Ribbon
  22936. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22937. * * pathArray array of paths, each of which an array of successive Vector3
  22938. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22939. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22940. * * 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
  22941. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22942. * * 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)
  22943. * * 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)
  22944. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22945. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22946. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22947. * @returns the VertexData of the ribbon
  22948. */
  22949. static CreateRibbon(options: {
  22950. pathArray: Vector3[][];
  22951. closeArray?: boolean;
  22952. closePath?: boolean;
  22953. offset?: number;
  22954. sideOrientation?: number;
  22955. frontUVs?: Vector4;
  22956. backUVs?: Vector4;
  22957. invertUV?: boolean;
  22958. uvs?: Vector2[];
  22959. colors?: Color4[];
  22960. }): VertexData;
  22961. /**
  22962. * Creates the VertexData for a box
  22963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22964. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22965. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22966. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22967. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22968. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22969. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22970. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22971. * * 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)
  22972. * * 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)
  22973. * @returns the VertexData of the box
  22974. */
  22975. static CreateBox(options: {
  22976. size?: number;
  22977. width?: number;
  22978. height?: number;
  22979. depth?: number;
  22980. faceUV?: Vector4[];
  22981. faceColors?: Color4[];
  22982. sideOrientation?: number;
  22983. frontUVs?: Vector4;
  22984. backUVs?: Vector4;
  22985. }): VertexData;
  22986. /**
  22987. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22989. * * segments sets the number of horizontal strips optional, default 32
  22990. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22991. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22992. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22993. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22994. * * 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
  22995. * * 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
  22996. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22997. * * 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)
  22998. * * 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)
  22999. * @returns the VertexData of the ellipsoid
  23000. */
  23001. static CreateSphere(options: {
  23002. segments?: number;
  23003. diameter?: number;
  23004. diameterX?: number;
  23005. diameterY?: number;
  23006. diameterZ?: number;
  23007. arc?: number;
  23008. slice?: number;
  23009. sideOrientation?: number;
  23010. frontUVs?: Vector4;
  23011. backUVs?: Vector4;
  23012. }): VertexData;
  23013. /**
  23014. * Creates the VertexData for a cylinder, cone or prism
  23015. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23016. * * height sets the height (y direction) of the cylinder, optional, default 2
  23017. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23018. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23019. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23020. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23021. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23022. * * 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
  23023. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23024. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23025. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23026. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23027. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23028. * * 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)
  23029. * * 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)
  23030. * @returns the VertexData of the cylinder, cone or prism
  23031. */
  23032. static CreateCylinder(options: {
  23033. height?: number;
  23034. diameterTop?: number;
  23035. diameterBottom?: number;
  23036. diameter?: number;
  23037. tessellation?: number;
  23038. subdivisions?: number;
  23039. arc?: number;
  23040. faceColors?: Color4[];
  23041. faceUV?: Vector4[];
  23042. hasRings?: boolean;
  23043. enclose?: boolean;
  23044. sideOrientation?: number;
  23045. frontUVs?: Vector4;
  23046. backUVs?: Vector4;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a torus
  23050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23051. * * diameter the diameter of the torus, optional default 1
  23052. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23053. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23054. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23055. * * 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)
  23056. * * 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)
  23057. * @returns the VertexData of the torus
  23058. */
  23059. static CreateTorus(options: {
  23060. diameter?: number;
  23061. thickness?: number;
  23062. tessellation?: number;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData of the LineSystem
  23069. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23070. * - lines an array of lines, each line being an array of successive Vector3
  23071. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23072. * @returns the VertexData of the LineSystem
  23073. */
  23074. static CreateLineSystem(options: {
  23075. lines: Vector3[][];
  23076. colors?: Nullable<Color4[][]>;
  23077. }): VertexData;
  23078. /**
  23079. * Create the VertexData for a DashedLines
  23080. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23081. * - points an array successive Vector3
  23082. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23083. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23084. * - dashNb the intended total number of dashes, optional, default 200
  23085. * @returns the VertexData for the DashedLines
  23086. */
  23087. static CreateDashedLines(options: {
  23088. points: Vector3[];
  23089. dashSize?: number;
  23090. gapSize?: number;
  23091. dashNb?: number;
  23092. }): VertexData;
  23093. /**
  23094. * Creates the VertexData for a Ground
  23095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23096. * - width the width (x direction) of the ground, optional, default 1
  23097. * - height the height (z direction) of the ground, optional, default 1
  23098. * - subdivisions the number of subdivisions per side, optional, default 1
  23099. * @returns the VertexData of the Ground
  23100. */
  23101. static CreateGround(options: {
  23102. width?: number;
  23103. height?: number;
  23104. subdivisions?: number;
  23105. subdivisionsX?: number;
  23106. subdivisionsY?: number;
  23107. }): VertexData;
  23108. /**
  23109. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23110. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23111. * * xmin the ground minimum X coordinate, optional, default -1
  23112. * * zmin the ground minimum Z coordinate, optional, default -1
  23113. * * xmax the ground maximum X coordinate, optional, default 1
  23114. * * zmax the ground maximum Z coordinate, optional, default 1
  23115. * * 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}
  23116. * * 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}
  23117. * @returns the VertexData of the TiledGround
  23118. */
  23119. static CreateTiledGround(options: {
  23120. xmin: number;
  23121. zmin: number;
  23122. xmax: number;
  23123. zmax: number;
  23124. subdivisions?: {
  23125. w: number;
  23126. h: number;
  23127. };
  23128. precision?: {
  23129. w: number;
  23130. h: number;
  23131. };
  23132. }): VertexData;
  23133. /**
  23134. * Creates the VertexData of the Ground designed from a heightmap
  23135. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23136. * * width the width (x direction) of the ground
  23137. * * height the height (z direction) of the ground
  23138. * * subdivisions the number of subdivisions per side
  23139. * * minHeight the minimum altitude on the ground, optional, default 0
  23140. * * maxHeight the maximum altitude on the ground, optional default 1
  23141. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23142. * * buffer the array holding the image color data
  23143. * * bufferWidth the width of image
  23144. * * bufferHeight the height of image
  23145. * @returns the VertexData of the Ground designed from a heightmap
  23146. */
  23147. static CreateGroundFromHeightMap(options: {
  23148. width: number;
  23149. height: number;
  23150. subdivisions: number;
  23151. minHeight: number;
  23152. maxHeight: number;
  23153. colorFilter: Color3;
  23154. buffer: Uint8Array;
  23155. bufferWidth: number;
  23156. bufferHeight: number;
  23157. }): VertexData;
  23158. /**
  23159. * Creates the VertexData for a Plane
  23160. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23161. * * size sets the width and height of the plane to the value of size, optional default 1
  23162. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23163. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23164. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23165. * * 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)
  23166. * * 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)
  23167. * @returns the VertexData of the box
  23168. */
  23169. static CreatePlane(options: {
  23170. size?: number;
  23171. width?: number;
  23172. height?: number;
  23173. sideOrientation?: number;
  23174. frontUVs?: Vector4;
  23175. backUVs?: Vector4;
  23176. }): VertexData;
  23177. /**
  23178. * Creates the VertexData of the Disc or regular Polygon
  23179. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23180. * * radius the radius of the disc, optional default 0.5
  23181. * * tessellation the number of polygon sides, optional, default 64
  23182. * * 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
  23183. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23184. * * 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)
  23185. * * 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)
  23186. * @returns the VertexData of the box
  23187. */
  23188. static CreateDisc(options: {
  23189. radius?: number;
  23190. tessellation?: number;
  23191. arc?: number;
  23192. sideOrientation?: number;
  23193. frontUVs?: Vector4;
  23194. backUVs?: Vector4;
  23195. }): VertexData;
  23196. /**
  23197. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23198. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23199. * @param polygon a mesh built from polygonTriangulation.build()
  23200. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23201. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23202. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23203. * @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)
  23204. * @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)
  23205. * @returns the VertexData of the Polygon
  23206. */
  23207. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23208. /**
  23209. * Creates the VertexData of the IcoSphere
  23210. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23211. * * radius the radius of the IcoSphere, optional default 1
  23212. * * radiusX allows stretching in the x direction, optional, default radius
  23213. * * radiusY allows stretching in the y direction, optional, default radius
  23214. * * radiusZ allows stretching in the z direction, optional, default radius
  23215. * * flat when true creates a flat shaded mesh, optional, default true
  23216. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23217. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23218. * * 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)
  23219. * * 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)
  23220. * @returns the VertexData of the IcoSphere
  23221. */
  23222. static CreateIcoSphere(options: {
  23223. radius?: number;
  23224. radiusX?: number;
  23225. radiusY?: number;
  23226. radiusZ?: number;
  23227. flat?: boolean;
  23228. subdivisions?: number;
  23229. sideOrientation?: number;
  23230. frontUVs?: Vector4;
  23231. backUVs?: Vector4;
  23232. }): VertexData;
  23233. /**
  23234. * Creates the VertexData for a Polyhedron
  23235. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23236. * * type provided types are:
  23237. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23238. * * 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)
  23239. * * size the size of the IcoSphere, optional default 1
  23240. * * sizeX allows stretching in the x direction, optional, default size
  23241. * * sizeY allows stretching in the y direction, optional, default size
  23242. * * sizeZ allows stretching in the z direction, optional, default size
  23243. * * 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
  23244. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23245. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23246. * * flat when true creates a flat shaded mesh, optional, default true
  23247. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23248. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23249. * * 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)
  23250. * * 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)
  23251. * @returns the VertexData of the Polyhedron
  23252. */
  23253. static CreatePolyhedron(options: {
  23254. type?: number;
  23255. size?: number;
  23256. sizeX?: number;
  23257. sizeY?: number;
  23258. sizeZ?: number;
  23259. custom?: any;
  23260. faceUV?: Vector4[];
  23261. faceColors?: Color4[];
  23262. flat?: boolean;
  23263. sideOrientation?: number;
  23264. frontUVs?: Vector4;
  23265. backUVs?: Vector4;
  23266. }): VertexData;
  23267. /**
  23268. * Creates the VertexData for a TorusKnot
  23269. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23270. * * radius the radius of the torus knot, optional, default 2
  23271. * * tube the thickness of the tube, optional, default 0.5
  23272. * * radialSegments the number of sides on each tube segments, optional, default 32
  23273. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23274. * * p the number of windings around the z axis, optional, default 2
  23275. * * q the number of windings around the x axis, optional, default 3
  23276. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23277. * * 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)
  23278. * * 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)
  23279. * @returns the VertexData of the Torus Knot
  23280. */
  23281. static CreateTorusKnot(options: {
  23282. radius?: number;
  23283. tube?: number;
  23284. radialSegments?: number;
  23285. tubularSegments?: number;
  23286. p?: number;
  23287. q?: number;
  23288. sideOrientation?: number;
  23289. frontUVs?: Vector4;
  23290. backUVs?: Vector4;
  23291. }): VertexData;
  23292. /**
  23293. * Compute normals for given positions and indices
  23294. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23295. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23296. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23297. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23298. * * facetNormals : optional array of facet normals (vector3)
  23299. * * facetPositions : optional array of facet positions (vector3)
  23300. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23301. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23302. * * bInfo : optional bounding info, required for facetPartitioning computation
  23303. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23304. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23305. * * useRightHandedSystem: optional boolean to for right handed system computation
  23306. * * depthSort : optional boolean to enable the facet depth sort computation
  23307. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23308. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23309. */
  23310. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23311. facetNormals?: any;
  23312. facetPositions?: any;
  23313. facetPartitioning?: any;
  23314. ratio?: number;
  23315. bInfo?: any;
  23316. bbSize?: Vector3;
  23317. subDiv?: any;
  23318. useRightHandedSystem?: boolean;
  23319. depthSort?: boolean;
  23320. distanceTo?: Vector3;
  23321. depthSortedFacets?: any;
  23322. }): void;
  23323. private static _ComputeSides;
  23324. /**
  23325. * Applies VertexData created from the imported parameters to the geometry
  23326. * @param parsedVertexData the parsed data from an imported file
  23327. * @param geometry the geometry to apply the VertexData to
  23328. */
  23329. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23330. }
  23331. }
  23332. declare module BABYLON {
  23333. /**
  23334. * Class containing static functions to help procedurally build meshes
  23335. */
  23336. class MeshBuilder {
  23337. private static updateSideOrientation;
  23338. /**
  23339. * Creates a box mesh
  23340. * * The parameter `size` sets the size (float) of each box side (default 1)
  23341. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  23342. * * 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)
  23343. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23345. * * 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
  23346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23347. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  23348. * @param name defines the name of the mesh
  23349. * @param options defines the options used to create the mesh
  23350. * @param scene defines the hosting scene
  23351. * @returns the box mesh
  23352. */
  23353. static CreateBox(name: string, options: {
  23354. size?: number;
  23355. width?: number;
  23356. height?: number;
  23357. depth?: number;
  23358. faceUV?: Vector4[];
  23359. faceColors?: Color4[];
  23360. sideOrientation?: number;
  23361. frontUVs?: Vector4;
  23362. backUVs?: Vector4;
  23363. updatable?: boolean;
  23364. }, scene?: Nullable<Scene>): Mesh;
  23365. /**
  23366. * Creates a sphere mesh
  23367. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23368. * * 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`)
  23369. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23370. * * 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
  23371. * * 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)
  23372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23373. * * 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
  23374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23375. * @param name defines the name of the mesh
  23376. * @param options defines the options used to create the mesh
  23377. * @param scene defines the hosting scene
  23378. * @returns the sphere mesh
  23379. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  23380. */
  23381. static CreateSphere(name: string, options: {
  23382. segments?: number;
  23383. diameter?: number;
  23384. diameterX?: number;
  23385. diameterY?: number;
  23386. diameterZ?: number;
  23387. arc?: number;
  23388. slice?: number;
  23389. sideOrientation?: number;
  23390. frontUVs?: Vector4;
  23391. backUVs?: Vector4;
  23392. updatable?: boolean;
  23393. }, scene: any): Mesh;
  23394. /**
  23395. * Creates a plane polygonal mesh. By default, this is a disc
  23396. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23397. * * 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
  23398. * * 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
  23399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23400. * * 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
  23401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23402. * @param name defines the name of the mesh
  23403. * @param options defines the options used to create the mesh
  23404. * @param scene defines the hosting scene
  23405. * @returns the plane polygonal mesh
  23406. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23407. */
  23408. static CreateDisc(name: string, options: {
  23409. radius?: number;
  23410. tessellation?: number;
  23411. arc?: number;
  23412. updatable?: boolean;
  23413. sideOrientation?: number;
  23414. frontUVs?: Vector4;
  23415. backUVs?: Vector4;
  23416. }, scene?: Nullable<Scene>): Mesh;
  23417. /**
  23418. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23419. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23420. * * 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`)
  23421. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23422. * * 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
  23423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23424. * * 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
  23425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23426. * @param name defines the name of the mesh
  23427. * @param options defines the options used to create the mesh
  23428. * @param scene defines the hosting scene
  23429. * @returns the icosahedron mesh
  23430. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23431. */
  23432. static CreateIcoSphere(name: string, options: {
  23433. radius?: number;
  23434. radiusX?: number;
  23435. radiusY?: number;
  23436. radiusZ?: number;
  23437. flat?: boolean;
  23438. subdivisions?: number;
  23439. sideOrientation?: number;
  23440. frontUVs?: Vector4;
  23441. backUVs?: Vector4;
  23442. updatable?: boolean;
  23443. }, scene: Scene): Mesh;
  23444. /**
  23445. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23446. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23447. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23448. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23449. * * 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
  23450. * * 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
  23451. * * 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
  23452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23453. * * 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
  23454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23455. * * 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
  23456. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23457. * * 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
  23458. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23460. * @param name defines the name of the mesh
  23461. * @param options defines the options used to create the mesh
  23462. * @param scene defines the hosting scene
  23463. * @returns the ribbon mesh
  23464. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  23465. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23466. */
  23467. static CreateRibbon(name: string, options: {
  23468. pathArray: Vector3[][];
  23469. closeArray?: boolean;
  23470. closePath?: boolean;
  23471. offset?: number;
  23472. updatable?: boolean;
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. instance?: Mesh;
  23477. invertUV?: boolean;
  23478. uvs?: Vector2[];
  23479. colors?: Color4[];
  23480. }, scene?: Nullable<Scene>): Mesh;
  23481. /**
  23482. * Creates a cylinder or a cone mesh
  23483. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23484. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23485. * * 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.
  23486. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23487. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23488. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23489. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23490. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23491. * * 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).
  23492. * * 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
  23493. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23494. * * 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
  23495. * * 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.
  23496. * * If `enclose` is false, a ring surface is one element.
  23497. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23498. * * 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
  23499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23500. * * 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
  23501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23502. * @param name defines the name of the mesh
  23503. * @param options defines the options used to create the mesh
  23504. * @param scene defines the hosting scene
  23505. * @returns the cylinder mesh
  23506. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23507. */
  23508. static CreateCylinder(name: string, options: {
  23509. height?: number;
  23510. diameterTop?: number;
  23511. diameterBottom?: number;
  23512. diameter?: number;
  23513. tessellation?: number;
  23514. subdivisions?: number;
  23515. arc?: number;
  23516. faceColors?: Color4[];
  23517. faceUV?: Vector4[];
  23518. updatable?: boolean;
  23519. hasRings?: boolean;
  23520. enclose?: boolean;
  23521. sideOrientation?: number;
  23522. frontUVs?: Vector4;
  23523. backUVs?: Vector4;
  23524. }, scene: any): Mesh;
  23525. /**
  23526. * Creates a torus mesh
  23527. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23528. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23529. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23531. * * 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
  23532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23533. * @param name defines the name of the mesh
  23534. * @param options defines the options used to create the mesh
  23535. * @param scene defines the hosting scene
  23536. * @returns the torus mesh
  23537. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23538. */
  23539. static CreateTorus(name: string, options: {
  23540. diameter?: number;
  23541. thickness?: number;
  23542. tessellation?: number;
  23543. updatable?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }, scene: any): Mesh;
  23548. /**
  23549. * Creates a torus knot mesh
  23550. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23551. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23552. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23553. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23555. * * 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
  23556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23557. * @param name defines the name of the mesh
  23558. * @param options defines the options used to create the mesh
  23559. * @param scene defines the hosting scene
  23560. * @returns the torus knot mesh
  23561. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23562. */
  23563. static CreateTorusKnot(name: string, options: {
  23564. radius?: number;
  23565. tube?: number;
  23566. radialSegments?: number;
  23567. tubularSegments?: number;
  23568. p?: number;
  23569. q?: number;
  23570. updatable?: boolean;
  23571. sideOrientation?: number;
  23572. frontUVs?: Vector4;
  23573. backUVs?: Vector4;
  23574. }, scene: any): Mesh;
  23575. /**
  23576. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23577. * * 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
  23578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23579. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23580. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23581. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23583. * * 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
  23584. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23586. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23587. * @param name defines the name of the new line system
  23588. * @param options defines the options used to create the line system
  23589. * @param scene defines the hosting scene
  23590. * @returns a new line system mesh
  23591. */
  23592. static CreateLineSystem(name: string, options: {
  23593. lines: Vector3[][];
  23594. updatable?: boolean;
  23595. instance?: Nullable<LinesMesh>;
  23596. colors?: Nullable<Color4[][]>;
  23597. useVertexAlpha?: boolean;
  23598. }, scene: Nullable<Scene>): LinesMesh;
  23599. /**
  23600. * Creates a line mesh
  23601. * 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
  23602. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23603. * * The parameter `points` is an array successive Vector3
  23604. * * 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
  23605. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23606. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23607. * * When updating an instance, remember that only point positions can change, not the number of points
  23608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23609. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23610. * @param name defines the name of the new line system
  23611. * @param options defines the options used to create the line system
  23612. * @param scene defines the hosting scene
  23613. * @returns a new line mesh
  23614. */
  23615. static CreateLines(name: string, options: {
  23616. points: Vector3[];
  23617. updatable?: boolean;
  23618. instance?: Nullable<LinesMesh>;
  23619. colors?: Color4[];
  23620. useVertexAlpha?: boolean;
  23621. }, scene?: Nullable<Scene>): LinesMesh;
  23622. /**
  23623. * Creates a dashed line mesh
  23624. * * 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
  23625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23626. * * The parameter `points` is an array successive Vector3
  23627. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23628. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23629. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23630. * * 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
  23631. * * When updating an instance, remember that only point positions can change, not the number of points
  23632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23633. * @param name defines the name of the mesh
  23634. * @param options defines the options used to create the mesh
  23635. * @param scene defines the hosting scene
  23636. * @returns the dashed line mesh
  23637. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23638. */
  23639. static CreateDashedLines(name: string, options: {
  23640. points: Vector3[];
  23641. dashSize?: number;
  23642. gapSize?: number;
  23643. dashNb?: number;
  23644. updatable?: boolean;
  23645. instance?: LinesMesh;
  23646. }, scene?: Nullable<Scene>): LinesMesh;
  23647. /**
  23648. * 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.
  23649. * * 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.
  23650. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23651. * * 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.
  23652. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23653. * * 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
  23654. * * 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
  23655. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23657. * * 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
  23658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23660. * @param name defines the name of the mesh
  23661. * @param options defines the options used to create the mesh
  23662. * @param scene defines the hosting scene
  23663. * @returns the extruded shape mesh
  23664. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23666. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23667. */
  23668. static ExtrudeShape(name: string, options: {
  23669. shape: Vector3[];
  23670. path: Vector3[];
  23671. scale?: number;
  23672. rotation?: number;
  23673. cap?: number;
  23674. updatable?: boolean;
  23675. sideOrientation?: number;
  23676. frontUVs?: Vector4;
  23677. backUVs?: Vector4;
  23678. instance?: Mesh;
  23679. invertUV?: boolean;
  23680. }, scene?: Nullable<Scene>): Mesh;
  23681. /**
  23682. * Creates an custom extruded shape mesh.
  23683. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23684. * * 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.
  23685. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23686. * * 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
  23687. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23688. * * 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
  23689. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23690. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23691. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23692. * * 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
  23693. * * 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
  23694. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23696. * * 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
  23697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23699. * @param name defines the name of the mesh
  23700. * @param options defines the options used to create the mesh
  23701. * @param scene defines the hosting scene
  23702. * @returns the custom extruded shape mesh
  23703. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23704. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23705. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23706. */
  23707. static ExtrudeShapeCustom(name: string, options: {
  23708. shape: Vector3[];
  23709. path: Vector3[];
  23710. scaleFunction?: any;
  23711. rotationFunction?: any;
  23712. ribbonCloseArray?: boolean;
  23713. ribbonClosePath?: boolean;
  23714. cap?: number;
  23715. updatable?: boolean;
  23716. sideOrientation?: number;
  23717. frontUVs?: Vector4;
  23718. backUVs?: Vector4;
  23719. instance?: Mesh;
  23720. invertUV?: boolean;
  23721. }, scene: Scene): Mesh;
  23722. /**
  23723. * Creates lathe mesh.
  23724. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23725. * * 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
  23726. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23727. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23728. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23729. * * 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
  23730. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23731. * * 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
  23732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23733. * * 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
  23734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23736. * @param name defines the name of the mesh
  23737. * @param options defines the options used to create the mesh
  23738. * @param scene defines the hosting scene
  23739. * @returns the lathe mesh
  23740. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23741. */
  23742. static CreateLathe(name: string, options: {
  23743. shape: Vector3[];
  23744. radius?: number;
  23745. tessellation?: number;
  23746. clip?: number;
  23747. arc?: number;
  23748. closed?: boolean;
  23749. updatable?: boolean;
  23750. sideOrientation?: number;
  23751. frontUVs?: Vector4;
  23752. backUVs?: Vector4;
  23753. cap?: number;
  23754. invertUV?: boolean;
  23755. }, scene: Scene): Mesh;
  23756. /**
  23757. * Creates a plane mesh
  23758. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23759. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23760. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23762. * * 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
  23763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23764. * @param name defines the name of the mesh
  23765. * @param options defines the options used to create the mesh
  23766. * @param scene defines the hosting scene
  23767. * @returns the plane mesh
  23768. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23769. */
  23770. static CreatePlane(name: string, options: {
  23771. size?: number;
  23772. width?: number;
  23773. height?: number;
  23774. sideOrientation?: number;
  23775. frontUVs?: Vector4;
  23776. backUVs?: Vector4;
  23777. updatable?: boolean;
  23778. sourcePlane?: Plane;
  23779. }, scene: Scene): Mesh;
  23780. /**
  23781. * Creates a ground mesh
  23782. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23783. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23785. * @param name defines the name of the mesh
  23786. * @param options defines the options used to create the mesh
  23787. * @param scene defines the hosting scene
  23788. * @returns the ground mesh
  23789. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23790. */
  23791. static CreateGround(name: string, options: {
  23792. width?: number;
  23793. height?: number;
  23794. subdivisions?: number;
  23795. subdivisionsX?: number;
  23796. subdivisionsY?: number;
  23797. updatable?: boolean;
  23798. }, scene: any): Mesh;
  23799. /**
  23800. * Creates a tiled ground mesh
  23801. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23802. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23803. * * 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
  23804. * * 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
  23805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23806. * @param name defines the name of the mesh
  23807. * @param options defines the options used to create the mesh
  23808. * @param scene defines the hosting scene
  23809. * @returns the tiled ground mesh
  23810. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23811. */
  23812. static CreateTiledGround(name: string, options: {
  23813. xmin: number;
  23814. zmin: number;
  23815. xmax: number;
  23816. zmax: number;
  23817. subdivisions?: {
  23818. w: number;
  23819. h: number;
  23820. };
  23821. precision?: {
  23822. w: number;
  23823. h: number;
  23824. };
  23825. updatable?: boolean;
  23826. }, scene: Scene): Mesh;
  23827. /**
  23828. * Creates a ground mesh from a height map
  23829. * * The parameter `url` sets the URL of the height map image resource.
  23830. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23831. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23832. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23833. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23834. * * 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.
  23835. * * 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).
  23836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23837. * @param name defines the name of the mesh
  23838. * @param url defines the url to the height map
  23839. * @param options defines the options used to create the mesh
  23840. * @param scene defines the hosting scene
  23841. * @returns the ground mesh
  23842. * @see http://doc.babylonjs.com/babylon101/height_map
  23843. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23844. */
  23845. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23846. width?: number;
  23847. height?: number;
  23848. subdivisions?: number;
  23849. minHeight?: number;
  23850. maxHeight?: number;
  23851. colorFilter?: Color3;
  23852. updatable?: boolean;
  23853. onReady?: (mesh: GroundMesh) => void;
  23854. }, scene: Scene): GroundMesh;
  23855. /**
  23856. * Creates a polygon mesh
  23857. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23858. * * 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
  23859. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23861. * * 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)
  23862. * * Remember you can only change the shape positions, not their number when updating a polygon
  23863. * @param name defines the name of the mesh
  23864. * @param options defines the options used to create the mesh
  23865. * @param scene defines the hosting scene
  23866. * @returns the polygon mesh
  23867. */
  23868. static CreatePolygon(name: string, options: {
  23869. shape: Vector3[];
  23870. holes?: Vector3[][];
  23871. depth?: number;
  23872. faceUV?: Vector4[];
  23873. faceColors?: Color4[];
  23874. updatable?: boolean;
  23875. sideOrientation?: number;
  23876. frontUVs?: Vector4;
  23877. backUVs?: Vector4;
  23878. }, scene: Scene): Mesh;
  23879. /**
  23880. * Creates an extruded polygon mesh, with depth in the Y direction.
  23881. * * 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)
  23882. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23883. * @param name defines the name of the mesh
  23884. * @param options defines the options used to create the mesh
  23885. * @param scene defines the hosting scene
  23886. * @returns the polygon mesh
  23887. */
  23888. static ExtrudePolygon(name: string, options: {
  23889. shape: Vector3[];
  23890. holes?: Vector3[][];
  23891. depth?: number;
  23892. faceUV?: Vector4[];
  23893. faceColors?: Color4[];
  23894. updatable?: boolean;
  23895. sideOrientation?: number;
  23896. frontUVs?: Vector4;
  23897. backUVs?: Vector4;
  23898. }, scene: Scene): Mesh;
  23899. /**
  23900. * Creates a tube mesh.
  23901. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23902. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23903. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23904. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23905. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23906. * * 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)
  23907. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23908. * * 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
  23909. * * 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
  23910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23911. * * 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
  23912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23914. * @param name defines the name of the mesh
  23915. * @param options defines the options used to create the mesh
  23916. * @param scene defines the hosting scene
  23917. * @returns the tube mesh
  23918. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23919. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23920. */
  23921. static CreateTube(name: string, options: {
  23922. path: Vector3[];
  23923. radius?: number;
  23924. tessellation?: number;
  23925. radiusFunction?: {
  23926. (i: number, distance: number): number;
  23927. };
  23928. cap?: number;
  23929. arc?: number;
  23930. updatable?: boolean;
  23931. sideOrientation?: number;
  23932. frontUVs?: Vector4;
  23933. backUVs?: Vector4;
  23934. instance?: Mesh;
  23935. invertUV?: boolean;
  23936. }, scene: Scene): Mesh;
  23937. /**
  23938. * Creates a polyhedron mesh
  23939. * * 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
  23940. * * The parameter `size` (positive float, default 1) sets the polygon size
  23941. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23942. * * 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`
  23943. * * 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
  23944. * * 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)`)
  23945. * * 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
  23946. * * 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
  23947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23948. * * 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
  23949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23950. * @param name defines the name of the mesh
  23951. * @param options defines the options used to create the mesh
  23952. * @param scene defines the hosting scene
  23953. * @returns the polyhedron mesh
  23954. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23955. */
  23956. static CreatePolyhedron(name: string, options: {
  23957. type?: number;
  23958. size?: number;
  23959. sizeX?: number;
  23960. sizeY?: number;
  23961. sizeZ?: number;
  23962. custom?: any;
  23963. faceUV?: Vector4[];
  23964. faceColors?: Color4[];
  23965. flat?: boolean;
  23966. updatable?: boolean;
  23967. sideOrientation?: number;
  23968. frontUVs?: Vector4;
  23969. backUVs?: Vector4;
  23970. }, scene: Scene): Mesh;
  23971. /**
  23972. * Creates a decal mesh.
  23973. * 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
  23974. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23975. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23976. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23977. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23978. * @param name defines the name of the mesh
  23979. * @param sourceMesh defines the mesh where the decal must be applied
  23980. * @param options defines the options used to create the mesh
  23981. * @param scene defines the hosting scene
  23982. * @returns the decal mesh
  23983. * @see http://doc.babylonjs.com/how_to/decals
  23984. */
  23985. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23986. position?: Vector3;
  23987. normal?: Vector3;
  23988. size?: Vector3;
  23989. angle?: number;
  23990. }): Mesh;
  23991. private static _ExtrudeShapeGeneric;
  23992. }
  23993. }
  23994. declare module BABYLON {
  23995. class MeshLODLevel {
  23996. distance: number;
  23997. mesh: Nullable<Mesh>;
  23998. constructor(distance: number, mesh: Nullable<Mesh>);
  23999. }
  24000. }
  24001. declare module BABYLON {
  24002. /**
  24003. * A simplifier interface for future simplification implementations.
  24004. */
  24005. interface ISimplifier {
  24006. /**
  24007. * Simplification of a given mesh according to the given settings.
  24008. * Since this requires computation, it is assumed that the function runs async.
  24009. * @param settings The settings of the simplification, including quality and distance
  24010. * @param successCallback A callback that will be called after the mesh was simplified.
  24011. * @param errorCallback in case of an error, this callback will be called. optional.
  24012. */
  24013. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  24014. }
  24015. /**
  24016. * Expected simplification settings.
  24017. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  24018. */
  24019. interface ISimplificationSettings {
  24020. quality: number;
  24021. distance: number;
  24022. optimizeMesh?: boolean;
  24023. }
  24024. class SimplificationSettings implements ISimplificationSettings {
  24025. quality: number;
  24026. distance: number;
  24027. optimizeMesh?: boolean | undefined;
  24028. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  24029. }
  24030. interface ISimplificationTask {
  24031. settings: Array<ISimplificationSettings>;
  24032. simplificationType: SimplificationType;
  24033. mesh: Mesh;
  24034. successCallback?: () => void;
  24035. parallelProcessing: boolean;
  24036. }
  24037. class SimplificationQueue {
  24038. private _simplificationArray;
  24039. running: boolean;
  24040. constructor();
  24041. addTask(task: ISimplificationTask): void;
  24042. executeNext(): void;
  24043. runSimplification(task: ISimplificationTask): void;
  24044. private getSimplifier;
  24045. }
  24046. /**
  24047. * The implemented types of simplification
  24048. * At the moment only Quadratic Error Decimation is implemented
  24049. */
  24050. enum SimplificationType {
  24051. /** Quadratic error decimation */
  24052. QUADRATIC = 0
  24053. }
  24054. class DecimationTriangle {
  24055. vertices: Array<DecimationVertex>;
  24056. normal: Vector3;
  24057. error: Array<number>;
  24058. deleted: boolean;
  24059. isDirty: boolean;
  24060. borderFactor: number;
  24061. deletePending: boolean;
  24062. originalOffset: number;
  24063. constructor(vertices: Array<DecimationVertex>);
  24064. }
  24065. class DecimationVertex {
  24066. position: Vector3;
  24067. id: number;
  24068. q: QuadraticMatrix;
  24069. isBorder: boolean;
  24070. triangleStart: number;
  24071. triangleCount: number;
  24072. originalOffsets: Array<number>;
  24073. constructor(position: Vector3, id: number);
  24074. updatePosition(newPosition: Vector3): void;
  24075. }
  24076. class QuadraticMatrix {
  24077. data: Array<number>;
  24078. constructor(data?: Array<number>);
  24079. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  24080. addInPlace(matrix: QuadraticMatrix): void;
  24081. addArrayInPlace(data: Array<number>): void;
  24082. add(matrix: QuadraticMatrix): QuadraticMatrix;
  24083. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  24084. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  24085. }
  24086. class Reference {
  24087. vertexId: number;
  24088. triangleId: number;
  24089. constructor(vertexId: number, triangleId: number);
  24090. }
  24091. /**
  24092. * An implementation of the Quadratic Error simplification algorithm.
  24093. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  24094. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  24095. * @author RaananW
  24096. */
  24097. class QuadraticErrorSimplification implements ISimplifier {
  24098. private _mesh;
  24099. private triangles;
  24100. private vertices;
  24101. private references;
  24102. private _reconstructedMesh;
  24103. syncIterations: number;
  24104. aggressiveness: number;
  24105. decimationIterations: number;
  24106. boundingBoxEpsilon: number;
  24107. constructor(_mesh: Mesh);
  24108. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  24109. private runDecimation;
  24110. private initWithMesh;
  24111. private init;
  24112. private reconstructMesh;
  24113. private initDecimatedMesh;
  24114. private isFlipped;
  24115. private updateTriangles;
  24116. private identifyBorder;
  24117. private updateMesh;
  24118. private vertexError;
  24119. private calculateError;
  24120. }
  24121. }
  24122. declare module BABYLON {
  24123. interface Scene {
  24124. /** @hidden (Backing field) */
  24125. _simplificationQueue: SimplificationQueue;
  24126. /**
  24127. * Gets or sets the simplification queue attached to the scene
  24128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  24129. */
  24130. simplificationQueue: SimplificationQueue;
  24131. }
  24132. interface Mesh {
  24133. /**
  24134. * Simplify the mesh according to the given array of settings.
  24135. * Function will return immediately and will simplify async. It returns the Mesh.
  24136. * @param settings a collection of simplification settings.
  24137. * @param parallelProcessing should all levels calculate parallel or one after the other.
  24138. * @param type the type of simplification to run.
  24139. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  24140. */
  24141. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  24142. }
  24143. /**
  24144. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  24145. * created in a scene
  24146. */
  24147. class SimplicationQueueSceneComponent implements ISceneComponent {
  24148. /**
  24149. * The component name helpfull to identify the component in the list of scene components.
  24150. */
  24151. readonly name: string;
  24152. /**
  24153. * The scene the component belongs to.
  24154. */
  24155. scene: Scene;
  24156. /**
  24157. * Creates a new instance of the component for the given scene
  24158. * @param scene Defines the scene to register the component in
  24159. */
  24160. constructor(scene: Scene);
  24161. /**
  24162. * Registers the component in a given scene
  24163. */
  24164. register(): void;
  24165. /**
  24166. * Rebuilds the elements related to this component in case of
  24167. * context lost for instance.
  24168. */
  24169. rebuild(): void;
  24170. /**
  24171. * Disposes the component and the associated ressources
  24172. */
  24173. dispose(): void;
  24174. private _beforeCameraUpdate;
  24175. }
  24176. }
  24177. declare module BABYLON {
  24178. class Polygon {
  24179. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  24180. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  24181. static Parse(input: string): Vector2[];
  24182. static StartingAt(x: number, y: number): Path2;
  24183. }
  24184. class PolygonMeshBuilder {
  24185. private _points;
  24186. private _outlinepoints;
  24187. private _holes;
  24188. private _name;
  24189. private _scene;
  24190. private _epoints;
  24191. private _eholes;
  24192. private _addToepoint;
  24193. constructor(name: string, contours: Path2, scene: Scene);
  24194. constructor(name: string, contours: Vector2[], scene: Scene);
  24195. addHole(hole: Vector2[]): PolygonMeshBuilder;
  24196. build(updatable?: boolean, depth?: number): Mesh;
  24197. private addSide;
  24198. }
  24199. }
  24200. declare module BABYLON {
  24201. class BaseSubMesh {
  24202. /** @hidden */
  24203. _materialDefines: Nullable<MaterialDefines>;
  24204. /** @hidden */
  24205. _materialEffect: Nullable<Effect>;
  24206. readonly effect: Nullable<Effect>;
  24207. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24208. }
  24209. class SubMesh extends BaseSubMesh implements ICullable {
  24210. materialIndex: number;
  24211. verticesStart: number;
  24212. verticesCount: number;
  24213. indexStart: number;
  24214. indexCount: number;
  24215. linesIndexCount: number;
  24216. private _mesh;
  24217. private _renderingMesh;
  24218. private _boundingInfo;
  24219. private _linesIndexBuffer;
  24220. /** @hidden */
  24221. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24222. /** @hidden */
  24223. _trianglePlanes: Plane[];
  24224. /** @hidden */
  24225. _lastColliderTransformMatrix: Matrix;
  24226. /** @hidden */
  24227. _renderId: number;
  24228. /** @hidden */
  24229. _alphaIndex: number;
  24230. /** @hidden */
  24231. _distanceToCamera: number;
  24232. /** @hidden */
  24233. _id: number;
  24234. private _currentMaterial;
  24235. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24236. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24237. readonly IsGlobal: boolean;
  24238. /**
  24239. * Returns the submesh BoudingInfo object.
  24240. */
  24241. getBoundingInfo(): BoundingInfo;
  24242. /**
  24243. * Sets the submesh BoundingInfo.
  24244. * Return the SubMesh.
  24245. */
  24246. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24247. /**
  24248. * Returns the mesh of the current submesh.
  24249. */
  24250. getMesh(): AbstractMesh;
  24251. /**
  24252. * Returns the rendering mesh of the submesh.
  24253. */
  24254. getRenderingMesh(): Mesh;
  24255. /**
  24256. * Returns the submesh material.
  24257. */
  24258. getMaterial(): Nullable<Material>;
  24259. /**
  24260. * Sets a new updated BoundingInfo object to the submesh.
  24261. * Returns the SubMesh.
  24262. */
  24263. refreshBoundingInfo(): SubMesh;
  24264. /** @hidden */
  24265. _checkCollision(collider: Collider): boolean;
  24266. /**
  24267. * Updates the submesh BoundingInfo.
  24268. * Returns the Submesh.
  24269. */
  24270. updateBoundingInfo(world: Matrix): SubMesh;
  24271. /**
  24272. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24273. * Boolean returned.
  24274. */
  24275. isInFrustum(frustumPlanes: Plane[]): boolean;
  24276. /**
  24277. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  24278. * Boolean returned.
  24279. */
  24280. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24281. /**
  24282. * Renders the submesh.
  24283. * Returns it.
  24284. */
  24285. render(enableAlphaMode: boolean): SubMesh;
  24286. /**
  24287. * Returns a new Index Buffer.
  24288. * Type returned : WebGLBuffer.
  24289. */
  24290. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  24291. /**
  24292. * True is the passed Ray intersects the submesh bounding box.
  24293. * Boolean returned.
  24294. */
  24295. canIntersects(ray: Ray): boolean;
  24296. /**
  24297. * Returns an object IntersectionInfo.
  24298. */
  24299. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  24300. /** @hidden */
  24301. _rebuild(): void;
  24302. /**
  24303. * Creates a new Submesh from the passed Mesh.
  24304. */
  24305. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24306. /**
  24307. * Disposes the Submesh.
  24308. * Returns nothing.
  24309. */
  24310. dispose(): void;
  24311. /**
  24312. * Creates a new Submesh from the passed parameters :
  24313. * - materialIndex (integer) : the index of the main mesh material.
  24314. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  24315. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  24316. * - mesh (Mesh) : the main mesh to create the submesh from.
  24317. * - renderingMesh (optional Mesh) : rendering mesh.
  24318. */
  24319. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24320. }
  24321. }
  24322. declare module BABYLON {
  24323. class TransformNode extends Node {
  24324. static BILLBOARDMODE_NONE: number;
  24325. static BILLBOARDMODE_X: number;
  24326. static BILLBOARDMODE_Y: number;
  24327. static BILLBOARDMODE_Z: number;
  24328. static BILLBOARDMODE_ALL: number;
  24329. private _forward;
  24330. private _forwardInverted;
  24331. private _up;
  24332. private _right;
  24333. private _rightInverted;
  24334. private _rotation;
  24335. private _rotationQuaternion;
  24336. protected _scaling: Vector3;
  24337. protected _isDirty: boolean;
  24338. private _transformToBoneReferal;
  24339. /**
  24340. * Set the billboard mode. Default is 0.
  24341. *
  24342. * | Value | Type | Description |
  24343. * | --- | --- | --- |
  24344. * | 0 | BILLBOARDMODE_NONE | |
  24345. * | 1 | BILLBOARDMODE_X | |
  24346. * | 2 | BILLBOARDMODE_Y | |
  24347. * | 4 | BILLBOARDMODE_Z | |
  24348. * | 7 | BILLBOARDMODE_ALL | |
  24349. *
  24350. */
  24351. billboardMode: number;
  24352. scalingDeterminant: number;
  24353. infiniteDistance: boolean;
  24354. /**
  24355. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  24356. * By default the system will update normals to compensate
  24357. */
  24358. ignoreNonUniformScaling: boolean;
  24359. position: Vector3;
  24360. /** @hidden */
  24361. _poseMatrix: Matrix;
  24362. private _localWorld;
  24363. /** @hidden */
  24364. _worldMatrix: Matrix;
  24365. /** @hidden */
  24366. _worldMatrixDeterminant: number;
  24367. private _absolutePosition;
  24368. private _pivotMatrix;
  24369. private _pivotMatrixInverse;
  24370. private _postMultiplyPivotMatrix;
  24371. protected _isWorldMatrixFrozen: boolean;
  24372. /**
  24373. * An event triggered after the world matrix is updated
  24374. */
  24375. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  24376. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  24377. /**
  24378. * Gets a string identifying the name of the class
  24379. * @returns "TransformNode" string
  24380. */
  24381. getClassName(): string;
  24382. /**
  24383. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  24384. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  24385. * Default : (0.0, 0.0, 0.0)
  24386. */
  24387. rotation: Vector3;
  24388. /**
  24389. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24390. * Default : (1.0, 1.0, 1.0)
  24391. */
  24392. /**
  24393. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  24394. * Default : (1.0, 1.0, 1.0)
  24395. */
  24396. scaling: Vector3;
  24397. /**
  24398. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  24399. * It's null by default.
  24400. * 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)
  24401. */
  24402. rotationQuaternion: Nullable<Quaternion>;
  24403. /**
  24404. * The forward direction of that transform in world space.
  24405. */
  24406. readonly forward: Vector3;
  24407. /**
  24408. * The up direction of that transform in world space.
  24409. */
  24410. readonly up: Vector3;
  24411. /**
  24412. * The right direction of that transform in world space.
  24413. */
  24414. readonly right: Vector3;
  24415. /**
  24416. * Returns the latest update of the World matrix
  24417. * Returns a Matrix.
  24418. */
  24419. getWorldMatrix(): Matrix;
  24420. /** @hidden */
  24421. _getWorldMatrixDeterminant(): number;
  24422. /**
  24423. * Returns directly the latest state of the mesh World matrix.
  24424. * A Matrix is returned.
  24425. */
  24426. readonly worldMatrixFromCache: Matrix;
  24427. /**
  24428. * Copies the parameter passed Matrix into the mesh Pose matrix.
  24429. * Returns the TransformNode.
  24430. */
  24431. updatePoseMatrix(matrix: Matrix): TransformNode;
  24432. /**
  24433. * Returns the mesh Pose matrix.
  24434. * Returned object : Matrix
  24435. */
  24436. getPoseMatrix(): Matrix;
  24437. /** @hidden */
  24438. _isSynchronized(): boolean;
  24439. /** @hidden */
  24440. _initCache(): void;
  24441. markAsDirty(property: string): TransformNode;
  24442. /**
  24443. * Returns the current mesh absolute position.
  24444. * Returns a Vector3.
  24445. */
  24446. readonly absolutePosition: Vector3;
  24447. /**
  24448. * Sets a new matrix to apply before all other transformation
  24449. * @param matrix defines the transform matrix
  24450. * @returns the current TransformNode
  24451. */
  24452. setPreTransformMatrix(matrix: Matrix): TransformNode;
  24453. /**
  24454. * Sets a new pivot matrix to the current node
  24455. * @param matrix defines the new pivot matrix to use
  24456. * @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
  24457. * @returns the current TransformNode
  24458. */
  24459. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  24460. /**
  24461. * Returns the mesh pivot matrix.
  24462. * Default : Identity.
  24463. * A Matrix is returned.
  24464. */
  24465. getPivotMatrix(): Matrix;
  24466. /**
  24467. * Prevents the World matrix to be computed any longer.
  24468. * Returns the TransformNode.
  24469. */
  24470. freezeWorldMatrix(): TransformNode;
  24471. /**
  24472. * Allows back the World matrix computation.
  24473. * Returns the TransformNode.
  24474. */
  24475. unfreezeWorldMatrix(): this;
  24476. /**
  24477. * True if the World matrix has been frozen.
  24478. * Returns a boolean.
  24479. */
  24480. readonly isWorldMatrixFrozen: boolean;
  24481. /**
  24482. * Retuns the mesh absolute position in the World.
  24483. * Returns a Vector3.
  24484. */
  24485. getAbsolutePosition(): Vector3;
  24486. /**
  24487. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  24488. * Returns the TransformNode.
  24489. */
  24490. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24491. /**
  24492. * Sets the mesh position in its local space.
  24493. * Returns the TransformNode.
  24494. */
  24495. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24496. /**
  24497. * Returns the mesh position in the local space from the current World matrix values.
  24498. * Returns a new Vector3.
  24499. */
  24500. getPositionExpressedInLocalSpace(): Vector3;
  24501. /**
  24502. * Translates the mesh along the passed Vector3 in its local space.
  24503. * Returns the TransformNode.
  24504. */
  24505. locallyTranslate(vector3: Vector3): TransformNode;
  24506. private static _lookAtVectorCache;
  24507. /**
  24508. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24509. * @param targetPoint the position (must be in same space as current mesh) to look at
  24510. * @param yawCor optional yaw (y-axis) correction in radians
  24511. * @param pitchCor optional pitch (x-axis) correction in radians
  24512. * @param rollCor optional roll (z-axis) correction in radians
  24513. * @param space the choosen space of the target
  24514. * @returns the TransformNode.
  24515. */
  24516. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24517. /**
  24518. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24519. * This Vector3 is expressed in the World space.
  24520. */
  24521. getDirection(localAxis: Vector3): Vector3;
  24522. /**
  24523. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24524. * localAxis is expressed in the mesh local space.
  24525. * result is computed in the Wordl space from the mesh World matrix.
  24526. * Returns the TransformNode.
  24527. */
  24528. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24529. /**
  24530. * Sets a new pivot point to the current node
  24531. * @param point defines the new pivot point to use
  24532. * @param space defines if the point is in world or local space (local by default)
  24533. * @returns the current TransformNode
  24534. */
  24535. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24536. /**
  24537. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24538. */
  24539. getPivotPoint(): Vector3;
  24540. /**
  24541. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24542. * Returns the TransformNode.
  24543. */
  24544. getPivotPointToRef(result: Vector3): TransformNode;
  24545. /**
  24546. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24547. */
  24548. getAbsolutePivotPoint(): Vector3;
  24549. /**
  24550. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24551. * Returns the TransformNode.
  24552. */
  24553. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24554. /**
  24555. * Defines the passed node as the parent of the current node.
  24556. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24557. * Returns the TransformNode.
  24558. */
  24559. setParent(node: Nullable<Node>): TransformNode;
  24560. private _nonUniformScaling;
  24561. readonly nonUniformScaling: boolean;
  24562. /** @hidden */
  24563. _updateNonUniformScalingState(value: boolean): boolean;
  24564. /**
  24565. * Attach the current TransformNode to another TransformNode associated with a bone
  24566. * @param bone Bone affecting the TransformNode
  24567. * @param affectedTransformNode TransformNode associated with the bone
  24568. */
  24569. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24570. detachFromBone(): TransformNode;
  24571. private static _rotationAxisCache;
  24572. /**
  24573. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24574. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24575. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24576. * The passed axis is also normalized.
  24577. * Returns the TransformNode.
  24578. */
  24579. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24580. /**
  24581. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24582. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24583. * The passed axis is also normalized.
  24584. * Returns the TransformNode.
  24585. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24586. */
  24587. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24588. /**
  24589. * Translates the mesh along the axis vector for the passed distance in the given space.
  24590. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24591. * Returns the TransformNode.
  24592. */
  24593. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24594. /**
  24595. * Adds a rotation step to the mesh current rotation.
  24596. * x, y, z are Euler angles expressed in radians.
  24597. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24598. * This means this rotation is made in the mesh local space only.
  24599. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24600. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24601. * ```javascript
  24602. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24603. * ```
  24604. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24605. * 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.
  24606. * Returns the TransformNode.
  24607. */
  24608. addRotation(x: number, y: number, z: number): TransformNode;
  24609. /**
  24610. * Computes the mesh World matrix and returns it.
  24611. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24612. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24613. * If the parameter `force`is set to `true`, the actual computation is done.
  24614. * Returns the mesh World Matrix.
  24615. */
  24616. computeWorldMatrix(force?: boolean): Matrix;
  24617. protected _afterComputeWorldMatrix(): void;
  24618. /**
  24619. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24620. * @param func: callback function to add
  24621. *
  24622. * Returns the TransformNode.
  24623. */
  24624. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24625. /**
  24626. * Removes a registered callback function.
  24627. * Returns the TransformNode.
  24628. */
  24629. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24630. /**
  24631. * Clone the current transform node
  24632. * Returns the new transform node
  24633. * @param name Name of the new clone
  24634. * @param newParent New parent for the clone
  24635. * @param doNotCloneChildren Do not clone children hierarchy
  24636. */
  24637. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24638. serialize(currentSerializationObject?: any): any;
  24639. /**
  24640. * Returns a new TransformNode object parsed from the source provided.
  24641. * The parameter `parsedMesh` is the source.
  24642. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24643. */
  24644. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24645. /**
  24646. * Releases resources associated with this transform node.
  24647. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24648. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24649. */
  24650. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24651. }
  24652. }
  24653. declare module BABYLON {
  24654. class VertexBuffer {
  24655. /** @hidden */
  24656. _buffer: Buffer;
  24657. private _kind;
  24658. private _size;
  24659. private _ownsBuffer;
  24660. private _instanced;
  24661. private _instanceDivisor;
  24662. /**
  24663. * The byte type.
  24664. */
  24665. static readonly BYTE: number;
  24666. /**
  24667. * The unsigned byte type.
  24668. */
  24669. static readonly UNSIGNED_BYTE: number;
  24670. /**
  24671. * The short type.
  24672. */
  24673. static readonly SHORT: number;
  24674. /**
  24675. * The unsigned short type.
  24676. */
  24677. static readonly UNSIGNED_SHORT: number;
  24678. /**
  24679. * The integer type.
  24680. */
  24681. static readonly INT: number;
  24682. /**
  24683. * The unsigned integer type.
  24684. */
  24685. static readonly UNSIGNED_INT: number;
  24686. /**
  24687. * The float type.
  24688. */
  24689. static readonly FLOAT: number;
  24690. /**
  24691. * Gets or sets the instance divisor when in instanced mode
  24692. */
  24693. instanceDivisor: number;
  24694. /**
  24695. * Gets the byte stride.
  24696. */
  24697. readonly byteStride: number;
  24698. /**
  24699. * Gets the byte offset.
  24700. */
  24701. readonly byteOffset: number;
  24702. /**
  24703. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24704. */
  24705. readonly normalized: boolean;
  24706. /**
  24707. * Gets the data type of each component in the array.
  24708. */
  24709. readonly type: number;
  24710. /**
  24711. * Constructor
  24712. * @param engine the engine
  24713. * @param data the data to use for this vertex buffer
  24714. * @param kind the vertex buffer kind
  24715. * @param updatable whether the data is updatable
  24716. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24717. * @param stride the stride (optional)
  24718. * @param instanced whether the buffer is instanced (optional)
  24719. * @param offset the offset of the data (optional)
  24720. * @param size the number of components (optional)
  24721. * @param type the type of the component (optional)
  24722. * @param normalized whether the data contains normalized data (optional)
  24723. * @param useBytes set to true if stride and offset are in bytes (optional)
  24724. */
  24725. 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);
  24726. /** @hidden */
  24727. _rebuild(): void;
  24728. /**
  24729. * Returns the kind of the VertexBuffer (string).
  24730. */
  24731. getKind(): string;
  24732. /**
  24733. * Boolean : is the VertexBuffer updatable ?
  24734. */
  24735. isUpdatable(): boolean;
  24736. /**
  24737. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24738. */
  24739. getData(): Nullable<DataArray>;
  24740. /**
  24741. * Returns the WebGLBuffer associated to the VertexBuffer.
  24742. */
  24743. getBuffer(): Nullable<WebGLBuffer>;
  24744. /**
  24745. * Returns the stride as a multiple of the type byte length.
  24746. * DEPRECATED. Use byteStride instead.
  24747. */
  24748. getStrideSize(): number;
  24749. /**
  24750. * Returns the offset as a multiple of the type byte length.
  24751. * DEPRECATED. Use byteOffset instead.
  24752. */
  24753. getOffset(): number;
  24754. /**
  24755. * Returns the number of components per vertex attribute (integer).
  24756. */
  24757. getSize(): number;
  24758. /**
  24759. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24760. */
  24761. getIsInstanced(): boolean;
  24762. /**
  24763. * Returns the instancing divisor, zero for non-instanced (integer).
  24764. */
  24765. getInstanceDivisor(): number;
  24766. /**
  24767. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24768. * Returns the created WebGLBuffer.
  24769. */
  24770. create(data?: DataArray): void;
  24771. /**
  24772. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24773. * This function will create a new buffer if the current one is not updatable
  24774. * Returns the updated WebGLBuffer.
  24775. */
  24776. update(data: DataArray): void;
  24777. /**
  24778. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24779. * Returns the directly updated WebGLBuffer.
  24780. * @param data the new data
  24781. * @param offset the new offset
  24782. * @param useBytes set to true if the offset is in bytes
  24783. */
  24784. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24785. /**
  24786. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24787. */
  24788. dispose(): void;
  24789. /**
  24790. * Enumerates each value of this vertex buffer as numbers.
  24791. * @param count the number of values to enumerate
  24792. * @param callback the callback function called for each value
  24793. */
  24794. forEach(count: number, callback: (value: number, index: number) => void): void;
  24795. private static _PositionKind;
  24796. private static _NormalKind;
  24797. private static _TangentKind;
  24798. private static _UVKind;
  24799. private static _UV2Kind;
  24800. private static _UV3Kind;
  24801. private static _UV4Kind;
  24802. private static _UV5Kind;
  24803. private static _UV6Kind;
  24804. private static _ColorKind;
  24805. private static _MatricesIndicesKind;
  24806. private static _MatricesWeightsKind;
  24807. private static _MatricesIndicesExtraKind;
  24808. private static _MatricesWeightsExtraKind;
  24809. static readonly PositionKind: string;
  24810. static readonly NormalKind: string;
  24811. static readonly TangentKind: string;
  24812. static readonly UVKind: string;
  24813. static readonly UV2Kind: string;
  24814. static readonly UV3Kind: string;
  24815. static readonly UV4Kind: string;
  24816. static readonly UV5Kind: string;
  24817. static readonly UV6Kind: string;
  24818. static readonly ColorKind: string;
  24819. static readonly MatricesIndicesKind: string;
  24820. static readonly MatricesWeightsKind: string;
  24821. static readonly MatricesIndicesExtraKind: string;
  24822. static readonly MatricesWeightsExtraKind: string;
  24823. /**
  24824. * Deduces the stride given a kind.
  24825. * @param kind The kind string to deduce
  24826. * @returns The deduced stride
  24827. */
  24828. static DeduceStride(kind: string): number;
  24829. /**
  24830. * Gets the byte length of the given type.
  24831. * @param type the type
  24832. * @returns the number of bytes
  24833. */
  24834. static GetTypeByteLength(type: number): number;
  24835. /**
  24836. * Enumerates each value of the given parameters as numbers.
  24837. * @param data the data to enumerate
  24838. * @param byteOffset the byte offset of the data
  24839. * @param byteStride the byte stride of the data
  24840. * @param componentCount the number of components per element
  24841. * @param componentType the type of the component
  24842. * @param count the total number of components
  24843. * @param normalized whether the data is normalized
  24844. * @param callback the callback function called for each value
  24845. */
  24846. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24847. private static _GetFloatValue;
  24848. }
  24849. }
  24850. declare module BABYLON {
  24851. /**
  24852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24854. * 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;
  24855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24856. */
  24857. class ColorCurves {
  24858. private _dirty;
  24859. private _tempColor;
  24860. private _globalCurve;
  24861. private _highlightsCurve;
  24862. private _midtonesCurve;
  24863. private _shadowsCurve;
  24864. private _positiveCurve;
  24865. private _negativeCurve;
  24866. private _globalHue;
  24867. private _globalDensity;
  24868. private _globalSaturation;
  24869. private _globalExposure;
  24870. /**
  24871. * Gets the global Hue value.
  24872. * 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).
  24873. */
  24874. /**
  24875. * Sets the global Hue value.
  24876. * 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).
  24877. */
  24878. globalHue: number;
  24879. /**
  24880. * Gets the global Density value.
  24881. * 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.
  24882. * Values less than zero provide a filter of opposite hue.
  24883. */
  24884. /**
  24885. * Sets the global Density value.
  24886. * 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.
  24887. * Values less than zero provide a filter of opposite hue.
  24888. */
  24889. globalDensity: number;
  24890. /**
  24891. * Gets the global Saturation value.
  24892. * 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.
  24893. */
  24894. /**
  24895. * Sets the global Saturation value.
  24896. * 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.
  24897. */
  24898. globalSaturation: number;
  24899. /**
  24900. * Gets the global Exposure value.
  24901. * 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.
  24902. */
  24903. /**
  24904. * Sets the global Exposure value.
  24905. * 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.
  24906. */
  24907. globalExposure: number;
  24908. private _highlightsHue;
  24909. private _highlightsDensity;
  24910. private _highlightsSaturation;
  24911. private _highlightsExposure;
  24912. /**
  24913. * Gets the highlights Hue value.
  24914. * 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).
  24915. */
  24916. /**
  24917. * Sets the highlights Hue value.
  24918. * 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).
  24919. */
  24920. highlightsHue: number;
  24921. /**
  24922. * Gets the highlights Density value.
  24923. * 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.
  24924. * Values less than zero provide a filter of opposite hue.
  24925. */
  24926. /**
  24927. * Sets the highlights Density value.
  24928. * 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.
  24929. * Values less than zero provide a filter of opposite hue.
  24930. */
  24931. highlightsDensity: number;
  24932. /**
  24933. * Gets the highlights Saturation value.
  24934. * 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.
  24935. */
  24936. /**
  24937. * Sets the highlights Saturation value.
  24938. * 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.
  24939. */
  24940. highlightsSaturation: number;
  24941. /**
  24942. * Gets the highlights Exposure value.
  24943. * 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.
  24944. */
  24945. /**
  24946. * Sets the highlights Exposure value.
  24947. * 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.
  24948. */
  24949. highlightsExposure: number;
  24950. private _midtonesHue;
  24951. private _midtonesDensity;
  24952. private _midtonesSaturation;
  24953. private _midtonesExposure;
  24954. /**
  24955. * Gets the midtones Hue value.
  24956. * 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).
  24957. */
  24958. /**
  24959. * Sets the midtones Hue value.
  24960. * 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).
  24961. */
  24962. midtonesHue: number;
  24963. /**
  24964. * Gets the midtones Density value.
  24965. * 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.
  24966. * Values less than zero provide a filter of opposite hue.
  24967. */
  24968. /**
  24969. * Sets the midtones Density value.
  24970. * 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.
  24971. * Values less than zero provide a filter of opposite hue.
  24972. */
  24973. midtonesDensity: number;
  24974. /**
  24975. * Gets the midtones Saturation value.
  24976. * 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.
  24977. */
  24978. /**
  24979. * Sets the midtones Saturation value.
  24980. * 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.
  24981. */
  24982. midtonesSaturation: number;
  24983. /**
  24984. * Gets the midtones Exposure value.
  24985. * 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.
  24986. */
  24987. /**
  24988. * Sets the midtones Exposure value.
  24989. * 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.
  24990. */
  24991. midtonesExposure: number;
  24992. private _shadowsHue;
  24993. private _shadowsDensity;
  24994. private _shadowsSaturation;
  24995. private _shadowsExposure;
  24996. /**
  24997. * Gets the shadows Hue value.
  24998. * 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).
  24999. */
  25000. /**
  25001. * Sets the shadows Hue value.
  25002. * 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).
  25003. */
  25004. shadowsHue: number;
  25005. /**
  25006. * Gets the shadows Density value.
  25007. * 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.
  25008. * Values less than zero provide a filter of opposite hue.
  25009. */
  25010. /**
  25011. * Sets the shadows Density value.
  25012. * 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.
  25013. * Values less than zero provide a filter of opposite hue.
  25014. */
  25015. shadowsDensity: number;
  25016. /**
  25017. * Gets the shadows Saturation value.
  25018. * 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.
  25019. */
  25020. /**
  25021. * Sets the shadows Saturation value.
  25022. * 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.
  25023. */
  25024. shadowsSaturation: number;
  25025. /**
  25026. * Gets the shadows Exposure value.
  25027. * 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.
  25028. */
  25029. /**
  25030. * Sets the shadows Exposure value.
  25031. * 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.
  25032. */
  25033. shadowsExposure: number;
  25034. getClassName(): string;
  25035. /**
  25036. * Binds the color curves to the shader.
  25037. * @param colorCurves The color curve to bind
  25038. * @param effect The effect to bind to
  25039. */
  25040. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  25041. /**
  25042. * Prepare the list of uniforms associated with the ColorCurves effects.
  25043. * @param uniformsList The list of uniforms used in the effect
  25044. */
  25045. static PrepareUniforms(uniformsList: string[]): void;
  25046. /**
  25047. * Returns color grading data based on a hue, density, saturation and exposure value.
  25048. * @param filterHue The hue of the color filter.
  25049. * @param filterDensity The density of the color filter.
  25050. * @param saturation The saturation.
  25051. * @param exposure The exposure.
  25052. * @param result The result data container.
  25053. */
  25054. private getColorGradingDataToRef;
  25055. /**
  25056. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  25057. * @param value The input slider value in range [-100,100].
  25058. * @returns Adjusted value.
  25059. */
  25060. private static applyColorGradingSliderNonlinear;
  25061. /**
  25062. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  25063. * @param hue The hue (H) input.
  25064. * @param saturation The saturation (S) input.
  25065. * @param brightness The brightness (B) input.
  25066. * @result An RGBA color represented as Vector4.
  25067. */
  25068. private static fromHSBToRef;
  25069. /**
  25070. * Returns a value clamped between min and max
  25071. * @param value The value to clamp
  25072. * @param min The minimum of value
  25073. * @param max The maximum of value
  25074. * @returns The clamped value.
  25075. */
  25076. private static clamp;
  25077. /**
  25078. * Clones the current color curve instance.
  25079. * @return The cloned curves
  25080. */
  25081. clone(): ColorCurves;
  25082. /**
  25083. * Serializes the current color curve instance to a json representation.
  25084. * @return a JSON representation
  25085. */
  25086. serialize(): any;
  25087. /**
  25088. * Parses the color curve from a json representation.
  25089. * @param source the JSON source to parse
  25090. * @return The parsed curves
  25091. */
  25092. static Parse(source: any): ColorCurves;
  25093. }
  25094. }
  25095. declare module BABYLON {
  25096. /**
  25097. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  25098. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  25099. */
  25100. class EffectFallbacks {
  25101. private _defines;
  25102. private _currentRank;
  25103. private _maxRank;
  25104. private _mesh;
  25105. /**
  25106. * Removes the fallback from the bound mesh.
  25107. */
  25108. unBindMesh(): void;
  25109. /**
  25110. * Adds a fallback on the specified property.
  25111. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  25112. * @param define The name of the define in the shader
  25113. */
  25114. addFallback(rank: number, define: string): void;
  25115. /**
  25116. * Sets the mesh to use CPU skinning when needing to fallback.
  25117. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  25118. * @param mesh The mesh to use the fallbacks.
  25119. */
  25120. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  25121. /**
  25122. * Checks to see if more fallbacks are still availible.
  25123. */
  25124. readonly isMoreFallbacks: boolean;
  25125. /**
  25126. * Removes the defines that shoould be removed when falling back.
  25127. * @param currentDefines defines the current define statements for the shader.
  25128. * @param effect defines the current effect we try to compile
  25129. * @returns The resulting defines with defines of the current rank removed.
  25130. */
  25131. reduce(currentDefines: string, effect: Effect): string;
  25132. }
  25133. /**
  25134. * Options to be used when creating an effect.
  25135. */
  25136. class EffectCreationOptions {
  25137. /**
  25138. * Atrributes that will be used in the shader.
  25139. */
  25140. attributes: string[];
  25141. /**
  25142. * Uniform varible names that will be set in the shader.
  25143. */
  25144. uniformsNames: string[];
  25145. /**
  25146. * Uniform buffer varible names that will be set in the shader.
  25147. */
  25148. uniformBuffersNames: string[];
  25149. /**
  25150. * Sampler texture variable names that will be set in the shader.
  25151. */
  25152. samplers: string[];
  25153. /**
  25154. * Define statements that will be set in the shader.
  25155. */
  25156. defines: any;
  25157. /**
  25158. * Possible fallbacks for this effect to improve performance when needed.
  25159. */
  25160. fallbacks: Nullable<EffectFallbacks>;
  25161. /**
  25162. * Callback that will be called when the shader is compiled.
  25163. */
  25164. onCompiled: Nullable<(effect: Effect) => void>;
  25165. /**
  25166. * Callback that will be called if an error occurs during shader compilation.
  25167. */
  25168. onError: Nullable<(effect: Effect, errors: string) => void>;
  25169. /**
  25170. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  25171. */
  25172. indexParameters: any;
  25173. /**
  25174. * Max number of lights that can be used in the shader.
  25175. */
  25176. maxSimultaneousLights: number;
  25177. /**
  25178. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  25179. */
  25180. transformFeedbackVaryings: Nullable<string[]>;
  25181. }
  25182. /**
  25183. * Effect containing vertex and fragment shader that can be executed on an object.
  25184. */
  25185. class Effect {
  25186. /**
  25187. * Name of the effect.
  25188. */
  25189. name: any;
  25190. /**
  25191. * String container all the define statements that should be set on the shader.
  25192. */
  25193. defines: string;
  25194. /**
  25195. * Callback that will be called when the shader is compiled.
  25196. */
  25197. onCompiled: Nullable<(effect: Effect) => void>;
  25198. /**
  25199. * Callback that will be called if an error occurs during shader compilation.
  25200. */
  25201. onError: Nullable<(effect: Effect, errors: string) => void>;
  25202. /**
  25203. * Callback that will be called when effect is bound.
  25204. */
  25205. onBind: Nullable<(effect: Effect) => void>;
  25206. /**
  25207. * Unique ID of the effect.
  25208. */
  25209. uniqueId: number;
  25210. /**
  25211. * Observable that will be called when the shader is compiled.
  25212. */
  25213. onCompileObservable: Observable<Effect>;
  25214. /**
  25215. * Observable that will be called if an error occurs during shader compilation.
  25216. */
  25217. onErrorObservable: Observable<Effect>;
  25218. /** @hidden */
  25219. _onBindObservable: Nullable<Observable<Effect>>;
  25220. /**
  25221. * Observable that will be called when effect is bound.
  25222. */
  25223. readonly onBindObservable: Observable<Effect>;
  25224. /** @hidden */
  25225. _bonesComputationForcedToCPU: boolean;
  25226. private static _uniqueIdSeed;
  25227. private _engine;
  25228. private _uniformBuffersNames;
  25229. private _uniformsNames;
  25230. private _samplers;
  25231. private _isReady;
  25232. private _compilationError;
  25233. private _attributesNames;
  25234. private _attributes;
  25235. private _uniforms;
  25236. /**
  25237. * Key for the effect.
  25238. * @hidden
  25239. */
  25240. _key: string;
  25241. private _indexParameters;
  25242. private _fallbacks;
  25243. private _vertexSourceCode;
  25244. private _fragmentSourceCode;
  25245. private _vertexSourceCodeOverride;
  25246. private _fragmentSourceCodeOverride;
  25247. private _transformFeedbackVaryings;
  25248. /**
  25249. * Compiled shader to webGL program.
  25250. * @hidden
  25251. */
  25252. _program: WebGLProgram;
  25253. private _valueCache;
  25254. private static _baseCache;
  25255. /**
  25256. * Instantiates an effect.
  25257. * An effect can be used to create/manage/execute vertex and fragment shaders.
  25258. * @param baseName Name of the effect.
  25259. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  25260. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  25261. * @param samplers List of sampler variables that will be passed to the shader.
  25262. * @param engine Engine to be used to render the effect
  25263. * @param defines Define statements to be added to the shader.
  25264. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  25265. * @param onCompiled Callback that will be called when the shader is compiled.
  25266. * @param onError Callback that will be called if an error occurs during shader compilation.
  25267. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  25268. */
  25269. 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);
  25270. /**
  25271. * Unique key for this effect
  25272. */
  25273. readonly key: string;
  25274. /**
  25275. * If the effect has been compiled and prepared.
  25276. * @returns if the effect is compiled and prepared.
  25277. */
  25278. isReady(): boolean;
  25279. /**
  25280. * The engine the effect was initialized with.
  25281. * @returns the engine.
  25282. */
  25283. getEngine(): Engine;
  25284. /**
  25285. * The compiled webGL program for the effect
  25286. * @returns the webGL program.
  25287. */
  25288. getProgram(): WebGLProgram;
  25289. /**
  25290. * The set of names of attribute variables for the shader.
  25291. * @returns An array of attribute names.
  25292. */
  25293. getAttributesNames(): string[];
  25294. /**
  25295. * Returns the attribute at the given index.
  25296. * @param index The index of the attribute.
  25297. * @returns The location of the attribute.
  25298. */
  25299. getAttributeLocation(index: number): number;
  25300. /**
  25301. * Returns the attribute based on the name of the variable.
  25302. * @param name of the attribute to look up.
  25303. * @returns the attribute location.
  25304. */
  25305. getAttributeLocationByName(name: string): number;
  25306. /**
  25307. * The number of attributes.
  25308. * @returns the numnber of attributes.
  25309. */
  25310. getAttributesCount(): number;
  25311. /**
  25312. * Gets the index of a uniform variable.
  25313. * @param uniformName of the uniform to look up.
  25314. * @returns the index.
  25315. */
  25316. getUniformIndex(uniformName: string): number;
  25317. /**
  25318. * Returns the attribute based on the name of the variable.
  25319. * @param uniformName of the uniform to look up.
  25320. * @returns the location of the uniform.
  25321. */
  25322. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  25323. /**
  25324. * Returns an array of sampler variable names
  25325. * @returns The array of sampler variable neames.
  25326. */
  25327. getSamplers(): string[];
  25328. /**
  25329. * The error from the last compilation.
  25330. * @returns the error string.
  25331. */
  25332. getCompilationError(): string;
  25333. /**
  25334. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  25335. * @param func The callback to be used.
  25336. */
  25337. executeWhenCompiled(func: (effect: Effect) => void): void;
  25338. /** @hidden */
  25339. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  25340. /** @hidden */
  25341. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  25342. /** @hidden */
  25343. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  25344. private _processShaderConversion;
  25345. private _processIncludes;
  25346. private _processPrecision;
  25347. /**
  25348. * Recompiles the webGL program
  25349. * @param vertexSourceCode The source code for the vertex shader.
  25350. * @param fragmentSourceCode The source code for the fragment shader.
  25351. * @param onCompiled Callback called when completed.
  25352. * @param onError Callback called on error.
  25353. * @hidden
  25354. */
  25355. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  25356. /**
  25357. * Gets the uniform locations of the the specified variable names
  25358. * @param names THe names of the variables to lookup.
  25359. * @returns Array of locations in the same order as variable names.
  25360. */
  25361. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  25362. /**
  25363. * Prepares the effect
  25364. * @hidden
  25365. */
  25366. _prepareEffect(): void;
  25367. /**
  25368. * Checks if the effect is supported. (Must be called after compilation)
  25369. */
  25370. readonly isSupported: boolean;
  25371. /**
  25372. * Binds a texture to the engine to be used as output of the shader.
  25373. * @param channel Name of the output variable.
  25374. * @param texture Texture to bind.
  25375. * @hidden
  25376. */
  25377. _bindTexture(channel: string, texture: InternalTexture): void;
  25378. /**
  25379. * Sets a texture on the engine to be used in the shader.
  25380. * @param channel Name of the sampler variable.
  25381. * @param texture Texture to set.
  25382. */
  25383. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  25384. /**
  25385. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  25386. * @param channel Name of the sampler variable.
  25387. * @param texture Texture to set.
  25388. */
  25389. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  25390. /**
  25391. * Sets an array of textures on the engine to be used in the shader.
  25392. * @param channel Name of the variable.
  25393. * @param textures Textures to set.
  25394. */
  25395. setTextureArray(channel: string, textures: BaseTexture[]): void;
  25396. /**
  25397. * 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)
  25398. * @param channel Name of the sampler variable.
  25399. * @param postProcess Post process to get the input texture from.
  25400. */
  25401. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  25402. /**
  25403. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  25404. * 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)
  25405. * @param channel Name of the sampler variable.
  25406. * @param postProcess Post process to get the output texture from.
  25407. */
  25408. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  25409. /** @hidden */
  25410. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  25411. /** @hidden */
  25412. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  25413. /** @hidden */
  25414. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  25415. /** @hidden */
  25416. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  25417. /**
  25418. * Binds a buffer to a uniform.
  25419. * @param buffer Buffer to bind.
  25420. * @param name Name of the uniform variable to bind to.
  25421. */
  25422. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  25423. /**
  25424. * Binds block to a uniform.
  25425. * @param blockName Name of the block to bind.
  25426. * @param index Index to bind.
  25427. */
  25428. bindUniformBlock(blockName: string, index: number): void;
  25429. /**
  25430. * Sets an interger value on a uniform variable.
  25431. * @param uniformName Name of the variable.
  25432. * @param value Value to be set.
  25433. * @returns this effect.
  25434. */
  25435. setInt(uniformName: string, value: number): Effect;
  25436. /**
  25437. * Sets an int array on a uniform variable.
  25438. * @param uniformName Name of the variable.
  25439. * @param array array to be set.
  25440. * @returns this effect.
  25441. */
  25442. setIntArray(uniformName: string, array: Int32Array): Effect;
  25443. /**
  25444. * 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)
  25445. * @param uniformName Name of the variable.
  25446. * @param array array to be set.
  25447. * @returns this effect.
  25448. */
  25449. setIntArray2(uniformName: string, array: Int32Array): Effect;
  25450. /**
  25451. * 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)
  25452. * @param uniformName Name of the variable.
  25453. * @param array array to be set.
  25454. * @returns this effect.
  25455. */
  25456. setIntArray3(uniformName: string, array: Int32Array): Effect;
  25457. /**
  25458. * 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)
  25459. * @param uniformName Name of the variable.
  25460. * @param array array to be set.
  25461. * @returns this effect.
  25462. */
  25463. setIntArray4(uniformName: string, array: Int32Array): Effect;
  25464. /**
  25465. * Sets an float array on a uniform variable.
  25466. * @param uniformName Name of the variable.
  25467. * @param array array to be set.
  25468. * @returns this effect.
  25469. */
  25470. setFloatArray(uniformName: string, array: Float32Array): Effect;
  25471. /**
  25472. * 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)
  25473. * @param uniformName Name of the variable.
  25474. * @param array array to be set.
  25475. * @returns this effect.
  25476. */
  25477. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  25478. /**
  25479. * 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)
  25480. * @param uniformName Name of the variable.
  25481. * @param array array to be set.
  25482. * @returns this effect.
  25483. */
  25484. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  25485. /**
  25486. * 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)
  25487. * @param uniformName Name of the variable.
  25488. * @param array array to be set.
  25489. * @returns this effect.
  25490. */
  25491. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  25492. /**
  25493. * Sets an array on a uniform variable.
  25494. * @param uniformName Name of the variable.
  25495. * @param array array to be set.
  25496. * @returns this effect.
  25497. */
  25498. setArray(uniformName: string, array: number[]): Effect;
  25499. /**
  25500. * 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)
  25501. * @param uniformName Name of the variable.
  25502. * @param array array to be set.
  25503. * @returns this effect.
  25504. */
  25505. setArray2(uniformName: string, array: number[]): Effect;
  25506. /**
  25507. * 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)
  25508. * @param uniformName Name of the variable.
  25509. * @param array array to be set.
  25510. * @returns this effect.
  25511. */
  25512. setArray3(uniformName: string, array: number[]): Effect;
  25513. /**
  25514. * 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)
  25515. * @param uniformName Name of the variable.
  25516. * @param array array to be set.
  25517. * @returns this effect.
  25518. */
  25519. setArray4(uniformName: string, array: number[]): Effect;
  25520. /**
  25521. * Sets matrices on a uniform variable.
  25522. * @param uniformName Name of the variable.
  25523. * @param matrices matrices to be set.
  25524. * @returns this effect.
  25525. */
  25526. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  25527. /**
  25528. * Sets matrix on a uniform variable.
  25529. * @param uniformName Name of the variable.
  25530. * @param matrix matrix to be set.
  25531. * @returns this effect.
  25532. */
  25533. setMatrix(uniformName: string, matrix: Matrix): Effect;
  25534. /**
  25535. * 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)
  25536. * @param uniformName Name of the variable.
  25537. * @param matrix matrix to be set.
  25538. * @returns this effect.
  25539. */
  25540. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  25541. /**
  25542. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  25543. * @param uniformName Name of the variable.
  25544. * @param matrix matrix to be set.
  25545. * @returns this effect.
  25546. */
  25547. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  25548. /**
  25549. * Sets a float on a uniform variable.
  25550. * @param uniformName Name of the variable.
  25551. * @param value value to be set.
  25552. * @returns this effect.
  25553. */
  25554. setFloat(uniformName: string, value: number): Effect;
  25555. /**
  25556. * Sets a boolean on a uniform variable.
  25557. * @param uniformName Name of the variable.
  25558. * @param bool value to be set.
  25559. * @returns this effect.
  25560. */
  25561. setBool(uniformName: string, bool: boolean): Effect;
  25562. /**
  25563. * Sets a Vector2 on a uniform variable.
  25564. * @param uniformName Name of the variable.
  25565. * @param vector2 vector2 to be set.
  25566. * @returns this effect.
  25567. */
  25568. setVector2(uniformName: string, vector2: Vector2): Effect;
  25569. /**
  25570. * Sets a float2 on a uniform variable.
  25571. * @param uniformName Name of the variable.
  25572. * @param x First float in float2.
  25573. * @param y Second float in float2.
  25574. * @returns this effect.
  25575. */
  25576. setFloat2(uniformName: string, x: number, y: number): Effect;
  25577. /**
  25578. * Sets a Vector3 on a uniform variable.
  25579. * @param uniformName Name of the variable.
  25580. * @param vector3 Value to be set.
  25581. * @returns this effect.
  25582. */
  25583. setVector3(uniformName: string, vector3: Vector3): Effect;
  25584. /**
  25585. * Sets a float3 on a uniform variable.
  25586. * @param uniformName Name of the variable.
  25587. * @param x First float in float3.
  25588. * @param y Second float in float3.
  25589. * @param z Third float in float3.
  25590. * @returns this effect.
  25591. */
  25592. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  25593. /**
  25594. * Sets a Vector4 on a uniform variable.
  25595. * @param uniformName Name of the variable.
  25596. * @param vector4 Value to be set.
  25597. * @returns this effect.
  25598. */
  25599. setVector4(uniformName: string, vector4: Vector4): Effect;
  25600. /**
  25601. * Sets a float4 on a uniform variable.
  25602. * @param uniformName Name of the variable.
  25603. * @param x First float in float4.
  25604. * @param y Second float in float4.
  25605. * @param z Third float in float4.
  25606. * @param w Fourth float in float4.
  25607. * @returns this effect.
  25608. */
  25609. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  25610. /**
  25611. * Sets a Color3 on a uniform variable.
  25612. * @param uniformName Name of the variable.
  25613. * @param color3 Value to be set.
  25614. * @returns this effect.
  25615. */
  25616. setColor3(uniformName: string, color3: Color3): Effect;
  25617. /**
  25618. * Sets a Color4 on a uniform variable.
  25619. * @param uniformName Name of the variable.
  25620. * @param color3 Value to be set.
  25621. * @param alpha Alpha value to be set.
  25622. * @returns this effect.
  25623. */
  25624. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  25625. /**
  25626. * Sets a Color4 on a uniform variable
  25627. * @param uniformName defines the name of the variable
  25628. * @param color4 defines the value to be set
  25629. * @returns this effect.
  25630. */
  25631. setDirectColor4(uniformName: string, color4: Color4): Effect;
  25632. /**
  25633. * This function will add a new shader to the shader store
  25634. * @param name the name of the shader
  25635. * @param pixelShader optional pixel shader content
  25636. * @param vertexShader optional vertex shader content
  25637. */
  25638. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  25639. /**
  25640. * Store of each shader (The can be looked up using effect.key)
  25641. */
  25642. static ShadersStore: {
  25643. [key: string]: string;
  25644. };
  25645. /**
  25646. * Store of each included file for a shader (The can be looked up using effect.key)
  25647. */
  25648. static IncludesShadersStore: {
  25649. [key: string]: string;
  25650. };
  25651. /**
  25652. * Resets the cache of effects.
  25653. */
  25654. static ResetCache(): void;
  25655. }
  25656. }
  25657. declare module BABYLON {
  25658. class FresnelParameters {
  25659. private _isEnabled;
  25660. isEnabled: boolean;
  25661. leftColor: Color3;
  25662. rightColor: Color3;
  25663. bias: number;
  25664. power: number;
  25665. clone(): FresnelParameters;
  25666. serialize(): any;
  25667. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. /**
  25672. * Interface to follow in your material defines to integrate easily the
  25673. * Image proccessing functions.
  25674. * @hidden
  25675. */
  25676. interface IImageProcessingConfigurationDefines {
  25677. IMAGEPROCESSING: boolean;
  25678. VIGNETTE: boolean;
  25679. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25680. VIGNETTEBLENDMODEOPAQUE: boolean;
  25681. TONEMAPPING: boolean;
  25682. TONEMAPPING_ACES: boolean;
  25683. CONTRAST: boolean;
  25684. EXPOSURE: boolean;
  25685. COLORCURVES: boolean;
  25686. COLORGRADING: boolean;
  25687. COLORGRADING3D: boolean;
  25688. SAMPLER3DGREENDEPTH: boolean;
  25689. SAMPLER3DBGRMAP: boolean;
  25690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25691. }
  25692. /**
  25693. * @hidden
  25694. */
  25695. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25696. IMAGEPROCESSING: boolean;
  25697. VIGNETTE: boolean;
  25698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25699. VIGNETTEBLENDMODEOPAQUE: boolean;
  25700. TONEMAPPING: boolean;
  25701. TONEMAPPING_ACES: boolean;
  25702. CONTRAST: boolean;
  25703. COLORCURVES: boolean;
  25704. COLORGRADING: boolean;
  25705. COLORGRADING3D: boolean;
  25706. SAMPLER3DGREENDEPTH: boolean;
  25707. SAMPLER3DBGRMAP: boolean;
  25708. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25709. EXPOSURE: boolean;
  25710. constructor();
  25711. }
  25712. /**
  25713. * This groups together the common properties used for image processing either in direct forward pass
  25714. * or through post processing effect depending on the use of the image processing pipeline in your scene
  25715. * or not.
  25716. */
  25717. class ImageProcessingConfiguration {
  25718. /**
  25719. * Default tone mapping applied in BabylonJS.
  25720. */
  25721. static readonly TONEMAPPING_STANDARD: number;
  25722. /**
  25723. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  25724. * to other engines rendering to increase portability.
  25725. */
  25726. static readonly TONEMAPPING_ACES: number;
  25727. /**
  25728. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  25729. */
  25730. colorCurves: Nullable<ColorCurves>;
  25731. private _colorCurvesEnabled;
  25732. /**
  25733. * Gets wether the color curves effect is enabled.
  25734. */
  25735. /**
  25736. * Sets wether the color curves effect is enabled.
  25737. */
  25738. colorCurvesEnabled: boolean;
  25739. /**
  25740. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  25741. */
  25742. colorGradingTexture: Nullable<BaseTexture>;
  25743. private _colorGradingEnabled;
  25744. /**
  25745. * Gets wether the color grading effect is enabled.
  25746. */
  25747. /**
  25748. * Sets wether the color grading effect is enabled.
  25749. */
  25750. colorGradingEnabled: boolean;
  25751. private _colorGradingWithGreenDepth;
  25752. /**
  25753. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  25754. */
  25755. /**
  25756. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  25757. */
  25758. colorGradingWithGreenDepth: boolean;
  25759. private _colorGradingBGR;
  25760. /**
  25761. * Gets wether the color grading texture contains BGR values.
  25762. */
  25763. /**
  25764. * Sets wether the color grading texture contains BGR values.
  25765. */
  25766. colorGradingBGR: boolean;
  25767. /** @hidden */
  25768. _exposure: number;
  25769. /**
  25770. * Gets the Exposure used in the effect.
  25771. */
  25772. /**
  25773. * Sets the Exposure used in the effect.
  25774. */
  25775. exposure: number;
  25776. private _toneMappingEnabled;
  25777. /**
  25778. * Gets wether the tone mapping effect is enabled.
  25779. */
  25780. /**
  25781. * Sets wether the tone mapping effect is enabled.
  25782. */
  25783. toneMappingEnabled: boolean;
  25784. private _toneMappingType;
  25785. /**
  25786. * Gets the type of tone mapping effect.
  25787. */
  25788. /**
  25789. * Sets the type of tone mapping effect used in BabylonJS.
  25790. */
  25791. toneMappingType: number;
  25792. protected _contrast: number;
  25793. /**
  25794. * Gets the contrast used in the effect.
  25795. */
  25796. /**
  25797. * Sets the contrast used in the effect.
  25798. */
  25799. contrast: number;
  25800. /**
  25801. * Vignette stretch size.
  25802. */
  25803. vignetteStretch: number;
  25804. /**
  25805. * Vignette centre X Offset.
  25806. */
  25807. vignetteCentreX: number;
  25808. /**
  25809. * Vignette centre Y Offset.
  25810. */
  25811. vignetteCentreY: number;
  25812. /**
  25813. * Vignette weight or intensity of the vignette effect.
  25814. */
  25815. vignetteWeight: number;
  25816. /**
  25817. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25818. * if vignetteEnabled is set to true.
  25819. */
  25820. vignetteColor: Color4;
  25821. /**
  25822. * Camera field of view used by the Vignette effect.
  25823. */
  25824. vignetteCameraFov: number;
  25825. private _vignetteBlendMode;
  25826. /**
  25827. * Gets the vignette blend mode allowing different kind of effect.
  25828. */
  25829. /**
  25830. * Sets the vignette blend mode allowing different kind of effect.
  25831. */
  25832. vignetteBlendMode: number;
  25833. private _vignetteEnabled;
  25834. /**
  25835. * Gets wether the vignette effect is enabled.
  25836. */
  25837. /**
  25838. * Sets wether the vignette effect is enabled.
  25839. */
  25840. vignetteEnabled: boolean;
  25841. private _applyByPostProcess;
  25842. /**
  25843. * Gets wether the image processing is applied through a post process or not.
  25844. */
  25845. /**
  25846. * Sets wether the image processing is applied through a post process or not.
  25847. */
  25848. applyByPostProcess: boolean;
  25849. private _isEnabled;
  25850. /**
  25851. * Gets wether the image processing is enabled or not.
  25852. */
  25853. /**
  25854. * Sets wether the image processing is enabled or not.
  25855. */
  25856. isEnabled: boolean;
  25857. /**
  25858. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  25859. */
  25860. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  25861. /**
  25862. * Method called each time the image processing information changes requires to recompile the effect.
  25863. */
  25864. protected _updateParameters(): void;
  25865. getClassName(): string;
  25866. /**
  25867. * Prepare the list of uniforms associated with the Image Processing effects.
  25868. * @param uniformsList The list of uniforms used in the effect
  25869. * @param defines the list of defines currently in use
  25870. */
  25871. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  25872. /**
  25873. * Prepare the list of samplers associated with the Image Processing effects.
  25874. * @param uniformsList The list of uniforms used in the effect
  25875. * @param defines the list of defines currently in use
  25876. */
  25877. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  25878. /**
  25879. * Prepare the list of defines associated to the shader.
  25880. * @param defines the list of defines to complete
  25881. */
  25882. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  25883. /**
  25884. * Returns true if all the image processing information are ready.
  25885. */
  25886. isReady(): boolean;
  25887. /**
  25888. * Binds the image processing to the shader.
  25889. * @param effect The effect to bind to
  25890. */
  25891. bind(effect: Effect, aspectRatio?: number): void;
  25892. /**
  25893. * Clones the current image processing instance.
  25894. * @return The cloned image processing
  25895. */
  25896. clone(): ImageProcessingConfiguration;
  25897. /**
  25898. * Serializes the current image processing instance to a json representation.
  25899. * @return a JSON representation
  25900. */
  25901. serialize(): any;
  25902. /**
  25903. * Parses the image processing from a json representation.
  25904. * @param source the JSON source to parse
  25905. * @return The parsed image processing
  25906. */
  25907. static Parse(source: any): ImageProcessingConfiguration;
  25908. private static _VIGNETTEMODE_MULTIPLY;
  25909. private static _VIGNETTEMODE_OPAQUE;
  25910. /**
  25911. * Used to apply the vignette as a mix with the pixel color.
  25912. */
  25913. static readonly VIGNETTEMODE_MULTIPLY: number;
  25914. /**
  25915. * Used to apply the vignette as a replacement of the pixel color.
  25916. */
  25917. static readonly VIGNETTEMODE_OPAQUE: number;
  25918. }
  25919. }
  25920. declare module BABYLON {
  25921. /**
  25922. * Manages the defines for the Material
  25923. */
  25924. class MaterialDefines {
  25925. private _keys;
  25926. private _isDirty;
  25927. /** @hidden */
  25928. _renderId: number;
  25929. /** @hidden */
  25930. _areLightsDirty: boolean;
  25931. /** @hidden */
  25932. _areAttributesDirty: boolean;
  25933. /** @hidden */
  25934. _areTexturesDirty: boolean;
  25935. /** @hidden */
  25936. _areFresnelDirty: boolean;
  25937. /** @hidden */
  25938. _areMiscDirty: boolean;
  25939. /** @hidden */
  25940. _areImageProcessingDirty: boolean;
  25941. /** @hidden */
  25942. _normals: boolean;
  25943. /** @hidden */
  25944. _uvs: boolean;
  25945. /** @hidden */
  25946. _needNormals: boolean;
  25947. /** @hidden */
  25948. _needUVs: boolean;
  25949. /**
  25950. * Specifies if the material needs to be re-calculated
  25951. */
  25952. readonly isDirty: boolean;
  25953. /**
  25954. * Marks the material to indicate that it has been re-calculated
  25955. */
  25956. markAsProcessed(): void;
  25957. /**
  25958. * Marks the material to indicate that it needs to be re-calculated
  25959. */
  25960. markAsUnprocessed(): void;
  25961. /**
  25962. * Marks the material to indicate all of its defines need to be re-calculated
  25963. */
  25964. markAllAsDirty(): void;
  25965. /**
  25966. * Marks the material to indicate that image processing needs to be re-calculated
  25967. */
  25968. markAsImageProcessingDirty(): void;
  25969. /**
  25970. * Marks the material to indicate the lights need to be re-calculated
  25971. */
  25972. markAsLightDirty(): void;
  25973. /**
  25974. * Marks the attribute state as changed
  25975. */
  25976. markAsAttributesDirty(): void;
  25977. /**
  25978. * Marks the texture state as changed
  25979. */
  25980. markAsTexturesDirty(): void;
  25981. /**
  25982. * Marks the fresnel state as changed
  25983. */
  25984. markAsFresnelDirty(): void;
  25985. /**
  25986. * Marks the misc state as changed
  25987. */
  25988. markAsMiscDirty(): void;
  25989. /**
  25990. * Rebuilds the material defines
  25991. */
  25992. rebuild(): void;
  25993. /**
  25994. * Specifies if two material defines are equal
  25995. * @param other - A material define instance to compare to
  25996. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  25997. */
  25998. isEqual(other: MaterialDefines): boolean;
  25999. /**
  26000. * Clones this instance's defines to another instance
  26001. * @param other - material defines to clone values to
  26002. */
  26003. cloneTo(other: MaterialDefines): void;
  26004. /**
  26005. * Resets the material define values
  26006. */
  26007. reset(): void;
  26008. /**
  26009. * Converts the material define values to a string
  26010. * @returns - String of material define information
  26011. */
  26012. toString(): string;
  26013. }
  26014. /**
  26015. * Base class for the main features of a material in Babylon.js
  26016. */
  26017. class Material implements IAnimatable {
  26018. private static _TriangleFillMode;
  26019. private static _WireFrameFillMode;
  26020. private static _PointFillMode;
  26021. private static _PointListDrawMode;
  26022. private static _LineListDrawMode;
  26023. private static _LineLoopDrawMode;
  26024. private static _LineStripDrawMode;
  26025. private static _TriangleStripDrawMode;
  26026. private static _TriangleFanDrawMode;
  26027. /**
  26028. * Returns the triangle fill mode
  26029. */
  26030. static readonly TriangleFillMode: number;
  26031. /**
  26032. * Returns the wireframe mode
  26033. */
  26034. static readonly WireFrameFillMode: number;
  26035. /**
  26036. * Returns the point fill mode
  26037. */
  26038. static readonly PointFillMode: number;
  26039. /**
  26040. * Returns the point list draw mode
  26041. */
  26042. static readonly PointListDrawMode: number;
  26043. /**
  26044. * Returns the line list draw mode
  26045. */
  26046. static readonly LineListDrawMode: number;
  26047. /**
  26048. * Returns the line loop draw mode
  26049. */
  26050. static readonly LineLoopDrawMode: number;
  26051. /**
  26052. * Returns the line strip draw mode
  26053. */
  26054. static readonly LineStripDrawMode: number;
  26055. /**
  26056. * Returns the triangle strip draw mode
  26057. */
  26058. static readonly TriangleStripDrawMode: number;
  26059. /**
  26060. * Returns the triangle fan draw mode
  26061. */
  26062. static readonly TriangleFanDrawMode: number;
  26063. /**
  26064. * Stores the clock-wise side orientation
  26065. */
  26066. private static _ClockWiseSideOrientation;
  26067. /**
  26068. * Stores the counter clock-wise side orientation
  26069. */
  26070. private static _CounterClockWiseSideOrientation;
  26071. /**
  26072. * Returns the clock-wise side orientation
  26073. */
  26074. static readonly ClockWiseSideOrientation: number;
  26075. /**
  26076. * Returns the counter clock-wise side orientation
  26077. */
  26078. static readonly CounterClockWiseSideOrientation: number;
  26079. /**
  26080. * The dirty texture flag value
  26081. */
  26082. private static _TextureDirtyFlag;
  26083. /**
  26084. * The dirty light flag value
  26085. */
  26086. private static _LightDirtyFlag;
  26087. /**
  26088. * The dirty fresnel flag value
  26089. */
  26090. private static _FresnelDirtyFlag;
  26091. /**
  26092. * The dirty attribute flag value
  26093. */
  26094. private static _AttributesDirtyFlag;
  26095. /**
  26096. * The dirty misc flag value
  26097. */
  26098. private static _MiscDirtyFlag;
  26099. /**
  26100. * Returns the dirty texture flag value
  26101. */
  26102. static readonly TextureDirtyFlag: number;
  26103. /**
  26104. * Returns the dirty light flag value
  26105. */
  26106. static readonly LightDirtyFlag: number;
  26107. /**
  26108. * Returns the dirty fresnel flag value
  26109. */
  26110. static readonly FresnelDirtyFlag: number;
  26111. /**
  26112. * Returns the dirty attributes flag value
  26113. */
  26114. static readonly AttributesDirtyFlag: number;
  26115. /**
  26116. * Returns the dirty misc flag value
  26117. */
  26118. static readonly MiscDirtyFlag: number;
  26119. /**
  26120. * The ID of the material
  26121. */
  26122. id: string;
  26123. /**
  26124. * Gets or sets the unique id of the material
  26125. */
  26126. uniqueId: number;
  26127. /**
  26128. * The name of the material
  26129. */
  26130. name: string;
  26131. /**
  26132. * Specifies if the ready state should be checked on each call
  26133. */
  26134. checkReadyOnEveryCall: boolean;
  26135. /**
  26136. * Specifies if the ready state should be checked once
  26137. */
  26138. checkReadyOnlyOnce: boolean;
  26139. /**
  26140. * The state of the material
  26141. */
  26142. state: string;
  26143. /**
  26144. * The alpha value of the material
  26145. */
  26146. protected _alpha: number;
  26147. /**
  26148. * Sets the alpha value of the material
  26149. */
  26150. /**
  26151. * Gets the alpha value of the material
  26152. */
  26153. alpha: number;
  26154. /**
  26155. * Specifies if back face culling is enabled
  26156. */
  26157. protected _backFaceCulling: boolean;
  26158. /**
  26159. * Sets the back-face culling state
  26160. */
  26161. /**
  26162. * Gets the back-face culling state
  26163. */
  26164. backFaceCulling: boolean;
  26165. /**
  26166. * Stores the value for side orientation
  26167. */
  26168. sideOrientation: number;
  26169. /**
  26170. * Callback triggered when the material is compiled
  26171. */
  26172. onCompiled: (effect: Effect) => void;
  26173. /**
  26174. * Callback triggered when an error occurs
  26175. */
  26176. onError: (effect: Effect, errors: string) => void;
  26177. /**
  26178. * Callback triggered to get the render target textures
  26179. */
  26180. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  26181. /**
  26182. * Specifies if the material should be serialized
  26183. */
  26184. doNotSerialize: boolean;
  26185. /**
  26186. * Specifies if the effect should be stored on sub meshes
  26187. */
  26188. storeEffectOnSubMeshes: boolean;
  26189. /**
  26190. * Stores the animations for the material
  26191. */
  26192. animations: Array<Animation>;
  26193. /**
  26194. * An event triggered when the material is disposed
  26195. */
  26196. onDisposeObservable: Observable<Material>;
  26197. /**
  26198. * An observer which watches for dispose events
  26199. */
  26200. private _onDisposeObserver;
  26201. private _onUnBindObservable;
  26202. /**
  26203. * Called during a dispose event
  26204. */
  26205. onDispose: () => void;
  26206. private _onBindObservable;
  26207. /**
  26208. * An event triggered when the material is bound
  26209. */
  26210. readonly onBindObservable: Observable<AbstractMesh>;
  26211. /**
  26212. * An observer which watches for bind events
  26213. */
  26214. private _onBindObserver;
  26215. /**
  26216. * Called during a bind event
  26217. */
  26218. onBind: (Mesh: AbstractMesh) => void;
  26219. /**
  26220. * An event triggered when the material is unbound
  26221. */
  26222. readonly onUnBindObservable: Observable<Material>;
  26223. /**
  26224. * Stores the value of the alpha mode
  26225. */
  26226. private _alphaMode;
  26227. /**
  26228. * Sets the value of the alpha mode.
  26229. *
  26230. * | Value | Type | Description |
  26231. * | --- | --- | --- |
  26232. * | 0 | ALPHA_DISABLE | |
  26233. * | 1 | ALPHA_ADD | |
  26234. * | 2 | ALPHA_COMBINE | |
  26235. * | 3 | ALPHA_SUBTRACT | |
  26236. * | 4 | ALPHA_MULTIPLY | |
  26237. * | 5 | ALPHA_MAXIMIZED | |
  26238. * | 6 | ALPHA_ONEONE | |
  26239. * | 7 | ALPHA_PREMULTIPLIED | |
  26240. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  26241. * | 9 | ALPHA_INTERPOLATE | |
  26242. * | 10 | ALPHA_SCREENMODE | |
  26243. *
  26244. */
  26245. /**
  26246. * Gets the value of the alpha mode
  26247. */
  26248. alphaMode: number;
  26249. /**
  26250. * Stores the state of the need depth pre-pass value
  26251. */
  26252. private _needDepthPrePass;
  26253. /**
  26254. * Sets the need depth pre-pass value
  26255. */
  26256. /**
  26257. * Gets the depth pre-pass value
  26258. */
  26259. needDepthPrePass: boolean;
  26260. /**
  26261. * Specifies if depth writing should be disabled
  26262. */
  26263. disableDepthWrite: boolean;
  26264. /**
  26265. * Specifies if depth writing should be forced
  26266. */
  26267. forceDepthWrite: boolean;
  26268. /**
  26269. * Specifies if there should be a separate pass for culling
  26270. */
  26271. separateCullingPass: boolean;
  26272. /**
  26273. * Stores the state specifing if fog should be enabled
  26274. */
  26275. private _fogEnabled;
  26276. /**
  26277. * Sets the state for enabling fog
  26278. */
  26279. /**
  26280. * Gets the value of the fog enabled state
  26281. */
  26282. fogEnabled: boolean;
  26283. /**
  26284. * Stores the size of points
  26285. */
  26286. pointSize: number;
  26287. /**
  26288. * Stores the z offset value
  26289. */
  26290. zOffset: number;
  26291. /**
  26292. * Gets a value specifying if wireframe mode is enabled
  26293. */
  26294. /**
  26295. * Sets the state of wireframe mode
  26296. */
  26297. wireframe: boolean;
  26298. /**
  26299. * Gets the value specifying if point clouds are enabled
  26300. */
  26301. /**
  26302. * Sets the state of point cloud mode
  26303. */
  26304. pointsCloud: boolean;
  26305. /**
  26306. * Gets the material fill mode
  26307. */
  26308. /**
  26309. * Sets the material fill mode
  26310. */
  26311. fillMode: number;
  26312. /**
  26313. * @hidden
  26314. * Stores the effects for the material
  26315. */
  26316. _effect: Nullable<Effect>;
  26317. /**
  26318. * @hidden
  26319. * Specifies if the material was previously ready
  26320. */
  26321. _wasPreviouslyReady: boolean;
  26322. /**
  26323. * Specifies if uniform buffers should be used
  26324. */
  26325. private _useUBO;
  26326. /**
  26327. * Stores a reference to the scene
  26328. */
  26329. private _scene;
  26330. /**
  26331. * Stores the fill mode state
  26332. */
  26333. private _fillMode;
  26334. /**
  26335. * Specifies if the depth write state should be cached
  26336. */
  26337. private _cachedDepthWriteState;
  26338. /**
  26339. * Stores the uniform buffer
  26340. */
  26341. protected _uniformBuffer: UniformBuffer;
  26342. /**
  26343. * Creates a material instance
  26344. * @param name defines the name of the material
  26345. * @param scene defines the scene to reference
  26346. * @param doNotAdd specifies if the material should be added to the scene
  26347. */
  26348. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  26349. /**
  26350. * Returns a string representation of the current material
  26351. * @param fullDetails defines a boolean indicating which levels of logging is desired
  26352. * @returns a string with material information
  26353. */
  26354. toString(fullDetails?: boolean): string;
  26355. /**
  26356. * Gets the class name of the material
  26357. * @returns a string with the class name of the material
  26358. */
  26359. getClassName(): string;
  26360. /**
  26361. * Specifies if updates for the material been locked
  26362. */
  26363. readonly isFrozen: boolean;
  26364. /**
  26365. * Locks updates for the material
  26366. */
  26367. freeze(): void;
  26368. /**
  26369. * Unlocks updates for the material
  26370. */
  26371. unfreeze(): void;
  26372. /**
  26373. * Specifies if the material is ready to be used
  26374. * @param mesh defines the mesh to check
  26375. * @param useInstances specifies if instances should be used
  26376. * @returns a boolean indicating if the material is ready to be used
  26377. */
  26378. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26379. /**
  26380. * Specifies that the submesh is ready to be used
  26381. * @param mesh defines the mesh to check
  26382. * @param subMesh defines which submesh to check
  26383. * @param useInstances specifies that instances should be used
  26384. * @returns a boolean indicating that the submesh is ready or not
  26385. */
  26386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  26387. /**
  26388. * Returns the material effect
  26389. * @returns the effect associated with the material
  26390. */
  26391. getEffect(): Nullable<Effect>;
  26392. /**
  26393. * Returns the current scene
  26394. * @returns a Scene
  26395. */
  26396. getScene(): Scene;
  26397. /**
  26398. * Specifies if the material will require alpha blending
  26399. * @returns a boolean specifying if alpha blending is needed
  26400. */
  26401. needAlphaBlending(): boolean;
  26402. /**
  26403. * Specifies if the mesh will require alpha blending
  26404. * @param mesh defines the mesh to check
  26405. * @returns a boolean specifying if alpha blending is needed for the mesh
  26406. */
  26407. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26408. /**
  26409. * Specifies if this material should be rendered in alpha test mode
  26410. * @returns a boolean specifying if an alpha test is needed.
  26411. */
  26412. needAlphaTesting(): boolean;
  26413. /**
  26414. * Gets the texture used for the alpha test
  26415. * @returns the texture to use for alpha testing
  26416. */
  26417. getAlphaTestTexture(): Nullable<BaseTexture>;
  26418. /**
  26419. * Marks the material to indicate that it needs to be re-calculated
  26420. */
  26421. markDirty(): void;
  26422. /** @hidden */
  26423. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26424. /**
  26425. * Binds the material to the mesh
  26426. * @param world defines the world transformation matrix
  26427. * @param mesh defines the mesh to bind the material to
  26428. */
  26429. bind(world: Matrix, mesh?: Mesh): void;
  26430. /**
  26431. * Binds the submesh to the material
  26432. * @param world defines the world transformation matrix
  26433. * @param mesh defines the mesh containing the submesh
  26434. * @param subMesh defines the submesh to bind the material to
  26435. */
  26436. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26437. /**
  26438. * Binds the world matrix to the material
  26439. * @param world defines the world transformation matrix
  26440. */
  26441. bindOnlyWorldMatrix(world: Matrix): void;
  26442. /**
  26443. * Binds the scene's uniform buffer to the effect.
  26444. * @param effect defines the effect to bind to the scene uniform buffer
  26445. * @param sceneUbo defines the uniform buffer storing scene data
  26446. */
  26447. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26448. /**
  26449. * Binds the view matrix to the effect
  26450. * @param effect defines the effect to bind the view matrix to
  26451. */
  26452. bindView(effect: Effect): void;
  26453. /**
  26454. * Binds the view projection matrix to the effect
  26455. * @param effect defines the effect to bind the view projection matrix to
  26456. */
  26457. bindViewProjection(effect: Effect): void;
  26458. /**
  26459. * Specifies if material alpha testing should be turned on for the mesh
  26460. * @param mesh defines the mesh to check
  26461. */
  26462. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26463. /**
  26464. * Processes to execute after binding the material to a mesh
  26465. * @param mesh defines the rendered mesh
  26466. */
  26467. protected _afterBind(mesh?: Mesh): void;
  26468. /**
  26469. * Unbinds the material from the mesh
  26470. */
  26471. unbind(): void;
  26472. /**
  26473. * Gets the active textures from the material
  26474. * @returns an array of textures
  26475. */
  26476. getActiveTextures(): BaseTexture[];
  26477. /**
  26478. * Specifies if the material uses a texture
  26479. * @param texture defines the texture to check against the material
  26480. * @returns a boolean specifying if the material uses the texture
  26481. */
  26482. hasTexture(texture: BaseTexture): boolean;
  26483. /**
  26484. * Makes a duplicate of the material, and gives it a new name
  26485. * @param name defines the new name for the duplicated material
  26486. * @returns the cloned material
  26487. */
  26488. clone(name: string): Nullable<Material>;
  26489. /**
  26490. * Gets the meshes bound to the material
  26491. * @returns an array of meshes bound to the material
  26492. */
  26493. getBindedMeshes(): AbstractMesh[];
  26494. /**
  26495. * Force shader compilation
  26496. * @param mesh defines the mesh associated with this material
  26497. * @param onCompiled defines a function to execute once the material is compiled
  26498. * @param options defines the options to configure the compilation
  26499. */
  26500. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  26501. clipPlane: boolean;
  26502. }>): void;
  26503. /**
  26504. * Force shader compilation
  26505. * @param mesh defines the mesh that will use this material
  26506. * @param options defines additional options for compiling the shaders
  26507. * @returns a promise that resolves when the compilation completes
  26508. */
  26509. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  26510. clipPlane: boolean;
  26511. }>): Promise<void>;
  26512. /**
  26513. * Marks a define in the material to indicate that it needs to be re-computed
  26514. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26515. */
  26516. markAsDirty(flag: number): void;
  26517. /**
  26518. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26519. * @param func defines a function which checks material defines against the submeshes
  26520. */
  26521. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26522. /**
  26523. * Indicates that image processing needs to be re-calculated for all submeshes
  26524. */
  26525. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26526. /**
  26527. * Indicates that textures need to be re-calculated for all submeshes
  26528. */
  26529. protected _markAllSubMeshesAsTexturesDirty(): void;
  26530. /**
  26531. * Indicates that fresnel needs to be re-calculated for all submeshes
  26532. */
  26533. protected _markAllSubMeshesAsFresnelDirty(): void;
  26534. /**
  26535. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26536. */
  26537. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26538. /**
  26539. * Indicates that lights need to be re-calculated for all submeshes
  26540. */
  26541. protected _markAllSubMeshesAsLightsDirty(): void;
  26542. /**
  26543. * Indicates that attributes need to be re-calculated for all submeshes
  26544. */
  26545. protected _markAllSubMeshesAsAttributesDirty(): void;
  26546. /**
  26547. * Indicates that misc needs to be re-calculated for all submeshes
  26548. */
  26549. protected _markAllSubMeshesAsMiscDirty(): void;
  26550. /**
  26551. * Indicates that textures and misc need to be re-calculated for all submeshes
  26552. */
  26553. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26554. /**
  26555. * Disposes the material
  26556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26558. */
  26559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26560. /**
  26561. * Serializes this material
  26562. * @returns the serialized material object
  26563. */
  26564. serialize(): any;
  26565. /**
  26566. * Creates a MultiMaterial from parsed MultiMaterial data.
  26567. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26568. * @param scene defines the hosting scene
  26569. * @returns a new MultiMaterial
  26570. */
  26571. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26572. /**
  26573. * Creates a material from parsed material data
  26574. * @param parsedMaterial defines parsed material data
  26575. * @param scene defines the hosting scene
  26576. * @param rootUrl defines the root URL to use to load textures
  26577. * @returns a new material
  26578. */
  26579. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  26580. }
  26581. }
  26582. declare module BABYLON {
  26583. /**
  26584. * "Static Class" containing the most commonly used helper while dealing with material for
  26585. * rendering purpose.
  26586. *
  26587. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  26588. *
  26589. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  26590. */
  26591. class MaterialHelper {
  26592. /**
  26593. * Bind the current view position to an effect.
  26594. * @param effect The effect to be bound
  26595. * @param scene The scene the eyes position is used from
  26596. */
  26597. static BindEyePosition(effect: Effect, scene: Scene): void;
  26598. /**
  26599. * Helps preparing the defines values about the UVs in used in the effect.
  26600. * UVs are shared as much as we can accross chanels in the shaders.
  26601. * @param texture The texture we are preparing the UVs for
  26602. * @param defines The defines to update
  26603. * @param key The chanel key "diffuse", "specular"... used in the shader
  26604. */
  26605. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  26606. /**
  26607. * Binds a texture matrix value to its corrsponding uniform
  26608. * @param texture The texture to bind the matrix for
  26609. * @param uniformBuffer The uniform buffer receivin the data
  26610. * @param key The chanel key "diffuse", "specular"... used in the shader
  26611. */
  26612. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  26613. /**
  26614. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  26615. * @param mesh defines the current mesh
  26616. * @param scene defines the current scene
  26617. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  26618. * @param pointsCloud defines if point cloud rendering has to be turned on
  26619. * @param fogEnabled defines if fog has to be turned on
  26620. * @param alphaTest defines if alpha testing has to be turned on
  26621. * @param defines defines the current list of defines
  26622. */
  26623. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  26624. /**
  26625. * Helper used to prepare the list of defines associated with frame values for shader compilation
  26626. * @param scene defines the current scene
  26627. * @param engine defines the current engine
  26628. * @param defines specifies the list of active defines
  26629. * @param useInstances defines if instances have to be turned on
  26630. * @param useClipPlane defines if clip plane have to be turned on
  26631. */
  26632. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  26633. /**
  26634. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  26635. * @param mesh The mesh containing the geometry data we will draw
  26636. * @param defines The defines to update
  26637. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  26638. * @param useBones Precise whether bones should be used or not (override mesh info)
  26639. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  26640. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  26641. * @returns false if defines are considered not dirty and have not been checked
  26642. */
  26643. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  26644. /**
  26645. * Prepares the defines related to the light information passed in parameter
  26646. * @param scene The scene we are intending to draw
  26647. * @param mesh The mesh the effect is compiling for
  26648. * @param defines The defines to update
  26649. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  26650. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  26651. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  26652. * @returns true if normals will be required for the rest of the effect
  26653. */
  26654. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  26655. /**
  26656. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  26657. * that won t be acctive due to defines being turned off.
  26658. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  26659. * @param samplersList The samplers list
  26660. * @param defines The defines helping in the list generation
  26661. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  26662. */
  26663. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  26664. /**
  26665. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  26666. * @param defines The defines to update while falling back
  26667. * @param fallbacks The authorized effect fallbacks
  26668. * @param maxSimultaneousLights The maximum number of lights allowed
  26669. * @param rank the current rank of the Effect
  26670. * @returns The newly affected rank
  26671. */
  26672. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  26673. /**
  26674. * Prepares the list of attributes required for morph targets according to the effect defines.
  26675. * @param attribs The current list of supported attribs
  26676. * @param mesh The mesh to prepare the morph targets attributes for
  26677. * @param defines The current Defines of the effect
  26678. */
  26679. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  26680. /**
  26681. * Prepares the list of attributes required for bones according to the effect defines.
  26682. * @param attribs The current list of supported attribs
  26683. * @param mesh The mesh to prepare the bones attributes for
  26684. * @param defines The current Defines of the effect
  26685. * @param fallbacks The current efffect fallback strategy
  26686. */
  26687. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  26688. /**
  26689. * Prepares the list of attributes required for instances according to the effect defines.
  26690. * @param attribs The current list of supported attribs
  26691. * @param defines The current Defines of the effect
  26692. */
  26693. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  26694. /**
  26695. * Binds the light shadow information to the effect for the given mesh.
  26696. * @param light The light containing the generator
  26697. * @param scene The scene the lights belongs to
  26698. * @param mesh The mesh we are binding the information to render
  26699. * @param lightIndex The light index in the effect used to render the mesh
  26700. * @param effect The effect we are binding the data to
  26701. */
  26702. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  26703. /**
  26704. * Binds the light information to the effect.
  26705. * @param light The light containing the generator
  26706. * @param effect The effect we are binding the data to
  26707. * @param lightIndex The light index in the effect used to render
  26708. */
  26709. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  26710. /**
  26711. * Binds the lights information from the scene to the effect for the given mesh.
  26712. * @param scene The scene the lights belongs to
  26713. * @param mesh The mesh we are binding the information to render
  26714. * @param effect The effect we are binding the data to
  26715. * @param defines The generated defines for the effect
  26716. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  26717. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  26718. */
  26719. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  26720. /**
  26721. * Binds the fog information from the scene to the effect for the given mesh.
  26722. * @param scene The scene the lights belongs to
  26723. * @param mesh The mesh we are binding the information to render
  26724. * @param effect The effect we are binding the data to
  26725. */
  26726. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  26727. /**
  26728. * Binds the bones information from the mesh to the effect.
  26729. * @param mesh The mesh we are binding the information to render
  26730. * @param effect The effect we are binding the data to
  26731. */
  26732. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  26733. /**
  26734. * Binds the morph targets information from the mesh to the effect.
  26735. * @param abstractMesh The mesh we are binding the information to render
  26736. * @param effect The effect we are binding the data to
  26737. */
  26738. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  26739. /**
  26740. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  26741. * @param defines The generated defines used in the effect
  26742. * @param effect The effect we are binding the data to
  26743. * @param scene The scene we are willing to render with logarithmic scale for
  26744. */
  26745. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  26746. /**
  26747. * Binds the clip plane information from the scene to the effect.
  26748. * @param scene The scene the clip plane information are extracted from
  26749. * @param effect The effect we are binding the data to
  26750. */
  26751. static BindClipPlane(effect: Effect, scene: Scene): void;
  26752. }
  26753. }
  26754. declare module BABYLON {
  26755. class MultiMaterial extends Material {
  26756. private _subMaterials;
  26757. subMaterials: Nullable<Material>[];
  26758. constructor(name: string, scene: Scene);
  26759. private _hookArray;
  26760. getSubMaterial(index: number): Nullable<Material>;
  26761. getActiveTextures(): BaseTexture[];
  26762. getClassName(): string;
  26763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  26764. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26765. serialize(): any;
  26766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26767. }
  26768. }
  26769. declare module BABYLON {
  26770. class PushMaterial extends Material {
  26771. protected _activeEffect: Effect;
  26772. protected _normalMatrix: Matrix;
  26773. constructor(name: string, scene: Scene);
  26774. getEffect(): Effect;
  26775. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26776. /**
  26777. * Binds the given world matrix to the active effect
  26778. *
  26779. * @param world the matrix to bind
  26780. */
  26781. bindOnlyWorldMatrix(world: Matrix): void;
  26782. /**
  26783. * Binds the given normal matrix to the active effect
  26784. *
  26785. * @param normalMatrix the matrix to bind
  26786. */
  26787. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26788. bind(world: Matrix, mesh?: Mesh): void;
  26789. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26790. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26791. }
  26792. }
  26793. declare module BABYLON {
  26794. class ShaderMaterial extends Material {
  26795. private _shaderPath;
  26796. private _options;
  26797. private _textures;
  26798. private _textureArrays;
  26799. private _floats;
  26800. private _ints;
  26801. private _floatsArrays;
  26802. private _colors3;
  26803. private _colors3Arrays;
  26804. private _colors4;
  26805. private _vectors2;
  26806. private _vectors3;
  26807. private _vectors4;
  26808. private _matrices;
  26809. private _matrices3x3;
  26810. private _matrices2x2;
  26811. private _vectors2Arrays;
  26812. private _vectors3Arrays;
  26813. private _cachedWorldViewMatrix;
  26814. private _renderId;
  26815. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  26816. getClassName(): string;
  26817. needAlphaBlending(): boolean;
  26818. needAlphaTesting(): boolean;
  26819. private _checkUniform;
  26820. setTexture(name: string, texture: Texture): ShaderMaterial;
  26821. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  26822. setFloat(name: string, value: number): ShaderMaterial;
  26823. setInt(name: string, value: number): ShaderMaterial;
  26824. setFloats(name: string, value: number[]): ShaderMaterial;
  26825. setColor3(name: string, value: Color3): ShaderMaterial;
  26826. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  26827. setColor4(name: string, value: Color4): ShaderMaterial;
  26828. setVector2(name: string, value: Vector2): ShaderMaterial;
  26829. setVector3(name: string, value: Vector3): ShaderMaterial;
  26830. setVector4(name: string, value: Vector4): ShaderMaterial;
  26831. setMatrix(name: string, value: Matrix): ShaderMaterial;
  26832. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  26833. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  26834. setArray2(name: string, value: number[]): ShaderMaterial;
  26835. setArray3(name: string, value: number[]): ShaderMaterial;
  26836. private _checkCache;
  26837. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26838. bindOnlyWorldMatrix(world: Matrix): void;
  26839. bind(world: Matrix, mesh?: Mesh): void;
  26840. getActiveTextures(): BaseTexture[];
  26841. hasTexture(texture: BaseTexture): boolean;
  26842. clone(name: string): ShaderMaterial;
  26843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26844. serialize(): any;
  26845. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  26846. }
  26847. }
  26848. declare module BABYLON {
  26849. /** @hidden */
  26850. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26851. MAINUV1: boolean;
  26852. MAINUV2: boolean;
  26853. DIFFUSE: boolean;
  26854. DIFFUSEDIRECTUV: number;
  26855. AMBIENT: boolean;
  26856. AMBIENTDIRECTUV: number;
  26857. OPACITY: boolean;
  26858. OPACITYDIRECTUV: number;
  26859. OPACITYRGB: boolean;
  26860. REFLECTION: boolean;
  26861. EMISSIVE: boolean;
  26862. EMISSIVEDIRECTUV: number;
  26863. SPECULAR: boolean;
  26864. SPECULARDIRECTUV: number;
  26865. BUMP: boolean;
  26866. BUMPDIRECTUV: number;
  26867. PARALLAX: boolean;
  26868. PARALLAXOCCLUSION: boolean;
  26869. SPECULAROVERALPHA: boolean;
  26870. CLIPPLANE: boolean;
  26871. CLIPPLANE2: boolean;
  26872. CLIPPLANE3: boolean;
  26873. CLIPPLANE4: boolean;
  26874. ALPHATEST: boolean;
  26875. DEPTHPREPASS: boolean;
  26876. ALPHAFROMDIFFUSE: boolean;
  26877. POINTSIZE: boolean;
  26878. FOG: boolean;
  26879. SPECULARTERM: boolean;
  26880. DIFFUSEFRESNEL: boolean;
  26881. OPACITYFRESNEL: boolean;
  26882. REFLECTIONFRESNEL: boolean;
  26883. REFRACTIONFRESNEL: boolean;
  26884. EMISSIVEFRESNEL: boolean;
  26885. FRESNEL: boolean;
  26886. NORMAL: boolean;
  26887. UV1: boolean;
  26888. UV2: boolean;
  26889. VERTEXCOLOR: boolean;
  26890. VERTEXALPHA: boolean;
  26891. NUM_BONE_INFLUENCERS: number;
  26892. BonesPerMesh: number;
  26893. INSTANCES: boolean;
  26894. GLOSSINESS: boolean;
  26895. ROUGHNESS: boolean;
  26896. EMISSIVEASILLUMINATION: boolean;
  26897. LINKEMISSIVEWITHDIFFUSE: boolean;
  26898. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26899. LIGHTMAP: boolean;
  26900. LIGHTMAPDIRECTUV: number;
  26901. OBJECTSPACE_NORMALMAP: boolean;
  26902. USELIGHTMAPASSHADOWMAP: boolean;
  26903. REFLECTIONMAP_3D: boolean;
  26904. REFLECTIONMAP_SPHERICAL: boolean;
  26905. REFLECTIONMAP_PLANAR: boolean;
  26906. REFLECTIONMAP_CUBIC: boolean;
  26907. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26908. REFLECTIONMAP_PROJECTION: boolean;
  26909. REFLECTIONMAP_SKYBOX: boolean;
  26910. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26911. REFLECTIONMAP_EXPLICIT: boolean;
  26912. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26913. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26914. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26915. INVERTCUBICMAP: boolean;
  26916. LOGARITHMICDEPTH: boolean;
  26917. REFRACTION: boolean;
  26918. REFRACTIONMAP_3D: boolean;
  26919. REFLECTIONOVERALPHA: boolean;
  26920. TWOSIDEDLIGHTING: boolean;
  26921. SHADOWFLOAT: boolean;
  26922. MORPHTARGETS: boolean;
  26923. MORPHTARGETS_NORMAL: boolean;
  26924. MORPHTARGETS_TANGENT: boolean;
  26925. NUM_MORPH_INFLUENCERS: number;
  26926. NONUNIFORMSCALING: boolean;
  26927. PREMULTIPLYALPHA: boolean;
  26928. IMAGEPROCESSING: boolean;
  26929. VIGNETTE: boolean;
  26930. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26931. VIGNETTEBLENDMODEOPAQUE: boolean;
  26932. TONEMAPPING: boolean;
  26933. TONEMAPPING_ACES: boolean;
  26934. CONTRAST: boolean;
  26935. COLORCURVES: boolean;
  26936. COLORGRADING: boolean;
  26937. COLORGRADING3D: boolean;
  26938. SAMPLER3DGREENDEPTH: boolean;
  26939. SAMPLER3DBGRMAP: boolean;
  26940. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26941. /**
  26942. * If the reflection texture on this material is in linear color space
  26943. * @hidden
  26944. */
  26945. IS_REFLECTION_LINEAR: boolean;
  26946. /**
  26947. * If the refraction texture on this material is in linear color space
  26948. * @hidden
  26949. */
  26950. IS_REFRACTION_LINEAR: boolean;
  26951. EXPOSURE: boolean;
  26952. constructor();
  26953. setReflectionMode(modeToEnable: string): void;
  26954. }
  26955. class StandardMaterial extends PushMaterial {
  26956. private _diffuseTexture;
  26957. diffuseTexture: Nullable<BaseTexture>;
  26958. private _ambientTexture;
  26959. ambientTexture: Nullable<BaseTexture>;
  26960. private _opacityTexture;
  26961. opacityTexture: Nullable<BaseTexture>;
  26962. private _reflectionTexture;
  26963. reflectionTexture: Nullable<BaseTexture>;
  26964. private _emissiveTexture;
  26965. emissiveTexture: Nullable<BaseTexture>;
  26966. private _specularTexture;
  26967. specularTexture: Nullable<BaseTexture>;
  26968. private _bumpTexture;
  26969. bumpTexture: Nullable<BaseTexture>;
  26970. private _lightmapTexture;
  26971. lightmapTexture: Nullable<BaseTexture>;
  26972. private _refractionTexture;
  26973. refractionTexture: Nullable<BaseTexture>;
  26974. ambientColor: Color3;
  26975. diffuseColor: Color3;
  26976. specularColor: Color3;
  26977. emissiveColor: Color3;
  26978. specularPower: number;
  26979. private _useAlphaFromDiffuseTexture;
  26980. useAlphaFromDiffuseTexture: boolean;
  26981. private _useEmissiveAsIllumination;
  26982. useEmissiveAsIllumination: boolean;
  26983. private _linkEmissiveWithDiffuse;
  26984. linkEmissiveWithDiffuse: boolean;
  26985. private _useSpecularOverAlpha;
  26986. useSpecularOverAlpha: boolean;
  26987. private _useReflectionOverAlpha;
  26988. useReflectionOverAlpha: boolean;
  26989. private _disableLighting;
  26990. disableLighting: boolean;
  26991. private _useObjectSpaceNormalMap;
  26992. /**
  26993. * Allows using an object space normal map (instead of tangent space).
  26994. */
  26995. useObjectSpaceNormalMap: boolean;
  26996. private _useParallax;
  26997. useParallax: boolean;
  26998. private _useParallaxOcclusion;
  26999. useParallaxOcclusion: boolean;
  27000. parallaxScaleBias: number;
  27001. private _roughness;
  27002. roughness: number;
  27003. indexOfRefraction: number;
  27004. invertRefractionY: boolean;
  27005. /**
  27006. * Defines the alpha limits in alpha test mode
  27007. */
  27008. alphaCutOff: number;
  27009. private _useLightmapAsShadowmap;
  27010. useLightmapAsShadowmap: boolean;
  27011. private _diffuseFresnelParameters;
  27012. diffuseFresnelParameters: FresnelParameters;
  27013. private _opacityFresnelParameters;
  27014. opacityFresnelParameters: FresnelParameters;
  27015. private _reflectionFresnelParameters;
  27016. reflectionFresnelParameters: FresnelParameters;
  27017. private _refractionFresnelParameters;
  27018. refractionFresnelParameters: FresnelParameters;
  27019. private _emissiveFresnelParameters;
  27020. emissiveFresnelParameters: FresnelParameters;
  27021. private _useReflectionFresnelFromSpecular;
  27022. useReflectionFresnelFromSpecular: boolean;
  27023. private _useGlossinessFromSpecularMapAlpha;
  27024. useGlossinessFromSpecularMapAlpha: boolean;
  27025. private _maxSimultaneousLights;
  27026. maxSimultaneousLights: number;
  27027. /**
  27028. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27029. */
  27030. private _invertNormalMapX;
  27031. invertNormalMapX: boolean;
  27032. /**
  27033. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27034. */
  27035. private _invertNormalMapY;
  27036. invertNormalMapY: boolean;
  27037. /**
  27038. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27039. */
  27040. private _twoSidedLighting;
  27041. twoSidedLighting: boolean;
  27042. /**
  27043. * Default configuration related to image processing available in the standard Material.
  27044. */
  27045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27046. /**
  27047. * Gets the image processing configuration used either in this material.
  27048. */
  27049. /**
  27050. * Sets the Default image processing configuration used either in the this material.
  27051. *
  27052. * If sets to null, the scene one is in use.
  27053. */
  27054. imageProcessingConfiguration: ImageProcessingConfiguration;
  27055. /**
  27056. * Keep track of the image processing observer to allow dispose and replace.
  27057. */
  27058. private _imageProcessingObserver;
  27059. /**
  27060. * Attaches a new image processing configuration to the Standard Material.
  27061. * @param configuration
  27062. */
  27063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27064. /**
  27065. * Gets wether the color curves effect is enabled.
  27066. */
  27067. /**
  27068. * Sets wether the color curves effect is enabled.
  27069. */
  27070. cameraColorCurvesEnabled: boolean;
  27071. /**
  27072. * Gets wether the color grading effect is enabled.
  27073. */
  27074. /**
  27075. * Gets wether the color grading effect is enabled.
  27076. */
  27077. cameraColorGradingEnabled: boolean;
  27078. /**
  27079. * Gets wether tonemapping is enabled or not.
  27080. */
  27081. /**
  27082. * Sets wether tonemapping is enabled or not
  27083. */
  27084. cameraToneMappingEnabled: boolean;
  27085. /**
  27086. * The camera exposure used on this material.
  27087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27088. * This corresponds to a photographic exposure.
  27089. */
  27090. /**
  27091. * The camera exposure used on this material.
  27092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27093. * This corresponds to a photographic exposure.
  27094. */
  27095. cameraExposure: number;
  27096. /**
  27097. * Gets The camera contrast used on this material.
  27098. */
  27099. /**
  27100. * Sets The camera contrast used on this material.
  27101. */
  27102. cameraContrast: number;
  27103. /**
  27104. * Gets the Color Grading 2D Lookup Texture.
  27105. */
  27106. /**
  27107. * Sets the Color Grading 2D Lookup Texture.
  27108. */
  27109. cameraColorGradingTexture: Nullable<BaseTexture>;
  27110. /**
  27111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27113. * 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;
  27114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27115. */
  27116. /**
  27117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27119. * 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;
  27120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27121. */
  27122. cameraColorCurves: Nullable<ColorCurves>;
  27123. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27124. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27125. protected _worldViewProjectionMatrix: Matrix;
  27126. protected _globalAmbientColor: Color3;
  27127. protected _useLogarithmicDepth: boolean;
  27128. constructor(name: string, scene: Scene);
  27129. getClassName(): string;
  27130. useLogarithmicDepth: boolean;
  27131. needAlphaBlending(): boolean;
  27132. needAlphaTesting(): boolean;
  27133. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27134. getAlphaTestTexture(): Nullable<BaseTexture>;
  27135. /**
  27136. * Child classes can use it to update shaders
  27137. */
  27138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27139. buildUniformLayout(): void;
  27140. unbind(): void;
  27141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27142. getAnimatables(): IAnimatable[];
  27143. getActiveTextures(): BaseTexture[];
  27144. hasTexture(texture: BaseTexture): boolean;
  27145. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27146. clone(name: string): StandardMaterial;
  27147. serialize(): any;
  27148. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27149. static _DiffuseTextureEnabled: boolean;
  27150. static DiffuseTextureEnabled: boolean;
  27151. static _AmbientTextureEnabled: boolean;
  27152. static AmbientTextureEnabled: boolean;
  27153. static _OpacityTextureEnabled: boolean;
  27154. static OpacityTextureEnabled: boolean;
  27155. static _ReflectionTextureEnabled: boolean;
  27156. static ReflectionTextureEnabled: boolean;
  27157. static _EmissiveTextureEnabled: boolean;
  27158. static EmissiveTextureEnabled: boolean;
  27159. static _SpecularTextureEnabled: boolean;
  27160. static SpecularTextureEnabled: boolean;
  27161. static _BumpTextureEnabled: boolean;
  27162. static BumpTextureEnabled: boolean;
  27163. static _LightmapTextureEnabled: boolean;
  27164. static LightmapTextureEnabled: boolean;
  27165. static _RefractionTextureEnabled: boolean;
  27166. static RefractionTextureEnabled: boolean;
  27167. static _ColorGradingTextureEnabled: boolean;
  27168. static ColorGradingTextureEnabled: boolean;
  27169. static _FresnelEnabled: boolean;
  27170. static FresnelEnabled: boolean;
  27171. }
  27172. }
  27173. declare module BABYLON {
  27174. class UniformBuffer {
  27175. private _engine;
  27176. private _buffer;
  27177. private _data;
  27178. private _bufferData;
  27179. private _dynamic?;
  27180. private _uniformLocations;
  27181. private _uniformSizes;
  27182. private _uniformLocationPointer;
  27183. private _needSync;
  27184. private _noUBO;
  27185. private _currentEffect;
  27186. private static _MAX_UNIFORM_SIZE;
  27187. private static _tempBuffer;
  27188. /**
  27189. * Wrapper for updateUniform.
  27190. * @method updateMatrix3x3
  27191. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27192. * @param {Float32Array} matrix
  27193. */
  27194. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27195. /**
  27196. * Wrapper for updateUniform.
  27197. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27198. * @param {Float32Array} matrix
  27199. */
  27200. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27201. /**
  27202. * Wrapper for updateUniform.
  27203. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27204. * @param {number} x
  27205. */
  27206. updateFloat: (name: string, x: number) => void;
  27207. /**
  27208. * Wrapper for updateUniform.
  27209. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27210. * @param {number} x
  27211. * @param {number} y
  27212. * @param {string} [suffix] Suffix to add to the uniform name.
  27213. */
  27214. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27215. /**
  27216. * Wrapper for updateUniform.
  27217. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27218. * @param {number} x
  27219. * @param {number} y
  27220. * @param {number} z
  27221. * @param {string} [suffix] Suffix to add to the uniform name.
  27222. */
  27223. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27224. /**
  27225. * Wrapper for updateUniform.
  27226. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27227. * @param {number} x
  27228. * @param {number} y
  27229. * @param {number} z
  27230. * @param {number} w
  27231. * @param {string} [suffix] Suffix to add to the uniform name.
  27232. */
  27233. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27234. /**
  27235. * Wrapper for updateUniform.
  27236. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27237. * @param {Matrix} A 4x4 matrix.
  27238. */
  27239. updateMatrix: (name: string, mat: Matrix) => void;
  27240. /**
  27241. * Wrapper for updateUniform.
  27242. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27243. * @param {Vector3} vector
  27244. */
  27245. updateVector3: (name: string, vector: Vector3) => void;
  27246. /**
  27247. * Wrapper for updateUniform.
  27248. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27249. * @param {Vector4} vector
  27250. */
  27251. updateVector4: (name: string, vector: Vector4) => void;
  27252. /**
  27253. * Wrapper for updateUniform.
  27254. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27255. * @param {Color3} color
  27256. * @param {string} [suffix] Suffix to add to the uniform name.
  27257. */
  27258. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27259. /**
  27260. * Wrapper for updateUniform.
  27261. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27262. * @param {Color3} color
  27263. * @param {number} alpha
  27264. * @param {string} [suffix] Suffix to add to the uniform name.
  27265. */
  27266. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27267. /**
  27268. * Uniform buffer objects.
  27269. *
  27270. * Handles blocks of uniform on the GPU.
  27271. *
  27272. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27273. *
  27274. * For more information, please refer to :
  27275. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27276. */
  27277. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27278. /**
  27279. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27280. * or just falling back on setUniformXXX calls.
  27281. */
  27282. readonly useUbo: boolean;
  27283. /**
  27284. * Indicates if the WebGL underlying uniform buffer is in sync
  27285. * with the javascript cache data.
  27286. */
  27287. readonly isSync: boolean;
  27288. /**
  27289. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27290. * Also, a dynamic UniformBuffer will disable cache verification and always
  27291. * update the underlying WebGL uniform buffer to the GPU.
  27292. */
  27293. isDynamic(): boolean;
  27294. /**
  27295. * The data cache on JS side.
  27296. */
  27297. getData(): Float32Array;
  27298. /**
  27299. * The underlying WebGL Uniform buffer.
  27300. */
  27301. getBuffer(): Nullable<WebGLBuffer>;
  27302. /**
  27303. * std140 layout specifies how to align data within an UBO structure.
  27304. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27305. * for specs.
  27306. */
  27307. private _fillAlignment;
  27308. /**
  27309. * Adds an uniform in the buffer.
  27310. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27311. * for the layout to be correct !
  27312. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27313. * @param {number|number[]} size Data size, or data directly.
  27314. */
  27315. addUniform(name: string, size: number | number[]): void;
  27316. /**
  27317. * Wrapper for addUniform.
  27318. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27319. * @param {Matrix} mat A 4x4 matrix.
  27320. */
  27321. addMatrix(name: string, mat: Matrix): void;
  27322. /**
  27323. * Wrapper for addUniform.
  27324. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27325. * @param {number} x
  27326. * @param {number} y
  27327. */
  27328. addFloat2(name: string, x: number, y: number): void;
  27329. /**
  27330. * Wrapper for addUniform.
  27331. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27332. * @param {number} x
  27333. * @param {number} y
  27334. * @param {number} z
  27335. */
  27336. addFloat3(name: string, x: number, y: number, z: number): void;
  27337. /**
  27338. * Wrapper for addUniform.
  27339. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27340. * @param {Color3} color
  27341. */
  27342. addColor3(name: string, color: Color3): void;
  27343. /**
  27344. * Wrapper for addUniform.
  27345. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27346. * @param {Color3} color
  27347. * @param {number} alpha
  27348. */
  27349. addColor4(name: string, color: Color3, alpha: number): void;
  27350. /**
  27351. * Wrapper for addUniform.
  27352. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27353. * @param {Vector3} vector
  27354. */
  27355. addVector3(name: string, vector: Vector3): void;
  27356. /**
  27357. * Wrapper for addUniform.
  27358. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27359. */
  27360. addMatrix3x3(name: string): void;
  27361. /**
  27362. * Wrapper for addUniform.
  27363. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  27364. */
  27365. addMatrix2x2(name: string): void;
  27366. /**
  27367. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27368. */
  27369. create(): void;
  27370. /** @hidden */
  27371. _rebuild(): void;
  27372. /**
  27373. * Updates the WebGL Uniform Buffer on the GPU.
  27374. * If the `dynamic` flag is set to true, no cache comparison is done.
  27375. * Otherwise, the buffer will be updated only if the cache differs.
  27376. */
  27377. update(): void;
  27378. /**
  27379. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27380. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  27381. * @param {number[]|Float32Array} data Flattened data
  27382. * @param {number} size Size of the data.
  27383. */
  27384. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27385. private _updateMatrix3x3ForUniform;
  27386. private _updateMatrix3x3ForEffect;
  27387. private _updateMatrix2x2ForEffect;
  27388. private _updateMatrix2x2ForUniform;
  27389. private _updateFloatForEffect;
  27390. private _updateFloatForUniform;
  27391. private _updateFloat2ForEffect;
  27392. private _updateFloat2ForUniform;
  27393. private _updateFloat3ForEffect;
  27394. private _updateFloat3ForUniform;
  27395. private _updateFloat4ForEffect;
  27396. private _updateFloat4ForUniform;
  27397. private _updateMatrixForEffect;
  27398. private _updateMatrixForUniform;
  27399. private _updateVector3ForEffect;
  27400. private _updateVector3ForUniform;
  27401. private _updateVector4ForEffect;
  27402. private _updateVector4ForUniform;
  27403. private _updateColor3ForEffect;
  27404. private _updateColor3ForUniform;
  27405. private _updateColor4ForEffect;
  27406. private _updateColor4ForUniform;
  27407. /**
  27408. * Sets a sampler uniform on the effect.
  27409. * @param {string} name Name of the sampler.
  27410. * @param {Texture} texture
  27411. */
  27412. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27413. /**
  27414. * Directly updates the value of the uniform in the cache AND on the GPU.
  27415. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  27416. * @param {number[]|Float32Array} data Flattened data
  27417. */
  27418. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27419. /**
  27420. * Binds this uniform buffer to an effect.
  27421. * @param {Effect} effect
  27422. * @param {string} name Name of the uniform block in the shader.
  27423. */
  27424. bindToEffect(effect: Effect, name: string): void;
  27425. /**
  27426. * Disposes the uniform buffer.
  27427. */
  27428. dispose(): void;
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. /**
  27433. * Class used to generate realtime reflection / refraction cube textures
  27434. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  27435. */
  27436. class ReflectionProbe {
  27437. /** defines the name of the probe */
  27438. name: string;
  27439. private _scene;
  27440. private _renderTargetTexture;
  27441. private _projectionMatrix;
  27442. private _viewMatrix;
  27443. private _target;
  27444. private _add;
  27445. private _attachedMesh;
  27446. private _invertYAxis;
  27447. /** Gets or sets probe position (center of the cube map) */
  27448. position: Vector3;
  27449. /**
  27450. * Creates a new reflection probe
  27451. * @param name defines the name of the probe
  27452. * @param size defines the texture resolution (for each face)
  27453. * @param scene defines the hosting scene
  27454. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  27455. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  27456. */
  27457. constructor(
  27458. /** defines the name of the probe */
  27459. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  27460. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  27461. samples: number;
  27462. /** Gets or sets the refresh rate to use (on every frame by default) */
  27463. refreshRate: number;
  27464. /**
  27465. * Gets the hosting scene
  27466. * @returns a Scene
  27467. */
  27468. getScene(): Scene;
  27469. /** Gets the internal CubeTexture used to render to */
  27470. readonly cubeTexture: RenderTargetTexture;
  27471. /** Gets the list of meshes to render */
  27472. readonly renderList: Nullable<AbstractMesh[]>;
  27473. /**
  27474. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  27475. * @param mesh defines the mesh to attach to
  27476. */
  27477. attachToMesh(mesh: AbstractMesh): void;
  27478. /**
  27479. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  27480. * @param renderingGroupId The rendering group id corresponding to its index
  27481. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27482. */
  27483. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27484. /**
  27485. * Clean all associated resources
  27486. */
  27487. dispose(): void;
  27488. }
  27489. }
  27490. declare module BABYLON {
  27491. /**
  27492. * Postprocess used to generate anaglyphic rendering
  27493. */
  27494. class AnaglyphPostProcess extends PostProcess {
  27495. private _passedProcess;
  27496. /**
  27497. * Creates a new AnaglyphPostProcess
  27498. * @param name defines postprocess name
  27499. * @param options defines creation options or target ratio scale
  27500. * @param rigCameras defines cameras using this postprocess
  27501. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27502. * @param engine defines hosting engine
  27503. * @param reusable defines if the postprocess will be reused multiple times per frame
  27504. */
  27505. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27506. }
  27507. }
  27508. declare module BABYLON {
  27509. class BlackAndWhitePostProcess extends PostProcess {
  27510. degree: number;
  27511. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27512. }
  27513. }
  27514. declare module BABYLON {
  27515. /**
  27516. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27517. */
  27518. class BloomEffect extends PostProcessRenderEffect {
  27519. private bloomScale;
  27520. /**
  27521. * @hidden Internal
  27522. */
  27523. _effects: Array<PostProcess>;
  27524. /**
  27525. * @hidden Internal
  27526. */
  27527. _downscale: ExtractHighlightsPostProcess;
  27528. private _blurX;
  27529. private _blurY;
  27530. private _merge;
  27531. /**
  27532. * The luminance threshold to find bright areas of the image to bloom.
  27533. */
  27534. threshold: number;
  27535. /**
  27536. * The strength of the bloom.
  27537. */
  27538. weight: number;
  27539. /**
  27540. * Specifies the size of the bloom blur kernel, relative to the final output size
  27541. */
  27542. kernel: number;
  27543. /**
  27544. * Creates a new instance of @see BloomEffect
  27545. * @param scene The scene the effect belongs to.
  27546. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27547. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27548. * @param bloomWeight The the strength of bloom.
  27549. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27550. * @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)
  27551. */
  27552. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27553. /**
  27554. * Disposes each of the internal effects for a given camera.
  27555. * @param camera The camera to dispose the effect on.
  27556. */
  27557. disposeEffects(camera: Camera): void;
  27558. /**
  27559. * @hidden Internal
  27560. */
  27561. _updateEffects(): void;
  27562. /**
  27563. * Internal
  27564. * @returns if all the contained post processes are ready.
  27565. * @hidden
  27566. */
  27567. _isReady(): boolean;
  27568. }
  27569. }
  27570. declare module BABYLON {
  27571. /**
  27572. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27573. */
  27574. class BloomMergePostProcess extends PostProcess {
  27575. /** Weight of the bloom to be added to the original input. */
  27576. weight: number;
  27577. /**
  27578. * Creates a new instance of @see BloomMergePostProcess
  27579. * @param name The name of the effect.
  27580. * @param originalFromInput Post process which's input will be used for the merge.
  27581. * @param blurred Blurred highlights post process which's output will be used.
  27582. * @param weight Weight of the bloom to be added to the original input.
  27583. * @param options The required width/height ratio to downsize to before computing the render pass.
  27584. * @param camera The camera to apply the render pass to.
  27585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27586. * @param engine The engine which the post process will be applied. (default: current engine)
  27587. * @param reusable If the post process can be reused on the same frame. (default: false)
  27588. * @param textureType Type of textures used when performing the post process. (default: 0)
  27589. * @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)
  27590. */
  27591. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27592. /** Weight of the bloom to be added to the original input. */
  27593. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27594. }
  27595. }
  27596. declare module BABYLON {
  27597. /**
  27598. * The Blur Post Process which blurs an image based on a kernel and direction.
  27599. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27600. */
  27601. class BlurPostProcess extends PostProcess {
  27602. /** The direction in which to blur the image. */
  27603. direction: Vector2;
  27604. private blockCompilation;
  27605. protected _kernel: number;
  27606. protected _idealKernel: number;
  27607. protected _packedFloat: boolean;
  27608. private _staticDefines;
  27609. /**
  27610. * Sets the length in pixels of the blur sample region
  27611. */
  27612. /**
  27613. * Gets the length in pixels of the blur sample region
  27614. */
  27615. kernel: number;
  27616. /**
  27617. * Sets wether or not the blur needs to unpack/repack floats
  27618. */
  27619. /**
  27620. * Gets wether or not the blur is unpacking/repacking floats
  27621. */
  27622. packedFloat: boolean;
  27623. /**
  27624. * Creates a new instance BlurPostProcess
  27625. * @param name The name of the effect.
  27626. * @param direction The direction in which to blur the image.
  27627. * @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.
  27628. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27629. * @param camera The camera to apply the render pass to.
  27630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27631. * @param engine The engine which the post process will be applied. (default: current engine)
  27632. * @param reusable If the post process can be reused on the same frame. (default: false)
  27633. * @param textureType Type of textures used when performing the post process. (default: 0)
  27634. * @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)
  27635. */
  27636. constructor(name: string,
  27637. /** The direction in which to blur the image. */
  27638. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27639. /**
  27640. * Updates the effect with the current post process compile time values and recompiles the shader.
  27641. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27642. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27643. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27644. * @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
  27645. * @param onCompiled Called when the shader has been compiled.
  27646. * @param onError Called if there is an error when compiling a shader.
  27647. */
  27648. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27649. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27650. /**
  27651. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27652. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27653. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27654. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27655. * The gaps between physical kernels are compensated for in the weighting of the samples
  27656. * @param idealKernel Ideal blur kernel.
  27657. * @return Nearest best kernel.
  27658. */
  27659. protected _nearestBestKernel(idealKernel: number): number;
  27660. /**
  27661. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27662. * @param x The point on the Gaussian distribution to sample.
  27663. * @return the value of the Gaussian function at x.
  27664. */
  27665. protected _gaussianWeight(x: number): number;
  27666. /**
  27667. * Generates a string that can be used as a floating point number in GLSL.
  27668. * @param x Value to print.
  27669. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27670. * @return GLSL float string.
  27671. */
  27672. protected _glslFloat(x: number, decimalFigures?: number): string;
  27673. }
  27674. }
  27675. declare module BABYLON {
  27676. /**
  27677. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27678. */
  27679. class ChromaticAberrationPostProcess extends PostProcess {
  27680. /**
  27681. * The amount of seperation of rgb channels (default: 30)
  27682. */
  27683. aberrationAmount: number;
  27684. /**
  27685. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27686. */
  27687. radialIntensity: number;
  27688. /**
  27689. * 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))
  27690. */
  27691. direction: Vector2;
  27692. /**
  27693. * 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))
  27694. */
  27695. centerPosition: Vector2;
  27696. /**
  27697. * Creates a new instance ChromaticAberrationPostProcess
  27698. * @param name The name of the effect.
  27699. * @param screenWidth The width of the screen to apply the effect on.
  27700. * @param screenHeight The height of the screen to apply the effect on.
  27701. * @param options The required width/height ratio to downsize to before computing the render pass.
  27702. * @param camera The camera to apply the render pass to.
  27703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27704. * @param engine The engine which the post process will be applied. (default: current engine)
  27705. * @param reusable If the post process can be reused on the same frame. (default: false)
  27706. * @param textureType Type of textures used when performing the post process. (default: 0)
  27707. * @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)
  27708. */
  27709. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27710. }
  27711. }
  27712. declare module BABYLON {
  27713. /**
  27714. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27715. */
  27716. class CircleOfConfusionPostProcess extends PostProcess {
  27717. /**
  27718. * 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.
  27719. */
  27720. lensSize: number;
  27721. /**
  27722. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27723. */
  27724. fStop: number;
  27725. /**
  27726. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27727. */
  27728. focusDistance: number;
  27729. /**
  27730. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27731. */
  27732. focalLength: number;
  27733. private _depthTexture;
  27734. /**
  27735. * Creates a new instance CircleOfConfusionPostProcess
  27736. * @param name The name of the effect.
  27737. * @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.
  27738. * @param options The required width/height ratio to downsize to before computing the render pass.
  27739. * @param camera The camera to apply the render pass to.
  27740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27741. * @param engine The engine which the post process will be applied. (default: current engine)
  27742. * @param reusable If the post process can be reused on the same frame. (default: false)
  27743. * @param textureType Type of textures used when performing the post process. (default: 0)
  27744. * @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)
  27745. */
  27746. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27747. /**
  27748. * 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.
  27749. */
  27750. depthTexture: RenderTargetTexture;
  27751. }
  27752. }
  27753. declare module BABYLON {
  27754. class ColorCorrectionPostProcess extends PostProcess {
  27755. private _colorTableTexture;
  27756. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27757. }
  27758. }
  27759. declare module BABYLON {
  27760. /**
  27761. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27762. * input texture to perform effects such as edge detection or sharpening
  27763. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27764. */
  27765. class ConvolutionPostProcess extends PostProcess {
  27766. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27767. kernel: number[];
  27768. /**
  27769. * Creates a new instance ConvolutionPostProcess
  27770. * @param name The name of the effect.
  27771. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27772. * @param options The required width/height ratio to downsize to before computing the render pass.
  27773. * @param camera The camera to apply the render pass to.
  27774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27775. * @param engine The engine which the post process will be applied. (default: current engine)
  27776. * @param reusable If the post process can be reused on the same frame. (default: false)
  27777. * @param textureType Type of textures used when performing the post process. (default: 0)
  27778. */
  27779. constructor(name: string,
  27780. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27781. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27782. /**
  27783. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27784. */
  27785. static EdgeDetect0Kernel: number[];
  27786. /**
  27787. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27788. */
  27789. static EdgeDetect1Kernel: number[];
  27790. /**
  27791. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27792. */
  27793. static EdgeDetect2Kernel: number[];
  27794. /**
  27795. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27796. */
  27797. static SharpenKernel: number[];
  27798. /**
  27799. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27800. */
  27801. static EmbossKernel: number[];
  27802. /**
  27803. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27804. */
  27805. static GaussianKernel: number[];
  27806. }
  27807. }
  27808. declare module BABYLON {
  27809. /**
  27810. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27811. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27812. * based on samples that have a large difference in distance than the center pixel.
  27813. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27814. */
  27815. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27816. direction: Vector2;
  27817. /**
  27818. * Creates a new instance CircleOfConfusionPostProcess
  27819. * @param name The name of the effect.
  27820. * @param scene The scene the effect belongs to.
  27821. * @param direction The direction the blur should be applied.
  27822. * @param kernel The size of the kernel used to blur.
  27823. * @param options The required width/height ratio to downsize to before computing the render pass.
  27824. * @param camera The camera to apply the render pass to.
  27825. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27826. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27828. * @param engine The engine which the post process will be applied. (default: current engine)
  27829. * @param reusable If the post process can be reused on the same frame. (default: false)
  27830. * @param textureType Type of textures used when performing the post process. (default: 0)
  27831. * @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)
  27832. */
  27833. 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);
  27834. }
  27835. }
  27836. declare module BABYLON {
  27837. /**
  27838. * Specifies the level of max blur that should be applied when using the depth of field effect
  27839. */
  27840. enum DepthOfFieldEffectBlurLevel {
  27841. /**
  27842. * Subtle blur
  27843. */
  27844. Low = 0,
  27845. /**
  27846. * Medium blur
  27847. */
  27848. Medium = 1,
  27849. /**
  27850. * Large blur
  27851. */
  27852. High = 2
  27853. }
  27854. /**
  27855. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27856. */
  27857. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27858. private _circleOfConfusion;
  27859. /**
  27860. * @hidden Internal, blurs from high to low
  27861. */
  27862. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27863. private _depthOfFieldBlurY;
  27864. private _dofMerge;
  27865. /**
  27866. * @hidden Internal post processes in depth of field effect
  27867. */
  27868. _effects: Array<PostProcess>;
  27869. /**
  27870. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27871. */
  27872. focalLength: number;
  27873. /**
  27874. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27875. */
  27876. fStop: number;
  27877. /**
  27878. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27879. */
  27880. focusDistance: number;
  27881. /**
  27882. * 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.
  27883. */
  27884. lensSize: number;
  27885. /**
  27886. * Creates a new instance DepthOfFieldEffect
  27887. * @param scene The scene the effect belongs to.
  27888. * @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.
  27889. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27890. * @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)
  27891. */
  27892. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27893. /**
  27894. * 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.
  27895. */
  27896. depthTexture: RenderTargetTexture;
  27897. /**
  27898. * Disposes each of the internal effects for a given camera.
  27899. * @param camera The camera to dispose the effect on.
  27900. */
  27901. disposeEffects(camera: Camera): void;
  27902. /**
  27903. * @hidden Internal
  27904. */
  27905. _updateEffects(): void;
  27906. /**
  27907. * Internal
  27908. * @returns if all the contained post processes are ready.
  27909. * @hidden
  27910. */
  27911. _isReady(): boolean;
  27912. }
  27913. }
  27914. declare module BABYLON {
  27915. /**
  27916. * Options to be set when merging outputs from the default pipeline.
  27917. */
  27918. class DepthOfFieldMergePostProcessOptions {
  27919. /**
  27920. * The original image to merge on top of
  27921. */
  27922. originalFromInput: PostProcess;
  27923. /**
  27924. * Parameters to perform the merge of the depth of field effect
  27925. */
  27926. depthOfField?: {
  27927. circleOfConfusion: PostProcess;
  27928. blurSteps: Array<PostProcess>;
  27929. };
  27930. /**
  27931. * Parameters to perform the merge of bloom effect
  27932. */
  27933. bloom?: {
  27934. blurred: PostProcess;
  27935. weight: number;
  27936. };
  27937. }
  27938. /**
  27939. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27940. */
  27941. class DepthOfFieldMergePostProcess extends PostProcess {
  27942. private blurSteps;
  27943. /**
  27944. * Creates a new instance of DepthOfFieldMergePostProcess
  27945. * @param name The name of the effect.
  27946. * @param originalFromInput Post process which's input will be used for the merge.
  27947. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27948. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27949. * @param options The required width/height ratio to downsize to before computing the render pass.
  27950. * @param camera The camera to apply the render pass to.
  27951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27952. * @param engine The engine which the post process will be applied. (default: current engine)
  27953. * @param reusable If the post process can be reused on the same frame. (default: false)
  27954. * @param textureType Type of textures used when performing the post process. (default: 0)
  27955. * @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)
  27956. */
  27957. 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);
  27958. /**
  27959. * Updates the effect with the current post process compile time values and recompiles the shader.
  27960. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27961. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27962. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27963. * @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
  27964. * @param onCompiled Called when the shader has been compiled.
  27965. * @param onError Called if there is an error when compiling a shader.
  27966. */
  27967. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27968. }
  27969. }
  27970. declare module BABYLON {
  27971. class DisplayPassPostProcess extends PostProcess {
  27972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27973. }
  27974. }
  27975. declare module BABYLON {
  27976. /**
  27977. * 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.
  27978. */
  27979. class ExtractHighlightsPostProcess extends PostProcess {
  27980. /**
  27981. * The luminance threshold, pixels below this value will be set to black.
  27982. */
  27983. threshold: number;
  27984. /** @hidden */
  27985. _exposure: number;
  27986. /**
  27987. * Post process which has the input texture to be used when performing highlight extraction
  27988. * @hidden
  27989. */
  27990. _inputPostProcess: Nullable<PostProcess>;
  27991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27992. }
  27993. }
  27994. declare module BABYLON {
  27995. class FilterPostProcess extends PostProcess {
  27996. kernelMatrix: Matrix;
  27997. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27998. }
  27999. }
  28000. declare module BABYLON {
  28001. class FxaaPostProcess extends PostProcess {
  28002. texelWidth: number;
  28003. texelHeight: number;
  28004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28005. private _getDefines;
  28006. }
  28007. }
  28008. declare module BABYLON {
  28009. /**
  28010. * The GrainPostProcess adds noise to the image at mid luminance levels
  28011. */
  28012. class GrainPostProcess extends PostProcess {
  28013. /**
  28014. * The intensity of the grain added (default: 30)
  28015. */
  28016. intensity: number;
  28017. /**
  28018. * If the grain should be randomized on every frame
  28019. */
  28020. animated: boolean;
  28021. /**
  28022. * Creates a new instance of @see GrainPostProcess
  28023. * @param name The name of the effect.
  28024. * @param options The required width/height ratio to downsize to before computing the render pass.
  28025. * @param camera The camera to apply the render pass to.
  28026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28027. * @param engine The engine which the post process will be applied. (default: current engine)
  28028. * @param reusable If the post process can be reused on the same frame. (default: false)
  28029. * @param textureType Type of textures used when performing the post process. (default: 0)
  28030. * @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)
  28031. */
  28032. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28033. }
  28034. }
  28035. declare module BABYLON {
  28036. class HighlightsPostProcess extends PostProcess {
  28037. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28038. }
  28039. }
  28040. declare module BABYLON {
  28041. class ImageProcessingPostProcess extends PostProcess {
  28042. /**
  28043. * Default configuration related to image processing available in the PBR Material.
  28044. */
  28045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28046. /**
  28047. * Gets the image processing configuration used either in this material.
  28048. */
  28049. /**
  28050. * Sets the Default image processing configuration used either in the this material.
  28051. *
  28052. * If sets to null, the scene one is in use.
  28053. */
  28054. imageProcessingConfiguration: ImageProcessingConfiguration;
  28055. /**
  28056. * Keep track of the image processing observer to allow dispose and replace.
  28057. */
  28058. private _imageProcessingObserver;
  28059. /**
  28060. * Attaches a new image processing configuration to the PBR Material.
  28061. * @param configuration
  28062. */
  28063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  28064. /**
  28065. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28066. */
  28067. /**
  28068. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28069. */
  28070. colorCurves: Nullable<ColorCurves>;
  28071. /**
  28072. * Gets wether the color curves effect is enabled.
  28073. */
  28074. /**
  28075. * Sets wether the color curves effect is enabled.
  28076. */
  28077. colorCurvesEnabled: boolean;
  28078. /**
  28079. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28080. */
  28081. /**
  28082. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28083. */
  28084. colorGradingTexture: Nullable<BaseTexture>;
  28085. /**
  28086. * Gets wether the color grading effect is enabled.
  28087. */
  28088. /**
  28089. * Gets wether the color grading effect is enabled.
  28090. */
  28091. colorGradingEnabled: boolean;
  28092. /**
  28093. * Gets exposure used in the effect.
  28094. */
  28095. /**
  28096. * Sets exposure used in the effect.
  28097. */
  28098. exposure: number;
  28099. /**
  28100. * Gets wether tonemapping is enabled or not.
  28101. */
  28102. /**
  28103. * Sets wether tonemapping is enabled or not
  28104. */
  28105. toneMappingEnabled: boolean;
  28106. /**
  28107. * Gets contrast used in the effect.
  28108. */
  28109. /**
  28110. * Sets contrast used in the effect.
  28111. */
  28112. contrast: number;
  28113. /**
  28114. * Gets Vignette stretch size.
  28115. */
  28116. /**
  28117. * Sets Vignette stretch size.
  28118. */
  28119. vignetteStretch: number;
  28120. /**
  28121. * Gets Vignette centre X Offset.
  28122. */
  28123. /**
  28124. * Sets Vignette centre X Offset.
  28125. */
  28126. vignetteCentreX: number;
  28127. /**
  28128. * Gets Vignette centre Y Offset.
  28129. */
  28130. /**
  28131. * Sets Vignette centre Y Offset.
  28132. */
  28133. vignetteCentreY: number;
  28134. /**
  28135. * Gets Vignette weight or intensity of the vignette effect.
  28136. */
  28137. /**
  28138. * Sets Vignette weight or intensity of the vignette effect.
  28139. */
  28140. vignetteWeight: number;
  28141. /**
  28142. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28143. * if vignetteEnabled is set to true.
  28144. */
  28145. /**
  28146. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28147. * if vignetteEnabled is set to true.
  28148. */
  28149. vignetteColor: Color4;
  28150. /**
  28151. * Gets Camera field of view used by the Vignette effect.
  28152. */
  28153. /**
  28154. * Sets Camera field of view used by the Vignette effect.
  28155. */
  28156. vignetteCameraFov: number;
  28157. /**
  28158. * Gets the vignette blend mode allowing different kind of effect.
  28159. */
  28160. /**
  28161. * Sets the vignette blend mode allowing different kind of effect.
  28162. */
  28163. vignetteBlendMode: number;
  28164. /**
  28165. * Gets wether the vignette effect is enabled.
  28166. */
  28167. /**
  28168. * Sets wether the vignette effect is enabled.
  28169. */
  28170. vignetteEnabled: boolean;
  28171. private _fromLinearSpace;
  28172. /**
  28173. * Gets wether the input of the processing is in Gamma or Linear Space.
  28174. */
  28175. /**
  28176. * Sets wether the input of the processing is in Gamma or Linear Space.
  28177. */
  28178. fromLinearSpace: boolean;
  28179. /**
  28180. * Defines cache preventing GC.
  28181. */
  28182. private _defines;
  28183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28184. getClassName(): string;
  28185. protected _updateParameters(): void;
  28186. dispose(camera?: Camera): void;
  28187. }
  28188. }
  28189. declare module BABYLON {
  28190. class PassPostProcess extends PostProcess {
  28191. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28192. }
  28193. }
  28194. declare module BABYLON {
  28195. type PostProcessOptions = {
  28196. width: number;
  28197. height: number;
  28198. };
  28199. /**
  28200. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28201. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28202. */
  28203. class PostProcess {
  28204. /** Name of the PostProcess. */
  28205. name: string;
  28206. /**
  28207. * Width of the texture to apply the post process on
  28208. */
  28209. width: number;
  28210. /**
  28211. * Height of the texture to apply the post process on
  28212. */
  28213. height: number;
  28214. /**
  28215. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28216. * @hidden
  28217. */
  28218. _outputTexture: Nullable<InternalTexture>;
  28219. /**
  28220. * Sampling mode used by the shader
  28221. * See https://doc.babylonjs.com/classes/3.1/texture
  28222. */
  28223. renderTargetSamplingMode: number;
  28224. /**
  28225. * Clear color to use when screen clearing
  28226. */
  28227. clearColor: Color4;
  28228. /**
  28229. * If the buffer needs to be cleared before applying the post process. (default: true)
  28230. * Should be set to false if shader will overwrite all previous pixels.
  28231. */
  28232. autoClear: boolean;
  28233. /**
  28234. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28235. */
  28236. alphaMode: number;
  28237. /**
  28238. * Sets the setAlphaBlendConstants of the babylon engine
  28239. */
  28240. alphaConstants: Color4;
  28241. /**
  28242. * Animations to be used for the post processing
  28243. */
  28244. animations: Animation[];
  28245. /**
  28246. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28247. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28248. */
  28249. enablePixelPerfectMode: boolean;
  28250. /**
  28251. * Force the postprocess to be applied without taking in account viewport
  28252. */
  28253. forceFullscreenViewport: boolean;
  28254. /**
  28255. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28256. *
  28257. * | Value | Type | Description |
  28258. * | ----- | ----------------------------------- | ----------- |
  28259. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28260. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28261. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28262. *
  28263. */
  28264. scaleMode: number;
  28265. /**
  28266. * Force textures to be a power of two (default: false)
  28267. */
  28268. alwaysForcePOT: boolean;
  28269. private _samples;
  28270. /**
  28271. * Number of sample textures (default: 1)
  28272. */
  28273. samples: number;
  28274. /**
  28275. * Modify the scale of the post process to be the same as the viewport (default: false)
  28276. */
  28277. adaptScaleToCurrentViewport: boolean;
  28278. private _camera;
  28279. private _scene;
  28280. private _engine;
  28281. private _options;
  28282. private _reusable;
  28283. private _textureType;
  28284. /**
  28285. * Smart array of input and output textures for the post process.
  28286. * @hidden
  28287. */
  28288. _textures: SmartArray<InternalTexture>;
  28289. /**
  28290. * The index in _textures that corresponds to the output texture.
  28291. * @hidden
  28292. */
  28293. _currentRenderTextureInd: number;
  28294. private _effect;
  28295. private _samplers;
  28296. private _fragmentUrl;
  28297. private _vertexUrl;
  28298. private _parameters;
  28299. private _scaleRatio;
  28300. protected _indexParameters: any;
  28301. private _shareOutputWithPostProcess;
  28302. private _texelSize;
  28303. private _forcedOutputTexture;
  28304. /**
  28305. * An event triggered when the postprocess is activated.
  28306. */
  28307. onActivateObservable: Observable<Camera>;
  28308. private _onActivateObserver;
  28309. /**
  28310. * A function that is added to the onActivateObservable
  28311. */
  28312. onActivate: Nullable<(camera: Camera) => void>;
  28313. /**
  28314. * An event triggered when the postprocess changes its size.
  28315. */
  28316. onSizeChangedObservable: Observable<PostProcess>;
  28317. private _onSizeChangedObserver;
  28318. /**
  28319. * A function that is added to the onSizeChangedObservable
  28320. */
  28321. onSizeChanged: (postProcess: PostProcess) => void;
  28322. /**
  28323. * An event triggered when the postprocess applies its effect.
  28324. */
  28325. onApplyObservable: Observable<Effect>;
  28326. private _onApplyObserver;
  28327. /**
  28328. * A function that is added to the onApplyObservable
  28329. */
  28330. onApply: (effect: Effect) => void;
  28331. /**
  28332. * An event triggered before rendering the postprocess
  28333. */
  28334. onBeforeRenderObservable: Observable<Effect>;
  28335. private _onBeforeRenderObserver;
  28336. /**
  28337. * A function that is added to the onBeforeRenderObservable
  28338. */
  28339. onBeforeRender: (effect: Effect) => void;
  28340. /**
  28341. * An event triggered after rendering the postprocess
  28342. */
  28343. onAfterRenderObservable: Observable<Effect>;
  28344. private _onAfterRenderObserver;
  28345. /**
  28346. * A function that is added to the onAfterRenderObservable
  28347. */
  28348. onAfterRender: (efect: Effect) => void;
  28349. /**
  28350. * 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
  28351. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28352. */
  28353. inputTexture: InternalTexture;
  28354. /**
  28355. * Gets the camera which post process is applied to.
  28356. * @returns The camera the post process is applied to.
  28357. */
  28358. getCamera(): Camera;
  28359. /**
  28360. * Gets the texel size of the postprocess.
  28361. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28362. */
  28363. readonly texelSize: Vector2;
  28364. /**
  28365. * Creates a new instance PostProcess
  28366. * @param name The name of the PostProcess.
  28367. * @param fragmentUrl The url of the fragment shader to be used.
  28368. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28369. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28370. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28371. * @param camera The camera to apply the render pass to.
  28372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28373. * @param engine The engine which the post process will be applied. (default: current engine)
  28374. * @param reusable If the post process can be reused on the same frame. (default: false)
  28375. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28376. * @param textureType Type of textures used when performing the post process. (default: 0)
  28377. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28378. * @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
  28379. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28380. */
  28381. constructor(
  28382. /** Name of the PostProcess. */
  28383. 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);
  28384. /**
  28385. * Gets the engine which this post process belongs to.
  28386. * @returns The engine the post process was enabled with.
  28387. */
  28388. getEngine(): Engine;
  28389. /**
  28390. * The effect that is created when initializing the post process.
  28391. * @returns The created effect corrisponding the the postprocess.
  28392. */
  28393. getEffect(): Effect;
  28394. /**
  28395. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28396. * @param postProcess The post process to share the output with.
  28397. * @returns This post process.
  28398. */
  28399. shareOutputWith(postProcess: PostProcess): PostProcess;
  28400. /**
  28401. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28402. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28403. */
  28404. useOwnOutput(): void;
  28405. /**
  28406. * Updates the effect with the current post process compile time values and recompiles the shader.
  28407. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28408. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28409. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28410. * @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
  28411. * @param onCompiled Called when the shader has been compiled.
  28412. * @param onError Called if there is an error when compiling a shader.
  28413. */
  28414. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28415. /**
  28416. * The post process is reusable if it can be used multiple times within one frame.
  28417. * @returns If the post process is reusable
  28418. */
  28419. isReusable(): boolean;
  28420. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28421. markTextureDirty(): void;
  28422. /**
  28423. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28424. * 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.
  28425. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28426. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28427. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28428. * @returns The target texture that was bound to be written to.
  28429. */
  28430. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28431. /**
  28432. * If the post process is supported.
  28433. */
  28434. readonly isSupported: boolean;
  28435. /**
  28436. * The aspect ratio of the output texture.
  28437. */
  28438. readonly aspectRatio: number;
  28439. /**
  28440. * Get a value indicating if the post-process is ready to be used
  28441. * @returns true if the post-process is ready (shader is compiled)
  28442. */
  28443. isReady(): boolean;
  28444. /**
  28445. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28446. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28447. */
  28448. apply(): Nullable<Effect>;
  28449. private _disposeTextures;
  28450. /**
  28451. * Disposes the post process.
  28452. * @param camera The camera to dispose the post process on.
  28453. */
  28454. dispose(camera?: Camera): void;
  28455. }
  28456. }
  28457. declare module BABYLON {
  28458. /**
  28459. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28460. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28461. */
  28462. class PostProcessManager {
  28463. private _scene;
  28464. private _indexBuffer;
  28465. private _vertexBuffers;
  28466. /**
  28467. * Creates a new instance PostProcess
  28468. * @param scene The scene that the post process is associated with.
  28469. */
  28470. constructor(scene: Scene);
  28471. private _prepareBuffers;
  28472. private _buildIndexBuffer;
  28473. /**
  28474. * Rebuilds the vertex buffers of the manager.
  28475. * @hidden
  28476. */
  28477. _rebuild(): void;
  28478. /**
  28479. * Prepares a frame to be run through a post process.
  28480. * @param sourceTexture The input texture to the post procesess. (default: null)
  28481. * @param postProcesses An array of post processes to be run. (default: null)
  28482. * @returns True if the post processes were able to be run.
  28483. * @hidden
  28484. */
  28485. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28486. /**
  28487. * Manually render a set of post processes to a texture.
  28488. * @param postProcesses An array of post processes to be run.
  28489. * @param targetTexture The target texture to render to.
  28490. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28491. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28492. * @param lodLevel defines which lod of the texture to render to
  28493. */
  28494. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28495. /**
  28496. * Finalize the result of the output of the postprocesses.
  28497. * @param doNotPresent If true the result will not be displayed to the screen.
  28498. * @param targetTexture The target texture to render to.
  28499. * @param faceIndex The index of the face to bind the target texture to.
  28500. * @param postProcesses The array of post processes to render.
  28501. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28502. * @hidden
  28503. */
  28504. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28505. /**
  28506. * Disposes of the post process manager.
  28507. */
  28508. dispose(): void;
  28509. }
  28510. }
  28511. declare module BABYLON {
  28512. class RefractionPostProcess extends PostProcess {
  28513. color: Color3;
  28514. depth: number;
  28515. colorLevel: number;
  28516. private _refTexture;
  28517. private _ownRefractionTexture;
  28518. /**
  28519. * Gets or sets the refraction texture
  28520. * Please note that you are responsible for disposing the texture if you set it manually
  28521. */
  28522. refractionTexture: Texture;
  28523. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28524. dispose(camera: Camera): void;
  28525. }
  28526. }
  28527. declare module BABYLON {
  28528. /**
  28529. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28530. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28531. */
  28532. class SharpenPostProcess extends PostProcess {
  28533. /**
  28534. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28535. */
  28536. colorAmount: number;
  28537. /**
  28538. * How much sharpness should be applied (default: 0.3)
  28539. */
  28540. edgeAmount: number;
  28541. /**
  28542. * Creates a new instance ConvolutionPostProcess
  28543. * @param name The name of the effect.
  28544. * @param options The required width/height ratio to downsize to before computing the render pass.
  28545. * @param camera The camera to apply the render pass to.
  28546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28547. * @param engine The engine which the post process will be applied. (default: current engine)
  28548. * @param reusable If the post process can be reused on the same frame. (default: false)
  28549. * @param textureType Type of textures used when performing the post process. (default: 0)
  28550. * @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)
  28551. */
  28552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28553. }
  28554. }
  28555. declare module BABYLON {
  28556. class StereoscopicInterlacePostProcess extends PostProcess {
  28557. private _stepSize;
  28558. private _passedProcess;
  28559. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28560. }
  28561. }
  28562. declare module BABYLON {
  28563. /** Defines operator used for tonemapping */
  28564. enum TonemappingOperator {
  28565. /** Hable */
  28566. Hable = 0,
  28567. /** Reinhard */
  28568. Reinhard = 1,
  28569. /** HejiDawson */
  28570. HejiDawson = 2,
  28571. /** Photographic */
  28572. Photographic = 3
  28573. }
  28574. /**
  28575. * Defines a post process to apply tone mapping
  28576. */
  28577. class TonemapPostProcess extends PostProcess {
  28578. private _operator;
  28579. /** Defines the required exposure adjustement */
  28580. exposureAdjustment: number;
  28581. /**
  28582. * Creates a new TonemapPostProcess
  28583. * @param name defines the name of the postprocess
  28584. * @param _operator defines the operator to use
  28585. * @param exposureAdjustment defines the required exposure adjustement
  28586. * @param camera defines the camera to use (can be null)
  28587. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28588. * @param engine defines the hosting engine (can be ignore if camera is set)
  28589. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28590. */
  28591. constructor(name: string, _operator: TonemappingOperator,
  28592. /** Defines the required exposure adjustement */
  28593. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28594. }
  28595. }
  28596. declare module BABYLON {
  28597. class VolumetricLightScatteringPostProcess extends PostProcess {
  28598. private _volumetricLightScatteringPass;
  28599. private _volumetricLightScatteringRTT;
  28600. private _viewPort;
  28601. private _screenCoordinates;
  28602. private _cachedDefines;
  28603. /**
  28604. * If not undefined, the mesh position is computed from the attached node position
  28605. */
  28606. attachedNode: {
  28607. position: Vector3;
  28608. };
  28609. /**
  28610. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28611. */
  28612. customMeshPosition: Vector3;
  28613. /**
  28614. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28615. */
  28616. useCustomMeshPosition: boolean;
  28617. /**
  28618. * If the post-process should inverse the light scattering direction
  28619. */
  28620. invert: boolean;
  28621. /**
  28622. * The internal mesh used by the post-process
  28623. */
  28624. mesh: Mesh;
  28625. useDiffuseColor: boolean;
  28626. /**
  28627. * Array containing the excluded meshes not rendered in the internal pass
  28628. */
  28629. excludedMeshes: AbstractMesh[];
  28630. /**
  28631. * Controls the overall intensity of the post-process
  28632. */
  28633. exposure: number;
  28634. /**
  28635. * Dissipates each sample's contribution in range [0, 1]
  28636. */
  28637. decay: number;
  28638. /**
  28639. * Controls the overall intensity of each sample
  28640. */
  28641. weight: number;
  28642. /**
  28643. * Controls the density of each sample
  28644. */
  28645. density: number;
  28646. /**
  28647. * @constructor
  28648. * @param {string} name - The post-process name
  28649. * @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)
  28650. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28651. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28652. * @param {number} samples - The post-process quality, default 100
  28653. * @param {number} samplingMode - The post-process filtering mode
  28654. * @param {BABYLON.Engine} engine - The babylon engine
  28655. * @param {boolean} reusable - If the post-process is reusable
  28656. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28657. */
  28658. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28659. getClassName(): string;
  28660. private _isReady;
  28661. /**
  28662. * Sets the new light position for light scattering effect
  28663. * @param {BABYLON.Vector3} The new custom light position
  28664. */
  28665. setCustomMeshPosition(position: Vector3): void;
  28666. /**
  28667. * Returns the light position for light scattering effect
  28668. * @return {BABYLON.Vector3} The custom light position
  28669. */
  28670. getCustomMeshPosition(): Vector3;
  28671. /**
  28672. * Disposes the internal assets and detaches the post-process from the camera
  28673. */
  28674. dispose(camera: Camera): void;
  28675. /**
  28676. * Returns the render target texture used by the post-process
  28677. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28678. */
  28679. getPass(): RenderTargetTexture;
  28680. private _meshExcluded;
  28681. private _createPass;
  28682. private _updateMeshScreenCoordinates;
  28683. /**
  28684. * Creates a default mesh for the Volumeric Light Scattering post-process
  28685. * @param {string} The mesh name
  28686. * @param {BABYLON.Scene} The scene where to create the mesh
  28687. * @return {BABYLON.Mesh} the default mesh
  28688. */
  28689. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28690. }
  28691. }
  28692. declare module BABYLON {
  28693. class VRDistortionCorrectionPostProcess extends PostProcess {
  28694. private _isRightEye;
  28695. private _distortionFactors;
  28696. private _postProcessScaleFactor;
  28697. private _lensCenterOffset;
  28698. private _scaleIn;
  28699. private _scaleFactor;
  28700. private _lensCenter;
  28701. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. class Sprite {
  28706. name: string;
  28707. position: Vector3;
  28708. color: Color4;
  28709. width: number;
  28710. height: number;
  28711. angle: number;
  28712. cellIndex: number;
  28713. invertU: number;
  28714. invertV: number;
  28715. disposeWhenFinishedAnimating: boolean;
  28716. animations: Animation[];
  28717. isPickable: boolean;
  28718. actionManager: ActionManager;
  28719. private _animationStarted;
  28720. private _loopAnimation;
  28721. private _fromIndex;
  28722. private _toIndex;
  28723. private _delay;
  28724. private _direction;
  28725. private _manager;
  28726. private _time;
  28727. private _onAnimationEnd;
  28728. /**
  28729. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28730. */
  28731. isVisible: boolean;
  28732. size: number;
  28733. constructor(name: string, manager: ISpriteManager);
  28734. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28735. stopAnimation(): void;
  28736. /** @hidden */
  28737. _animate(deltaTime: number): void;
  28738. dispose(): void;
  28739. }
  28740. }
  28741. declare module BABYLON {
  28742. /**
  28743. * Defines the minimum interface to fullfil in order to be a sprite manager.
  28744. */
  28745. interface ISpriteManager extends IDisposable {
  28746. /**
  28747. * Restricts the camera to viewing objects with the same layerMask.
  28748. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  28749. */
  28750. layerMask: number;
  28751. /**
  28752. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28753. */
  28754. isPickable: boolean;
  28755. /**
  28756. * Specifies the rendering group id for this mesh (0 by default)
  28757. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28758. */
  28759. renderingGroupId: number;
  28760. /**
  28761. * Defines the list of sprites managed by the manager.
  28762. */
  28763. sprites: Array<Sprite>;
  28764. /**
  28765. * Tests the intersection of a sprite with a specific ray.
  28766. * @param ray The ray we are sending to test the collision
  28767. * @param camera The camera space we are sending rays in
  28768. * @param predicate A predicate allowing excluding sprites from the list of object to test
  28769. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  28770. * @returns picking info or null.
  28771. */
  28772. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28773. /**
  28774. * Renders the list of sprites on screen.
  28775. */
  28776. render(): void;
  28777. }
  28778. class SpriteManager implements ISpriteManager {
  28779. name: string;
  28780. sprites: Sprite[];
  28781. renderingGroupId: number;
  28782. layerMask: number;
  28783. fogEnabled: boolean;
  28784. isPickable: boolean;
  28785. cellWidth: number;
  28786. cellHeight: number;
  28787. /**
  28788. * An event triggered when the manager is disposed.
  28789. */
  28790. onDisposeObservable: Observable<SpriteManager>;
  28791. private _onDisposeObserver;
  28792. onDispose: () => void;
  28793. private _capacity;
  28794. private _spriteTexture;
  28795. private _epsilon;
  28796. private _scene;
  28797. private _vertexData;
  28798. private _buffer;
  28799. private _vertexBuffers;
  28800. private _indexBuffer;
  28801. private _effectBase;
  28802. private _effectFog;
  28803. texture: Texture;
  28804. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  28805. private _appendSpriteVertex;
  28806. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28807. render(): void;
  28808. dispose(): void;
  28809. }
  28810. }
  28811. declare module BABYLON {
  28812. interface Scene {
  28813. /** @hidden */
  28814. _pointerOverSprite: Nullable<Sprite>;
  28815. /** @hidden */
  28816. _pickedDownSprite: Nullable<Sprite>;
  28817. /** @hidden */
  28818. _tempSpritePickingRay: Nullable<Ray>;
  28819. /**
  28820. * All of the sprite managers added to this scene
  28821. * @see http://doc.babylonjs.com/babylon101/sprites
  28822. */
  28823. spriteManagers: Array<ISpriteManager>;
  28824. /**
  28825. * An event triggered when sprites rendering is about to start
  28826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  28827. */
  28828. onBeforeSpritesRenderingObservable: Observable<Scene>;
  28829. /**
  28830. * An event triggered when sprites rendering is done
  28831. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  28832. */
  28833. onAfterSpritesRenderingObservable: Observable<Scene>;
  28834. /** @hidden */
  28835. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  28836. /** Launch a ray to try to pick a sprite in the scene
  28837. * @param x position on screen
  28838. * @param y position on screen
  28839. * @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
  28840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  28841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  28842. * @returns a PickingInfo
  28843. */
  28844. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  28845. /** Use the given ray to pick a sprite in the scene
  28846. * @param ray The ray (in world space) to use to pick meshes
  28847. * @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
  28848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  28849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  28850. * @returns a PickingInfo
  28851. */
  28852. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  28853. /**
  28854. * Force the sprite under the pointer
  28855. * @param sprite defines the sprite to use
  28856. */
  28857. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  28858. /**
  28859. * Gets the sprite under the pointer
  28860. * @returns a Sprite or null if no sprite is under the pointer
  28861. */
  28862. getPointerOverSprite(): Nullable<Sprite>;
  28863. }
  28864. /**
  28865. * Defines the sprite scene component responsible to manage sprites
  28866. * in a given scene.
  28867. */
  28868. class SpriteSceneComponent implements ISceneComponent {
  28869. /**
  28870. * The component name helpfull to identify the component in the list of scene components.
  28871. */
  28872. readonly name: string;
  28873. /**
  28874. * The scene the component belongs to.
  28875. */
  28876. scene: Scene;
  28877. /** @hidden */
  28878. private _spritePredicate;
  28879. /**
  28880. * Creates a new instance of the component for the given scene
  28881. * @param scene Defines the scene to register the component in
  28882. */
  28883. constructor(scene: Scene);
  28884. /**
  28885. * Registers the component in a given scene
  28886. */
  28887. register(): void;
  28888. /**
  28889. * Rebuilds the elements related to this component in case of
  28890. * context lost for instance.
  28891. */
  28892. rebuild(): void;
  28893. /**
  28894. * Disposes the component and the associated ressources.
  28895. */
  28896. dispose(): void;
  28897. private _pickSpriteButKeepRay;
  28898. private _pointerMove;
  28899. private _pointerDown;
  28900. private _pointerUp;
  28901. }
  28902. }
  28903. declare module BABYLON {
  28904. interface Scene {
  28905. /** @hidden (Backing field) */
  28906. _boundingBoxRenderer: BoundingBoxRenderer;
  28907. /** @hidden (Backing field) */
  28908. _forceShowBoundingBoxes: boolean;
  28909. /**
  28910. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28911. */
  28912. forceShowBoundingBoxes: boolean;
  28913. /**
  28914. * Gets the bounding box renderer associated with the scene
  28915. * @returns a BoundingBoxRenderer
  28916. */
  28917. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28918. }
  28919. interface AbstractMesh {
  28920. /** @hidden (Backing field) */
  28921. _showBoundingBox: boolean;
  28922. /**
  28923. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28924. */
  28925. showBoundingBox: boolean;
  28926. }
  28927. class BoundingBoxRenderer implements ISceneComponent {
  28928. /**
  28929. * The component name helpfull to identify the component in the list of scene components.
  28930. */
  28931. readonly name: string;
  28932. /**
  28933. * The scene the component belongs to.
  28934. */
  28935. scene: Scene;
  28936. frontColor: Color3;
  28937. backColor: Color3;
  28938. showBackLines: boolean;
  28939. renderList: SmartArray<BoundingBox>;
  28940. private _colorShader;
  28941. private _vertexBuffers;
  28942. private _indexBuffer;
  28943. constructor(scene: Scene);
  28944. /**
  28945. * Registers the component in a given scene
  28946. */
  28947. register(): void;
  28948. private _evaluateSubMesh;
  28949. private _activeMesh;
  28950. private _prepareRessources;
  28951. private _createIndexBuffer;
  28952. /**
  28953. * Rebuilds the elements related to this component in case of
  28954. * context lost for instance.
  28955. */
  28956. rebuild(): void;
  28957. reset(): void;
  28958. render(): void;
  28959. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28960. dispose(): void;
  28961. }
  28962. }
  28963. declare module BABYLON {
  28964. /**
  28965. * This represents a depth renderer in Babylon.
  28966. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28967. */
  28968. class DepthRenderer {
  28969. private _scene;
  28970. private _depthMap;
  28971. private _effect;
  28972. private _cachedDefines;
  28973. private _camera;
  28974. /**
  28975. * Instantiates a depth renderer
  28976. * @param scene The scene the renderer belongs to
  28977. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28978. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28979. */
  28980. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28981. /**
  28982. * Creates the depth rendering effect and checks if the effect is ready.
  28983. * @param subMesh The submesh to be used to render the depth map of
  28984. * @param useInstances If multiple world instances should be used
  28985. * @returns if the depth renderer is ready to render the depth map
  28986. */
  28987. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28988. /**
  28989. * Gets the texture which the depth map will be written to.
  28990. * @returns The depth map texture
  28991. */
  28992. getDepthMap(): RenderTargetTexture;
  28993. /**
  28994. * Disposes of the depth renderer.
  28995. */
  28996. dispose(): void;
  28997. }
  28998. }
  28999. declare module BABYLON {
  29000. interface Scene {
  29001. /** @hidden (Backing field) */
  29002. _depthRenderer: {
  29003. [id: string]: DepthRenderer;
  29004. };
  29005. /**
  29006. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  29007. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  29008. * @returns the created depth renderer
  29009. */
  29010. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  29011. /**
  29012. * Disables a depth renderer for a given camera
  29013. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  29014. */
  29015. disableDepthRenderer(camera?: Nullable<Camera>): void;
  29016. }
  29017. /**
  29018. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  29019. * in several rendering techniques.
  29020. */
  29021. class DepthRendererSceneComponent implements ISceneComponent {
  29022. /**
  29023. * The component name helpfull to identify the component in the list of scene components.
  29024. */
  29025. readonly name: string;
  29026. /**
  29027. * The scene the component belongs to.
  29028. */
  29029. scene: Scene;
  29030. /**
  29031. * Creates a new instance of the component for the given scene
  29032. * @param scene Defines the scene to register the component in
  29033. */
  29034. constructor(scene: Scene);
  29035. /**
  29036. * Registers the component in a given scene
  29037. */
  29038. register(): void;
  29039. /**
  29040. * Rebuilds the elements related to this component in case of
  29041. * context lost for instance.
  29042. */
  29043. rebuild(): void;
  29044. /**
  29045. * Disposes the component and the associated ressources
  29046. */
  29047. dispose(): void;
  29048. private _gatherRenderTargets;
  29049. }
  29050. }
  29051. declare module BABYLON {
  29052. interface AbstractMesh {
  29053. /**
  29054. * Disables the mesh edge rendering mode
  29055. * @returns the currentAbstractMesh
  29056. */
  29057. disableEdgesRendering(): AbstractMesh;
  29058. /**
  29059. * Enables the edge rendering mode on the mesh.
  29060. * This mode makes the mesh edges visible
  29061. * @param epsilon defines the maximal distance between two angles to detect a face
  29062. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29063. * @returns the currentAbstractMesh
  29064. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29065. */
  29066. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29067. /**
  29068. * Gets the edgesRenderer associated with the mesh
  29069. */
  29070. edgesRenderer: Nullable<EdgesRenderer>;
  29071. }
  29072. interface LinesMesh {
  29073. /**
  29074. * Enables the edge rendering mode on the mesh.
  29075. * This mode makes the mesh edges visible
  29076. * @param epsilon defines the maximal distance between two angles to detect a face
  29077. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29078. * @returns the currentAbstractMesh
  29079. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29080. */
  29081. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29082. }
  29083. /**
  29084. * Defines the minimum contract an Edges renderer should follow.
  29085. */
  29086. interface IEdgesRenderer extends IDisposable {
  29087. /**
  29088. * Gets or sets a boolean indicating if the edgesRenderer is active
  29089. */
  29090. isEnabled: boolean;
  29091. /**
  29092. * Renders the edges of the attached mesh,
  29093. */
  29094. render(): void;
  29095. /**
  29096. * Checks wether or not the edges renderer is ready to render.
  29097. * @return true if ready, otherwise false.
  29098. */
  29099. isReady(): boolean;
  29100. }
  29101. /**
  29102. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29103. */
  29104. class EdgesRenderer implements IEdgesRenderer {
  29105. edgesWidthScalerForOrthographic: number;
  29106. edgesWidthScalerForPerspective: number;
  29107. protected _source: AbstractMesh;
  29108. protected _linesPositions: number[];
  29109. protected _linesNormals: number[];
  29110. protected _linesIndices: number[];
  29111. protected _epsilon: number;
  29112. protected _indicesCount: number;
  29113. protected _lineShader: ShaderMaterial;
  29114. protected _ib: WebGLBuffer;
  29115. protected _buffers: {
  29116. [key: string]: Nullable<VertexBuffer>;
  29117. };
  29118. protected _checkVerticesInsteadOfIndices: boolean;
  29119. private _meshRebuildObserver;
  29120. private _meshDisposeObserver;
  29121. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29122. isEnabled: boolean;
  29123. /**
  29124. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29125. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29126. * @param source Mesh used to create edges
  29127. * @param epsilon sum of angles in adjacency to check for edge
  29128. * @param checkVerticesInsteadOfIndices
  29129. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29130. */
  29131. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  29132. protected _prepareRessources(): void;
  29133. /** @hidden */
  29134. _rebuild(): void;
  29135. /**
  29136. * Releases the required resources for the edges renderer
  29137. */
  29138. dispose(): void;
  29139. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29140. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29141. /**
  29142. * Checks if the pair of p0 and p1 is en edge
  29143. * @param faceIndex
  29144. * @param edge
  29145. * @param faceNormals
  29146. * @param p0
  29147. * @param p1
  29148. * @private
  29149. */
  29150. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29151. /**
  29152. * Generates lines edges from adjacencjes
  29153. * @private
  29154. */
  29155. _generateEdgesLines(): void;
  29156. /**
  29157. * Checks wether or not the edges renderer is ready to render.
  29158. * @return true if ready, otherwise false.
  29159. */
  29160. isReady(): boolean;
  29161. /**
  29162. * Renders the edges of the attached mesh,
  29163. */
  29164. render(): void;
  29165. }
  29166. }
  29167. declare module BABYLON {
  29168. /**
  29169. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  29170. */
  29171. class GeometryBufferRenderer {
  29172. private _scene;
  29173. private _multiRenderTarget;
  29174. private _ratio;
  29175. private _enablePosition;
  29176. protected _effect: Effect;
  29177. protected _cachedDefines: string;
  29178. /**
  29179. * Set the render list (meshes to be rendered) used in the G buffer.
  29180. */
  29181. renderList: Mesh[];
  29182. /**
  29183. * Gets wether or not G buffer are supported by the running hardware.
  29184. * This requires draw buffer supports
  29185. */
  29186. readonly isSupported: boolean;
  29187. /**
  29188. * Gets wether or not position are enabled for the G buffer.
  29189. */
  29190. /**
  29191. * Sets wether or not position are enabled for the G buffer.
  29192. */
  29193. enablePosition: boolean;
  29194. /**
  29195. * Gets the scene associated with the buffer.
  29196. */
  29197. readonly scene: Scene;
  29198. /**
  29199. * Gets the ratio used by the buffer during its creation.
  29200. * How big is the buffer related to the main canvas.
  29201. */
  29202. readonly ratio: number;
  29203. /**
  29204. * Creates a new G Buffer for the scene
  29205. * @param scene The scene the buffer belongs to
  29206. * @param ratio How big is the buffer related to the main canvas.
  29207. */
  29208. constructor(scene: Scene, ratio?: number);
  29209. /**
  29210. * Checks wether everything is ready to render a submesh to the G buffer.
  29211. * @param subMesh the submesh to check readiness for
  29212. * @param useInstances is the mesh drawn using instance or not
  29213. * @returns true if ready otherwise false
  29214. */
  29215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29216. /**
  29217. * Gets the current underlying G Buffer.
  29218. * @returns the buffer
  29219. */
  29220. getGBuffer(): MultiRenderTarget;
  29221. /**
  29222. * Gets the number of samples used to render the buffer (anti aliasing).
  29223. */
  29224. /**
  29225. * Sets the number of samples used to render the buffer (anti aliasing).
  29226. */
  29227. samples: number;
  29228. /**
  29229. * Disposes the renderer and frees up associated resources.
  29230. */
  29231. dispose(): void;
  29232. protected _createRenderTargets(): void;
  29233. }
  29234. }
  29235. declare module BABYLON {
  29236. interface Scene {
  29237. /** @hidden (Backing field) */
  29238. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29239. /**
  29240. * Gets or Sets the current geometry buffer associated to the scene.
  29241. */
  29242. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29243. /**
  29244. * Enables a GeometryBufferRender and associates it with the scene
  29245. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  29246. * @returns the GeometryBufferRenderer
  29247. */
  29248. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  29249. /**
  29250. * Disables the GeometryBufferRender associated with the scene
  29251. */
  29252. disableGeometryBufferRenderer(): void;
  29253. }
  29254. /**
  29255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  29256. * in several rendering techniques.
  29257. */
  29258. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  29259. /**
  29260. * The component name helpfull to identify the component in the list of scene components.
  29261. */
  29262. readonly name: string;
  29263. /**
  29264. * The scene the component belongs to.
  29265. */
  29266. scene: Scene;
  29267. /**
  29268. * Creates a new instance of the component for the given scene
  29269. * @param scene Defines the scene to register the component in
  29270. */
  29271. constructor(scene: Scene);
  29272. /**
  29273. * Registers the component in a given scene
  29274. */
  29275. register(): void;
  29276. /**
  29277. * Rebuilds the elements related to this component in case of
  29278. * context lost for instance.
  29279. */
  29280. rebuild(): void;
  29281. /**
  29282. * Disposes the component and the associated ressources
  29283. */
  29284. dispose(): void;
  29285. private _gatherRenderTargets;
  29286. }
  29287. }
  29288. declare module BABYLON {
  29289. /**
  29290. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29291. */
  29292. class LineEdgesRenderer extends EdgesRenderer {
  29293. /**
  29294. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29295. * @param source LineMesh used to generate edges
  29296. * @param epsilon not important (specified angle for edge detection)
  29297. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29298. */
  29299. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29300. /**
  29301. * Always create the edge since its a line so only important things are p0 and p1
  29302. * @param faceIndex not important for LineMesh
  29303. * @param edge not important for LineMesh
  29304. * @param faceNormals not important for LineMesh
  29305. * @param p0 beginnig of line
  29306. * @param p1 end of line
  29307. */
  29308. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29309. /**
  29310. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29311. */
  29312. _generateEdgesLines(): void;
  29313. }
  29314. }
  29315. declare module BABYLON {
  29316. interface Scene {
  29317. /** @hidden */
  29318. _outlineRenderer: OutlineRenderer;
  29319. /**
  29320. * Gets the outline renderer associated with the scene
  29321. * @returns a OutlineRenderer
  29322. */
  29323. getOutlineRenderer(): OutlineRenderer;
  29324. }
  29325. interface AbstractMesh {
  29326. /** @hidden (Backing field) */
  29327. _renderOutline: boolean;
  29328. /**
  29329. * Gets or sets a boolean indicating if the outline must be rendered as well
  29330. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  29331. */
  29332. renderOutline: boolean;
  29333. /** @hidden (Backing field) */
  29334. _renderOverlay: boolean;
  29335. /**
  29336. * Gets or sets a boolean indicating if the overlay must be rendered as well
  29337. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  29338. */
  29339. renderOverlay: boolean;
  29340. }
  29341. /**
  29342. * This class is responsible to draw bothe outline/overlay of meshes.
  29343. * It should not be used directly but through the available method on mesh.
  29344. */
  29345. class OutlineRenderer implements ISceneComponent {
  29346. /**
  29347. * The name of the component. Each component must have a unique name.
  29348. */
  29349. name: string;
  29350. /**
  29351. * The scene the component belongs to.
  29352. */
  29353. scene: Scene;
  29354. /**
  29355. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  29356. */
  29357. zOffset: number;
  29358. private _engine;
  29359. private _effect;
  29360. private _cachedDefines;
  29361. private _savedDepthWrite;
  29362. /**
  29363. * Instantiates a new outline renderer. (There could be only one per scene).
  29364. * @param scene Defines the scene it belongs to
  29365. */
  29366. constructor(scene: Scene);
  29367. /**
  29368. * Register the component to one instance of a scene.
  29369. */
  29370. register(): void;
  29371. /**
  29372. * Rebuilds the elements related to this component in case of
  29373. * context lost for instance.
  29374. */
  29375. rebuild(): void;
  29376. /**
  29377. * Disposes the component and the associated ressources.
  29378. */
  29379. dispose(): void;
  29380. /**
  29381. * Renders the outline in the canvas.
  29382. * @param subMesh Defines the sumesh to render
  29383. * @param batch Defines the batch of meshes in case of instances
  29384. * @param useOverlay Defines if the rendering is for the overlay or the outline
  29385. */
  29386. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  29387. /**
  29388. * Returns whether or not the outline renderer is ready for a given submesh.
  29389. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  29390. * @param subMesh Defines the submesh to check readyness for
  29391. * @param useInstances Defines wheter wee are trying to render instances or not
  29392. * @returns true if ready otherwise false
  29393. */
  29394. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29395. private _beforeRenderingMesh;
  29396. private _afterRenderingMesh;
  29397. }
  29398. }
  29399. declare module BABYLON {
  29400. class RenderingGroup {
  29401. index: number;
  29402. private _scene;
  29403. private _opaqueSubMeshes;
  29404. private _transparentSubMeshes;
  29405. private _alphaTestSubMeshes;
  29406. private _depthOnlySubMeshes;
  29407. private _particleSystems;
  29408. private _spriteManagers;
  29409. private _opaqueSortCompareFn;
  29410. private _alphaTestSortCompareFn;
  29411. private _transparentSortCompareFn;
  29412. private _renderOpaque;
  29413. private _renderAlphaTest;
  29414. private _renderTransparent;
  29415. private _edgesRenderers;
  29416. onBeforeTransparentRendering: () => void;
  29417. /**
  29418. * Set the opaque sort comparison function.
  29419. * If null the sub meshes will be render in the order they were created
  29420. */
  29421. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29422. /**
  29423. * Set the alpha test sort comparison function.
  29424. * If null the sub meshes will be render in the order they were created
  29425. */
  29426. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29427. /**
  29428. * Set the transparent sort comparison function.
  29429. * If null the sub meshes will be render in the order they were created
  29430. */
  29431. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29432. /**
  29433. * Creates a new rendering group.
  29434. * @param index The rendering group index
  29435. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29436. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29437. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29438. */
  29439. 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>);
  29440. /**
  29441. * Render all the sub meshes contained in the group.
  29442. * @param customRenderFunction Used to override the default render behaviour of the group.
  29443. * @returns true if rendered some submeshes.
  29444. */
  29445. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29446. /**
  29447. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29448. * @param subMeshes The submeshes to render
  29449. */
  29450. private renderOpaqueSorted;
  29451. /**
  29452. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29453. * @param subMeshes The submeshes to render
  29454. */
  29455. private renderAlphaTestSorted;
  29456. /**
  29457. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29458. * @param subMeshes The submeshes to render
  29459. */
  29460. private renderTransparentSorted;
  29461. /**
  29462. * Renders the submeshes in a specified order.
  29463. * @param subMeshes The submeshes to sort before render
  29464. * @param sortCompareFn The comparison function use to sort
  29465. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29466. * @param transparent Specifies to activate blending if true
  29467. */
  29468. private static renderSorted;
  29469. /**
  29470. * Renders the submeshes in the order they were dispatched (no sort applied).
  29471. * @param subMeshes The submeshes to render
  29472. */
  29473. private static renderUnsorted;
  29474. /**
  29475. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29476. * are rendered back to front if in the same alpha index.
  29477. *
  29478. * @param a The first submesh
  29479. * @param b The second submesh
  29480. * @returns The result of the comparison
  29481. */
  29482. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29483. /**
  29484. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29485. * are rendered back to front.
  29486. *
  29487. * @param a The first submesh
  29488. * @param b The second submesh
  29489. * @returns The result of the comparison
  29490. */
  29491. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29492. /**
  29493. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29494. * are rendered front to back (prevent overdraw).
  29495. *
  29496. * @param a The first submesh
  29497. * @param b The second submesh
  29498. * @returns The result of the comparison
  29499. */
  29500. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29501. /**
  29502. * Resets the different lists of submeshes to prepare a new frame.
  29503. */
  29504. prepare(): void;
  29505. dispose(): void;
  29506. /**
  29507. * Inserts the submesh in its correct queue depending on its material.
  29508. * @param subMesh The submesh to dispatch
  29509. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29510. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29511. */
  29512. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29513. dispatchSprites(spriteManager: ISpriteManager): void;
  29514. dispatchParticles(particleSystem: IParticleSystem): void;
  29515. private _renderParticles;
  29516. private _renderSprites;
  29517. }
  29518. }
  29519. declare module BABYLON {
  29520. /**
  29521. * Interface describing the different options available in the rendering manager
  29522. * regarding Auto Clear between groups.
  29523. */
  29524. interface IRenderingManagerAutoClearSetup {
  29525. /**
  29526. * Defines whether or not autoclear is enable.
  29527. */
  29528. autoClear: boolean;
  29529. /**
  29530. * Defines whether or not to autoclear the depth buffer.
  29531. */
  29532. depth: boolean;
  29533. /**
  29534. * Defines whether or not to autoclear the stencil buffer.
  29535. */
  29536. stencil: boolean;
  29537. }
  29538. class RenderingManager {
  29539. /**
  29540. * The max id used for rendering groups (not included)
  29541. */
  29542. static MAX_RENDERINGGROUPS: number;
  29543. /**
  29544. * The min id used for rendering groups (included)
  29545. */
  29546. static MIN_RENDERINGGROUPS: number;
  29547. /**
  29548. * Used to globally prevent autoclearing scenes.
  29549. */
  29550. static AUTOCLEAR: boolean;
  29551. /**
  29552. * @hidden
  29553. */
  29554. _useSceneAutoClearSetup: boolean;
  29555. private _scene;
  29556. private _renderingGroups;
  29557. private _depthStencilBufferAlreadyCleaned;
  29558. private _autoClearDepthStencil;
  29559. private _customOpaqueSortCompareFn;
  29560. private _customAlphaTestSortCompareFn;
  29561. private _customTransparentSortCompareFn;
  29562. private _renderingGroupInfo;
  29563. constructor(scene: Scene);
  29564. private _clearDepthStencilBuffer;
  29565. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29566. reset(): void;
  29567. dispose(): void;
  29568. /**
  29569. * Clear the info related to rendering groups preventing retention points during dispose.
  29570. */
  29571. freeRenderingGroups(): void;
  29572. private _prepareRenderingGroup;
  29573. dispatchSprites(spriteManager: ISpriteManager): void;
  29574. dispatchParticles(particleSystem: IParticleSystem): void;
  29575. /**
  29576. * @param subMesh The submesh to dispatch
  29577. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29578. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29579. */
  29580. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29581. /**
  29582. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29583. * This allowed control for front to back rendering or reversly depending of the special needs.
  29584. *
  29585. * @param renderingGroupId The rendering group id corresponding to its index
  29586. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29587. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29588. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29589. */
  29590. 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;
  29591. /**
  29592. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29593. *
  29594. * @param renderingGroupId The rendering group id corresponding to its index
  29595. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29596. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29597. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29598. */
  29599. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29600. /**
  29601. * Gets the current auto clear configuration for one rendering group of the rendering
  29602. * manager.
  29603. * @param index the rendering group index to get the information for
  29604. * @returns The auto clear setup for the requested rendering group
  29605. */
  29606. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29607. }
  29608. }
  29609. declare module BABYLON {
  29610. /**
  29611. * Renders a layer on top of an existing scene
  29612. */
  29613. class UtilityLayerRenderer implements IDisposable {
  29614. /** the original scene that will be rendered on top of */
  29615. originalScene: Scene;
  29616. private _pointerCaptures;
  29617. private _lastPointerEvents;
  29618. private static _DefaultUtilityLayer;
  29619. private static _DefaultKeepDepthUtilityLayer;
  29620. /**
  29621. * 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)
  29622. */
  29623. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29624. /**
  29625. * 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)
  29626. */
  29627. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29628. /**
  29629. * The scene that is rendered on top of the original scene
  29630. */
  29631. utilityLayerScene: Scene;
  29632. /**
  29633. * If the utility layer should automatically be rendered on top of existing scene
  29634. */
  29635. shouldRender: boolean;
  29636. /**
  29637. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29638. */
  29639. onlyCheckPointerDownEvents: boolean;
  29640. /**
  29641. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29642. */
  29643. processAllEvents: boolean;
  29644. /**
  29645. * Observable raised when the pointer move from the utility layer scene to the main scene
  29646. */
  29647. onPointerOutObservable: Observable<number>;
  29648. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29649. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29650. private _afterRenderObserver;
  29651. private _sceneDisposeObserver;
  29652. private _originalPointerObserver;
  29653. /**
  29654. * Instantiates a UtilityLayerRenderer
  29655. * @param originalScene the original scene that will be rendered on top of
  29656. */
  29657. constructor(
  29658. /** the original scene that will be rendered on top of */
  29659. originalScene: Scene);
  29660. private _notifyObservers;
  29661. /**
  29662. * Renders the utility layers scene on top of the original scene
  29663. */
  29664. render(): void;
  29665. /**
  29666. * Disposes of the renderer
  29667. */
  29668. dispose(): void;
  29669. private _updateCamera;
  29670. }
  29671. }
  29672. declare module BABYLON {
  29673. /**
  29674. * @hidden
  29675. **/
  29676. class _AlphaState {
  29677. private _isAlphaBlendDirty;
  29678. private _isBlendFunctionParametersDirty;
  29679. private _isBlendEquationParametersDirty;
  29680. private _isBlendConstantsDirty;
  29681. private _alphaBlend;
  29682. private _blendFunctionParameters;
  29683. private _blendEquationParameters;
  29684. private _blendConstants;
  29685. /**
  29686. * Initializes the state.
  29687. */
  29688. constructor();
  29689. readonly isDirty: boolean;
  29690. alphaBlend: boolean;
  29691. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29692. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29693. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29694. reset(): void;
  29695. apply(gl: WebGLRenderingContext): void;
  29696. }
  29697. }
  29698. declare module BABYLON {
  29699. /**
  29700. * @hidden
  29701. **/
  29702. class _DepthCullingState {
  29703. private _isDepthTestDirty;
  29704. private _isDepthMaskDirty;
  29705. private _isDepthFuncDirty;
  29706. private _isCullFaceDirty;
  29707. private _isCullDirty;
  29708. private _isZOffsetDirty;
  29709. private _isFrontFaceDirty;
  29710. private _depthTest;
  29711. private _depthMask;
  29712. private _depthFunc;
  29713. private _cull;
  29714. private _cullFace;
  29715. private _zOffset;
  29716. private _frontFace;
  29717. /**
  29718. * Initializes the state.
  29719. */
  29720. constructor();
  29721. readonly isDirty: boolean;
  29722. zOffset: number;
  29723. cullFace: Nullable<number>;
  29724. cull: Nullable<boolean>;
  29725. depthFunc: Nullable<number>;
  29726. depthMask: boolean;
  29727. depthTest: boolean;
  29728. frontFace: Nullable<number>;
  29729. reset(): void;
  29730. apply(gl: WebGLRenderingContext): void;
  29731. }
  29732. }
  29733. declare module BABYLON {
  29734. /**
  29735. * @hidden
  29736. **/
  29737. class _StencilState {
  29738. private _isStencilTestDirty;
  29739. private _isStencilMaskDirty;
  29740. private _isStencilFuncDirty;
  29741. private _isStencilOpDirty;
  29742. private _stencilTest;
  29743. private _stencilMask;
  29744. private _stencilFunc;
  29745. private _stencilFuncRef;
  29746. private _stencilFuncMask;
  29747. private _stencilOpStencilFail;
  29748. private _stencilOpDepthFail;
  29749. private _stencilOpStencilDepthPass;
  29750. readonly isDirty: boolean;
  29751. stencilFunc: number;
  29752. stencilFuncRef: number;
  29753. stencilFuncMask: number;
  29754. stencilOpStencilFail: number;
  29755. stencilOpDepthFail: number;
  29756. stencilOpStencilDepthPass: number;
  29757. stencilMask: number;
  29758. stencilTest: boolean;
  29759. constructor();
  29760. reset(): void;
  29761. apply(gl: WebGLRenderingContext): void;
  29762. }
  29763. }
  29764. declare module BABYLON {
  29765. /**
  29766. * Class used to evalaute queries containing `and` and `or` operators
  29767. */
  29768. class AndOrNotEvaluator {
  29769. /**
  29770. * Evaluate a query
  29771. * @param query defines the query to evaluate
  29772. * @param evaluateCallback defines the callback used to filter result
  29773. * @returns true if the query matches
  29774. */
  29775. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29776. private static _HandleParenthesisContent;
  29777. private static _SimplifyNegation;
  29778. }
  29779. }
  29780. declare module BABYLON {
  29781. /**
  29782. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29783. */
  29784. enum AssetTaskState {
  29785. /**
  29786. * Initialization
  29787. */
  29788. INIT = 0,
  29789. /**
  29790. * Running
  29791. */
  29792. RUNNING = 1,
  29793. /**
  29794. * Done
  29795. */
  29796. DONE = 2,
  29797. /**
  29798. * Error
  29799. */
  29800. ERROR = 3
  29801. }
  29802. /**
  29803. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29804. */
  29805. abstract class AbstractAssetTask {
  29806. /**
  29807. * Task name
  29808. */ name: string;
  29809. /**
  29810. * Callback called when the task is successful
  29811. */
  29812. onSuccess: (task: any) => void;
  29813. /**
  29814. * Callback called when the task is not successful
  29815. */
  29816. onError: (task: any, message?: string, exception?: any) => void;
  29817. /**
  29818. * Creates a new {BABYLON.AssetsManager}
  29819. * @param name defines the name of the task
  29820. */
  29821. constructor(
  29822. /**
  29823. * Task name
  29824. */ name: string);
  29825. private _isCompleted;
  29826. private _taskState;
  29827. private _errorObject;
  29828. /**
  29829. * Get if the task is completed
  29830. */
  29831. readonly isCompleted: boolean;
  29832. /**
  29833. * Gets the current state of the task
  29834. */
  29835. readonly taskState: AssetTaskState;
  29836. /**
  29837. * Gets the current error object (if task is in error)
  29838. */
  29839. readonly errorObject: {
  29840. message?: string;
  29841. exception?: any;
  29842. };
  29843. /**
  29844. * Internal only
  29845. * @hidden
  29846. */
  29847. _setErrorObject(message?: string, exception?: any): void;
  29848. /**
  29849. * Execute the current task
  29850. * @param scene defines the scene where you want your assets to be loaded
  29851. * @param onSuccess is a callback called when the task is successfully executed
  29852. * @param onError is a callback called if an error occurs
  29853. */
  29854. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29855. /**
  29856. * Execute the current task
  29857. * @param scene defines the scene where you want your assets to be loaded
  29858. * @param onSuccess is a callback called when the task is successfully executed
  29859. * @param onError is a callback called if an error occurs
  29860. */
  29861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29862. /**
  29863. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29864. * This can be used with failed tasks that have the reason for failure fixed.
  29865. */
  29866. reset(): void;
  29867. private onErrorCallback;
  29868. private onDoneCallback;
  29869. }
  29870. /**
  29871. * Define the interface used by progress events raised during assets loading
  29872. */
  29873. interface IAssetsProgressEvent {
  29874. /**
  29875. * Defines the number of remaining tasks to process
  29876. */
  29877. remainingCount: number;
  29878. /**
  29879. * Defines the total number of tasks
  29880. */
  29881. totalCount: number;
  29882. /**
  29883. * Defines the task that was just processed
  29884. */
  29885. task: AbstractAssetTask;
  29886. }
  29887. /**
  29888. * Class used to share progress information about assets loading
  29889. */
  29890. class AssetsProgressEvent implements IAssetsProgressEvent {
  29891. /**
  29892. * Defines the number of remaining tasks to process
  29893. */
  29894. remainingCount: number;
  29895. /**
  29896. * Defines the total number of tasks
  29897. */
  29898. totalCount: number;
  29899. /**
  29900. * Defines the task that was just processed
  29901. */
  29902. task: AbstractAssetTask;
  29903. /**
  29904. * Creates a {BABYLON.AssetsProgressEvent}
  29905. * @param remainingCount defines the number of remaining tasks to process
  29906. * @param totalCount defines the total number of tasks
  29907. * @param task defines the task that was just processed
  29908. */
  29909. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29910. }
  29911. /**
  29912. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29913. */
  29914. class MeshAssetTask extends AbstractAssetTask {
  29915. /**
  29916. * Defines the name of the task
  29917. */
  29918. name: string;
  29919. /**
  29920. * Defines the list of mesh's names you want to load
  29921. */
  29922. meshesNames: any;
  29923. /**
  29924. * Defines the root url to use as a base to load your meshes and associated resources
  29925. */
  29926. rootUrl: string;
  29927. /**
  29928. * Defines the filename of the scene to load from
  29929. */
  29930. sceneFilename: string;
  29931. /**
  29932. * Gets the list of loaded meshes
  29933. */
  29934. loadedMeshes: Array<AbstractMesh>;
  29935. /**
  29936. * Gets the list of loaded particle systems
  29937. */
  29938. loadedParticleSystems: Array<IParticleSystem>;
  29939. /**
  29940. * Gets the list of loaded skeletons
  29941. */
  29942. loadedSkeletons: Array<Skeleton>;
  29943. /**
  29944. * Callback called when the task is successful
  29945. */
  29946. onSuccess: (task: MeshAssetTask) => void;
  29947. /**
  29948. * Callback called when the task is successful
  29949. */
  29950. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29951. /**
  29952. * Creates a new {BABYLON.MeshAssetTask}
  29953. * @param name defines the name of the task
  29954. * @param meshesNames defines the list of mesh's names you want to load
  29955. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29956. * @param sceneFilename defines the filename of the scene to load from
  29957. */
  29958. constructor(
  29959. /**
  29960. * Defines the name of the task
  29961. */
  29962. name: string,
  29963. /**
  29964. * Defines the list of mesh's names you want to load
  29965. */
  29966. meshesNames: any,
  29967. /**
  29968. * Defines the root url to use as a base to load your meshes and associated resources
  29969. */
  29970. rootUrl: string,
  29971. /**
  29972. * Defines the filename of the scene to load from
  29973. */
  29974. sceneFilename: string);
  29975. /**
  29976. * Execute the current task
  29977. * @param scene defines the scene where you want your assets to be loaded
  29978. * @param onSuccess is a callback called when the task is successfully executed
  29979. * @param onError is a callback called if an error occurs
  29980. */
  29981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29982. }
  29983. /**
  29984. * Define a task used by {BABYLON.AssetsManager} to load text content
  29985. */
  29986. class TextFileAssetTask extends AbstractAssetTask {
  29987. /**
  29988. * Defines the name of the task
  29989. */
  29990. name: string;
  29991. /**
  29992. * Defines the location of the file to load
  29993. */
  29994. url: string;
  29995. /**
  29996. * Gets the loaded text string
  29997. */
  29998. text: string;
  29999. /**
  30000. * Callback called when the task is successful
  30001. */
  30002. onSuccess: (task: TextFileAssetTask) => void;
  30003. /**
  30004. * Callback called when the task is successful
  30005. */
  30006. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  30007. /**
  30008. * Creates a new TextFileAssetTask object
  30009. * @param name defines the name of the task
  30010. * @param url defines the location of the file to load
  30011. */
  30012. constructor(
  30013. /**
  30014. * Defines the name of the task
  30015. */
  30016. name: string,
  30017. /**
  30018. * Defines the location of the file to load
  30019. */
  30020. url: string);
  30021. /**
  30022. * Execute the current task
  30023. * @param scene defines the scene where you want your assets to be loaded
  30024. * @param onSuccess is a callback called when the task is successfully executed
  30025. * @param onError is a callback called if an error occurs
  30026. */
  30027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30028. }
  30029. /**
  30030. * Define a task used by {BABYLON.AssetsManager} to load binary data
  30031. */
  30032. class BinaryFileAssetTask extends AbstractAssetTask {
  30033. /**
  30034. * Defines the name of the task
  30035. */
  30036. name: string;
  30037. /**
  30038. * Defines the location of the file to load
  30039. */
  30040. url: string;
  30041. /**
  30042. * Gets the lodaded data (as an array buffer)
  30043. */
  30044. data: ArrayBuffer;
  30045. /**
  30046. * Callback called when the task is successful
  30047. */
  30048. onSuccess: (task: BinaryFileAssetTask) => void;
  30049. /**
  30050. * Callback called when the task is successful
  30051. */
  30052. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  30053. /**
  30054. * Creates a new BinaryFileAssetTask object
  30055. * @param name defines the name of the new task
  30056. * @param url defines the location of the file to load
  30057. */
  30058. constructor(
  30059. /**
  30060. * Defines the name of the task
  30061. */
  30062. name: string,
  30063. /**
  30064. * Defines the location of the file to load
  30065. */
  30066. url: string);
  30067. /**
  30068. * Execute the current task
  30069. * @param scene defines the scene where you want your assets to be loaded
  30070. * @param onSuccess is a callback called when the task is successfully executed
  30071. * @param onError is a callback called if an error occurs
  30072. */
  30073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30074. }
  30075. /**
  30076. * Define a task used by {BABYLON.AssetsManager} to load images
  30077. */
  30078. class ImageAssetTask extends AbstractAssetTask {
  30079. /**
  30080. * Defines the name of the task
  30081. */
  30082. name: string;
  30083. /**
  30084. * Defines the location of the image to load
  30085. */
  30086. url: string;
  30087. /**
  30088. * Gets the loaded images
  30089. */
  30090. image: HTMLImageElement;
  30091. /**
  30092. * Callback called when the task is successful
  30093. */
  30094. onSuccess: (task: ImageAssetTask) => void;
  30095. /**
  30096. * Callback called when the task is successful
  30097. */
  30098. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  30099. /**
  30100. * Creates a new ImageAssetTask
  30101. * @param name defines the name of the task
  30102. * @param url defines the location of the image to load
  30103. */
  30104. constructor(
  30105. /**
  30106. * Defines the name of the task
  30107. */
  30108. name: string,
  30109. /**
  30110. * Defines the location of the image to load
  30111. */
  30112. url: string);
  30113. /**
  30114. * Execute the current task
  30115. * @param scene defines the scene where you want your assets to be loaded
  30116. * @param onSuccess is a callback called when the task is successfully executed
  30117. * @param onError is a callback called if an error occurs
  30118. */
  30119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30120. }
  30121. /**
  30122. * Defines the interface used by texture loading tasks
  30123. */
  30124. interface ITextureAssetTask<TEX extends BaseTexture> {
  30125. /**
  30126. * Gets the loaded texture
  30127. */
  30128. texture: TEX;
  30129. }
  30130. /**
  30131. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  30132. */
  30133. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  30134. /**
  30135. * Defines the name of the task
  30136. */
  30137. name: string;
  30138. /**
  30139. * Defines the location of the file to load
  30140. */
  30141. url: string;
  30142. /**
  30143. * Defines if mipmap should not be generated (default is false)
  30144. */
  30145. noMipmap?: boolean | undefined;
  30146. /**
  30147. * Defines if texture must be inverted on Y axis (default is false)
  30148. */
  30149. invertY?: boolean | undefined;
  30150. /**
  30151. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30152. */
  30153. samplingMode: number;
  30154. /**
  30155. * Gets the loaded texture
  30156. */
  30157. texture: Texture;
  30158. /**
  30159. * Callback called when the task is successful
  30160. */
  30161. onSuccess: (task: TextureAssetTask) => void;
  30162. /**
  30163. * Callback called when the task is successful
  30164. */
  30165. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  30166. /**
  30167. * Creates a new TextureAssetTask object
  30168. * @param name defines the name of the task
  30169. * @param url defines the location of the file to load
  30170. * @param noMipmap defines if mipmap should not be generated (default is false)
  30171. * @param invertY defines if texture must be inverted on Y axis (default is false)
  30172. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30173. */
  30174. constructor(
  30175. /**
  30176. * Defines the name of the task
  30177. */
  30178. name: string,
  30179. /**
  30180. * Defines the location of the file to load
  30181. */
  30182. url: string,
  30183. /**
  30184. * Defines if mipmap should not be generated (default is false)
  30185. */
  30186. noMipmap?: boolean | undefined,
  30187. /**
  30188. * Defines if texture must be inverted on Y axis (default is false)
  30189. */
  30190. invertY?: boolean | undefined,
  30191. /**
  30192. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30193. */
  30194. samplingMode?: number);
  30195. /**
  30196. * Execute the current task
  30197. * @param scene defines the scene where you want your assets to be loaded
  30198. * @param onSuccess is a callback called when the task is successfully executed
  30199. * @param onError is a callback called if an error occurs
  30200. */
  30201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30202. }
  30203. /**
  30204. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  30205. */
  30206. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  30207. /**
  30208. * Defines the name of the task
  30209. */
  30210. name: string;
  30211. /**
  30212. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30213. */
  30214. url: string;
  30215. /**
  30216. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30217. */
  30218. extensions?: string[] | undefined;
  30219. /**
  30220. * Defines if mipmaps should not be generated (default is false)
  30221. */
  30222. noMipmap?: boolean | undefined;
  30223. /**
  30224. * Defines the explicit list of files (undefined by default)
  30225. */
  30226. files?: string[] | undefined;
  30227. /**
  30228. * Gets the loaded texture
  30229. */
  30230. texture: CubeTexture;
  30231. /**
  30232. * Callback called when the task is successful
  30233. */
  30234. onSuccess: (task: CubeTextureAssetTask) => void;
  30235. /**
  30236. * Callback called when the task is successful
  30237. */
  30238. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30239. /**
  30240. * Creates a new CubeTextureAssetTask
  30241. * @param name defines the name of the task
  30242. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30243. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30244. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30245. * @param files defines the explicit list of files (undefined by default)
  30246. */
  30247. constructor(
  30248. /**
  30249. * Defines the name of the task
  30250. */
  30251. name: string,
  30252. /**
  30253. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30254. */
  30255. url: string,
  30256. /**
  30257. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30258. */
  30259. extensions?: string[] | undefined,
  30260. /**
  30261. * Defines if mipmaps should not be generated (default is false)
  30262. */
  30263. noMipmap?: boolean | undefined,
  30264. /**
  30265. * Defines the explicit list of files (undefined by default)
  30266. */
  30267. files?: string[] | undefined);
  30268. /**
  30269. * Execute the current task
  30270. * @param scene defines the scene where you want your assets to be loaded
  30271. * @param onSuccess is a callback called when the task is successfully executed
  30272. * @param onError is a callback called if an error occurs
  30273. */
  30274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30275. }
  30276. /**
  30277. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30278. */
  30279. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30280. /**
  30281. * Defines the name of the task
  30282. */
  30283. name: string;
  30284. /**
  30285. * Defines the location of the file to load
  30286. */
  30287. url: string;
  30288. /**
  30289. * Defines the desired size (the more it increases the longer the generation will be)
  30290. */
  30291. size: number;
  30292. /**
  30293. * Defines if mipmaps should not be generated (default is false)
  30294. */
  30295. noMipmap: boolean;
  30296. /**
  30297. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30298. */
  30299. generateHarmonics: boolean;
  30300. /**
  30301. * 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)
  30302. */
  30303. gammaSpace: boolean;
  30304. /**
  30305. * Internal Use Only
  30306. */
  30307. reserved: boolean;
  30308. /**
  30309. * Gets the loaded texture
  30310. */
  30311. texture: HDRCubeTexture;
  30312. /**
  30313. * Callback called when the task is successful
  30314. */
  30315. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30316. /**
  30317. * Callback called when the task is successful
  30318. */
  30319. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30320. /**
  30321. * Creates a new HDRCubeTextureAssetTask object
  30322. * @param name defines the name of the task
  30323. * @param url defines the location of the file to load
  30324. * @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.
  30325. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30326. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30327. * @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)
  30328. * @param reserved Internal use only
  30329. */
  30330. constructor(
  30331. /**
  30332. * Defines the name of the task
  30333. */
  30334. name: string,
  30335. /**
  30336. * Defines the location of the file to load
  30337. */
  30338. url: string,
  30339. /**
  30340. * Defines the desired size (the more it increases the longer the generation will be)
  30341. */
  30342. size: number,
  30343. /**
  30344. * Defines if mipmaps should not be generated (default is false)
  30345. */
  30346. noMipmap?: boolean,
  30347. /**
  30348. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30349. */
  30350. generateHarmonics?: boolean,
  30351. /**
  30352. * 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)
  30353. */
  30354. gammaSpace?: boolean,
  30355. /**
  30356. * Internal Use Only
  30357. */
  30358. reserved?: boolean);
  30359. /**
  30360. * Execute the current task
  30361. * @param scene defines the scene where you want your assets to be loaded
  30362. * @param onSuccess is a callback called when the task is successfully executed
  30363. * @param onError is a callback called if an error occurs
  30364. */
  30365. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30366. }
  30367. /**
  30368. * This class can be used to easily import assets into a scene
  30369. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30370. */
  30371. class AssetsManager {
  30372. private _scene;
  30373. private _isLoading;
  30374. protected _tasks: AbstractAssetTask[];
  30375. protected _waitingTasksCount: number;
  30376. protected _totalTasksCount: number;
  30377. /**
  30378. * Callback called when all tasks are processed
  30379. */
  30380. onFinish: (tasks: AbstractAssetTask[]) => void;
  30381. /**
  30382. * Callback called when a task is successful
  30383. */
  30384. onTaskSuccess: (task: AbstractAssetTask) => void;
  30385. /**
  30386. * Callback called when a task had an error
  30387. */
  30388. onTaskError: (task: AbstractAssetTask) => void;
  30389. /**
  30390. * Callback called when a task is done (whatever the result is)
  30391. */
  30392. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30393. /**
  30394. * Observable called when all tasks are processed
  30395. */
  30396. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30397. /**
  30398. * Observable called when a task had an error
  30399. */
  30400. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30401. /**
  30402. * Observable called when a task is successful
  30403. */
  30404. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30405. /**
  30406. * Observable called when a task is done (whatever the result is)
  30407. */
  30408. onProgressObservable: Observable<IAssetsProgressEvent>;
  30409. /**
  30410. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30412. */
  30413. useDefaultLoadingScreen: boolean;
  30414. /**
  30415. * Creates a new AssetsManager
  30416. * @param scene defines the scene to work on
  30417. */
  30418. constructor(scene: Scene);
  30419. /**
  30420. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30421. * @param taskName defines the name of the new task
  30422. * @param meshesNames defines the name of meshes to load
  30423. * @param rootUrl defines the root url to use to locate files
  30424. * @param sceneFilename defines the filename of the scene file
  30425. * @returns a new {BABYLON.MeshAssetTask} object
  30426. */
  30427. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  30428. /**
  30429. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  30430. * @param taskName defines the name of the new task
  30431. * @param url defines the url of the file to load
  30432. * @returns a new {BABYLON.TextFileAssetTask} object
  30433. */
  30434. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  30435. /**
  30436. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  30437. * @param taskName defines the name of the new task
  30438. * @param url defines the url of the file to load
  30439. * @returns a new {BABYLON.BinaryFileAssetTask} object
  30440. */
  30441. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  30442. /**
  30443. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  30444. * @param taskName defines the name of the new task
  30445. * @param url defines the url of the file to load
  30446. * @returns a new {BABYLON.ImageAssetTask} object
  30447. */
  30448. addImageTask(taskName: string, url: string): ImageAssetTask;
  30449. /**
  30450. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  30451. * @param taskName defines the name of the new task
  30452. * @param url defines the url of the file to load
  30453. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30454. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  30455. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  30456. * @returns a new {BABYLON.TextureAssetTask} object
  30457. */
  30458. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  30459. /**
  30460. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  30461. * @param taskName defines the name of the new task
  30462. * @param url defines the url of the file to load
  30463. * @param extensions defines the extension to use to load the cube map (can be null)
  30464. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30465. * @param files defines the list of files to load (can be null)
  30466. * @returns a new {BABYLON.CubeTextureAssetTask} object
  30467. */
  30468. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  30469. /**
  30470. *
  30471. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  30472. * @param taskName defines the name of the new task
  30473. * @param url defines the url of the file to load
  30474. * @param size defines the size you want for the cubemap (can be null)
  30475. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30476. * @param generateHarmonics defines if you want to automatically generate (true by default)
  30477. * @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)
  30478. * @param reserved Internal use only
  30479. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30480. */
  30481. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30482. /**
  30483. * Remove a task from the assets manager.
  30484. * @param task the task to remove
  30485. */
  30486. removeTask(task: AbstractAssetTask): void;
  30487. private _decreaseWaitingTasksCount;
  30488. private _runTask;
  30489. /**
  30490. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30491. * @return the current instance of the {BABYLON.AssetsManager}
  30492. */
  30493. reset(): AssetsManager;
  30494. /**
  30495. * Start the loading process
  30496. * @return the current instance of the {BABYLON.AssetsManager}
  30497. */
  30498. load(): AssetsManager;
  30499. }
  30500. }
  30501. declare module BABYLON {
  30502. /**
  30503. * Class used to enable access to IndexedDB
  30504. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30505. */
  30506. class Database {
  30507. private callbackManifestChecked;
  30508. private currentSceneUrl;
  30509. private db;
  30510. private _enableSceneOffline;
  30511. private _enableTexturesOffline;
  30512. private manifestVersionFound;
  30513. private mustUpdateRessources;
  30514. private hasReachedQuota;
  30515. private isSupported;
  30516. private idbFactory;
  30517. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30518. static IsUASupportingBlobStorage: boolean;
  30519. /** Gets a boolean indicating if Database storate is enabled */
  30520. static IDBStorageEnabled: boolean;
  30521. /**
  30522. * Gets a boolean indicating if scene must be saved in the database
  30523. */
  30524. readonly enableSceneOffline: boolean;
  30525. /**
  30526. * Gets a boolean indicating if textures must be saved in the database
  30527. */
  30528. readonly enableTexturesOffline: boolean;
  30529. /**
  30530. * Creates a new Database
  30531. * @param urlToScene defines the url to load the scene
  30532. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30533. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30534. */
  30535. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30536. private static _ParseURL;
  30537. private static _ReturnFullUrlLocation;
  30538. private _checkManifestFile;
  30539. /**
  30540. * Open the database and make it available
  30541. * @param successCallback defines the callback to call on success
  30542. * @param errorCallback defines the callback to call on error
  30543. */
  30544. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30545. /**
  30546. * Loads an image from the database
  30547. * @param url defines the url to load from
  30548. * @param image defines the target DOM image
  30549. */
  30550. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30551. private _loadImageFromDBAsync;
  30552. private _saveImageIntoDBAsync;
  30553. private _checkVersionFromDB;
  30554. private _loadVersionFromDBAsync;
  30555. private _saveVersionIntoDBAsync;
  30556. /**
  30557. * Loads a file from database
  30558. * @param url defines the URL to load from
  30559. * @param sceneLoaded defines a callback to call on success
  30560. * @param progressCallBack defines a callback to call when progress changed
  30561. * @param errorCallback defines a callback to call on error
  30562. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30563. */
  30564. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30565. private _loadFileFromDBAsync;
  30566. private _saveFileIntoDBAsync;
  30567. }
  30568. }
  30569. declare module BABYLON {
  30570. interface DDSInfo {
  30571. width: number;
  30572. height: number;
  30573. mipmapCount: number;
  30574. isFourCC: boolean;
  30575. isRGB: boolean;
  30576. isLuminance: boolean;
  30577. isCube: boolean;
  30578. isCompressed: boolean;
  30579. dxgiFormat: number;
  30580. textureType: number;
  30581. /** Sphericle polynomial created for the dds texture */
  30582. sphericalPolynomial?: SphericalPolynomial;
  30583. }
  30584. class DDSTools {
  30585. static StoreLODInAlphaChannel: boolean;
  30586. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30587. private static _FloatView;
  30588. private static _Int32View;
  30589. private static _ToHalfFloat;
  30590. private static _FromHalfFloat;
  30591. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30592. private static _GetHalfFloatRGBAArrayBuffer;
  30593. private static _GetFloatRGBAArrayBuffer;
  30594. private static _GetFloatAsUIntRGBAArrayBuffer;
  30595. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30596. private static _GetRGBAArrayBuffer;
  30597. private static _ExtractLongWordOrder;
  30598. private static _GetRGBArrayBuffer;
  30599. private static _GetLuminanceArrayBuffer;
  30600. /**
  30601. * Uploads DDS Levels to a Babylon Texture
  30602. * @hidden
  30603. */
  30604. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30605. }
  30606. }
  30607. declare module BABYLON {
  30608. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30609. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30610. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30611. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30612. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30613. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30614. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30615. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30616. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30617. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30618. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30619. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30620. /**
  30621. * Decorator used to define property that can be serialized as reference to a camera
  30622. * @param sourceName defines the name of the property to decorate
  30623. */
  30624. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30625. class SerializationHelper {
  30626. static Serialize<T>(entity: T, serializationObject?: any): any;
  30627. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30628. static Clone<T>(creationFunction: () => T, source: T): T;
  30629. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30630. }
  30631. }
  30632. declare module BABYLON {
  30633. /**
  30634. * Wrapper class for promise with external resolve and reject.
  30635. */
  30636. class Deferred<T> {
  30637. /**
  30638. * The promise associated with this deferred object.
  30639. */
  30640. readonly promise: Promise<T>;
  30641. private _resolve;
  30642. private _reject;
  30643. /**
  30644. * The resolve method of the promise associated with this deferred object.
  30645. */
  30646. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30647. /**
  30648. * The reject method of the promise associated with this deferred object.
  30649. */
  30650. readonly reject: (reason?: any) => void;
  30651. /**
  30652. * Constructor for this deferred object.
  30653. */
  30654. constructor();
  30655. }
  30656. }
  30657. declare module BABYLON {
  30658. /**
  30659. * Raw texture data and descriptor sufficient for WebGL texture upload
  30660. */
  30661. interface EnvironmentTextureInfo {
  30662. /**
  30663. * Version of the environment map
  30664. */
  30665. version: number;
  30666. /**
  30667. * Width of image
  30668. */
  30669. width: number;
  30670. /**
  30671. * Irradiance information stored in the file.
  30672. */
  30673. irradiance: any;
  30674. /**
  30675. * Specular information stored in the file.
  30676. */
  30677. specular: any;
  30678. }
  30679. /**
  30680. * Sets of helpers addressing the serialization and deserialization of environment texture
  30681. * stored in a BabylonJS env file.
  30682. * Those files are usually stored as .env files.
  30683. */
  30684. class EnvironmentTextureTools {
  30685. /**
  30686. * Magic number identifying the env file.
  30687. */
  30688. private static _MagicBytes;
  30689. /**
  30690. * Gets the environment info from an env file.
  30691. * @param data The array buffer containing the .env bytes.
  30692. * @returns the environment file info (the json header) if successfully parsed.
  30693. */
  30694. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30695. /**
  30696. * Creates an environment texture from a loaded cube texture.
  30697. * @param texture defines the cube texture to convert in env file
  30698. * @return a promise containing the environment data if succesfull.
  30699. */
  30700. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30701. /**
  30702. * Creates a JSON representation of the spherical data.
  30703. * @param texture defines the texture containing the polynomials
  30704. * @return the JSON representation of the spherical info
  30705. */
  30706. private static _CreateEnvTextureIrradiance;
  30707. /**
  30708. * Uploads the texture info contained in the env file to the GPU.
  30709. * @param texture defines the internal texture to upload to
  30710. * @param arrayBuffer defines the buffer cotaining the data to load
  30711. * @param info defines the texture info retrieved through the GetEnvInfo method
  30712. * @returns a promise
  30713. */
  30714. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30715. /**
  30716. * Uploads the levels of image data to the GPU.
  30717. * @param texture defines the internal texture to upload to
  30718. * @param imageData defines the array buffer views of image data [mipmap][face]
  30719. * @returns a promise
  30720. */
  30721. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30722. /**
  30723. * Uploads spherical polynomials information to the texture.
  30724. * @param texture defines the texture we are trying to upload the information to
  30725. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30726. */
  30727. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30728. }
  30729. }
  30730. declare module BABYLON {
  30731. class FilesInput {
  30732. static FilesToLoad: {
  30733. [key: string]: File;
  30734. };
  30735. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30736. private _engine;
  30737. private _currentScene;
  30738. private _sceneLoadedCallback;
  30739. private _progressCallback;
  30740. private _additionalRenderLoopLogicCallback;
  30741. private _textureLoadingCallback;
  30742. private _startingProcessingFilesCallback;
  30743. private _onReloadCallback;
  30744. private _errorCallback;
  30745. private _elementToMonitor;
  30746. private _sceneFileToLoad;
  30747. private _filesToLoad;
  30748. 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);
  30749. private _dragEnterHandler;
  30750. private _dragOverHandler;
  30751. private _dropHandler;
  30752. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30753. dispose(): void;
  30754. private renderFunction;
  30755. private drag;
  30756. private drop;
  30757. private _traverseFolder;
  30758. private _processFiles;
  30759. loadFiles(event: any): void;
  30760. private _processReload;
  30761. reload(): void;
  30762. }
  30763. }
  30764. declare module BABYLON {
  30765. /**
  30766. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30767. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30768. */
  30769. class KhronosTextureContainer {
  30770. arrayBuffer: any;
  30771. static HEADER_LEN: number;
  30772. static COMPRESSED_2D: number;
  30773. static COMPRESSED_3D: number;
  30774. static TEX_2D: number;
  30775. static TEX_3D: number;
  30776. glType: number;
  30777. glTypeSize: number;
  30778. glFormat: number;
  30779. glInternalFormat: number;
  30780. glBaseInternalFormat: number;
  30781. pixelWidth: number;
  30782. pixelHeight: number;
  30783. pixelDepth: number;
  30784. numberOfArrayElements: number;
  30785. numberOfFaces: number;
  30786. numberOfMipmapLevels: number;
  30787. bytesOfKeyValueData: number;
  30788. loadType: number;
  30789. /**
  30790. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30791. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30792. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30793. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30794. */
  30795. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30796. switchEndainness(val: number): number;
  30797. /**
  30798. * Uploads KTX content to a Babylon Texture.
  30799. * It is assumed that the texture has already been created & is currently bound
  30800. * @hidden
  30801. */
  30802. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30803. private _upload2DCompressedLevels;
  30804. }
  30805. }
  30806. declare module BABYLON {
  30807. /**
  30808. * A class serves as a medium between the observable and its observers
  30809. */
  30810. class EventState {
  30811. /**
  30812. * Create a new EventState
  30813. * @param mask defines the mask associated with this state
  30814. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30815. * @param target defines the original target of the state
  30816. * @param currentTarget defines the current target of the state
  30817. */
  30818. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30819. /**
  30820. * Initialize the current event state
  30821. * @param mask defines the mask associated with this state
  30822. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30823. * @param target defines the original target of the state
  30824. * @param currentTarget defines the current target of the state
  30825. * @returns the current event state
  30826. */
  30827. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30828. /**
  30829. * An Observer can set this property to true to prevent subsequent observers of being notified
  30830. */
  30831. skipNextObservers: boolean;
  30832. /**
  30833. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30834. */
  30835. mask: number;
  30836. /**
  30837. * The object that originally notified the event
  30838. */
  30839. target?: any;
  30840. /**
  30841. * The current object in the bubbling phase
  30842. */
  30843. currentTarget?: any;
  30844. /**
  30845. * This will be populated with the return value of the last function that was executed.
  30846. * If it is the first function in the callback chain it will be the event data.
  30847. */
  30848. lastReturnValue?: any;
  30849. }
  30850. /**
  30851. * Represent an Observer registered to a given Observable object.
  30852. */
  30853. class Observer<T> {
  30854. /**
  30855. * Defines the callback to call when the observer is notified
  30856. */
  30857. callback: (eventData: T, eventState: EventState) => void;
  30858. /**
  30859. * Defines the mask of the observer (used to filter notifications)
  30860. */
  30861. mask: number;
  30862. /**
  30863. * Defines the current scope used to restore the JS context
  30864. */
  30865. scope: any;
  30866. /** @hidden */
  30867. _willBeUnregistered: boolean;
  30868. /**
  30869. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30870. */
  30871. unregisterOnNextCall: boolean;
  30872. /**
  30873. * Creates a new observer
  30874. * @param callback defines the callback to call when the observer is notified
  30875. * @param mask defines the mask of the observer (used to filter notifications)
  30876. * @param scope defines the current scope used to restore the JS context
  30877. */
  30878. constructor(
  30879. /**
  30880. * Defines the callback to call when the observer is notified
  30881. */
  30882. callback: (eventData: T, eventState: EventState) => void,
  30883. /**
  30884. * Defines the mask of the observer (used to filter notifications)
  30885. */
  30886. mask: number,
  30887. /**
  30888. * Defines the current scope used to restore the JS context
  30889. */
  30890. scope?: any);
  30891. }
  30892. /**
  30893. * Represent a list of observers registered to multiple Observables object.
  30894. */
  30895. class MultiObserver<T> {
  30896. private _observers;
  30897. private _observables;
  30898. /**
  30899. * Release associated resources
  30900. */
  30901. dispose(): void;
  30902. /**
  30903. * Raise a callback when one of the observable will notify
  30904. * @param observables defines a list of observables to watch
  30905. * @param callback defines the callback to call on notification
  30906. * @param mask defines the mask used to filter notifications
  30907. * @param scope defines the current scope used to restore the JS context
  30908. * @returns the new MultiObserver
  30909. */
  30910. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30911. }
  30912. /**
  30913. * The Observable class is a simple implementation of the Observable pattern.
  30914. *
  30915. * 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.
  30916. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30917. * 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).
  30918. * 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.
  30919. */
  30920. class Observable<T> {
  30921. private _observers;
  30922. private _eventState;
  30923. private _onObserverAdded;
  30924. /**
  30925. * Creates a new observable
  30926. * @param onObserverAdded defines a callback to call when a new observer is added
  30927. */
  30928. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30929. /**
  30930. * Create a new Observer with the specified callback
  30931. * @param callback the callback that will be executed for that Observer
  30932. * @param mask the mask used to filter observers
  30933. * @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.
  30934. * @param scope optional scope for the callback to be called from
  30935. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30936. * @returns the new observer created for the callback
  30937. */
  30938. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30939. /**
  30940. * Create a new Observer with the specified callback and unregisters after the next notification
  30941. * @param callback the callback that will be executed for that Observer
  30942. * @returns the new observer created for the callback
  30943. */
  30944. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30945. /**
  30946. * Remove an Observer from the Observable object
  30947. * @param observer the instance of the Observer to remove
  30948. * @returns false if it doesn't belong to this Observable
  30949. */
  30950. remove(observer: Nullable<Observer<T>>): boolean;
  30951. /**
  30952. * Remove a callback from the Observable object
  30953. * @param callback the callback to remove
  30954. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30955. * @returns false if it doesn't belong to this Observable
  30956. */
  30957. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30958. private _deferUnregister;
  30959. private _remove;
  30960. /**
  30961. * Notify all Observers by calling their respective callback with the given data
  30962. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30963. * @param eventData defines the data to send to all observers
  30964. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30965. * @param target defines the original target of the state
  30966. * @param currentTarget defines the current target of the state
  30967. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30968. */
  30969. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30970. /**
  30971. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30972. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30973. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30974. * and it is crucial that all callbacks will be executed.
  30975. * The order of the callbacks is kept, callbacks are not executed parallel.
  30976. *
  30977. * @param eventData The data to be sent to each callback
  30978. * @param mask is used to filter observers defaults to -1
  30979. * @param target defines the callback target (see EventState)
  30980. * @param currentTarget defines he current object in the bubbling phase
  30981. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30982. */
  30983. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30984. /**
  30985. * Notify a specific observer
  30986. * @param observer defines the observer to notify
  30987. * @param eventData defines the data to be sent to each callback
  30988. * @param mask is used to filter observers defaults to -1
  30989. */
  30990. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30991. /**
  30992. * Gets a boolean indicating if the observable has at least one observer
  30993. * @returns true is the Observable has at least one Observer registered
  30994. */
  30995. hasObservers(): boolean;
  30996. /**
  30997. * Clear the list of observers
  30998. */
  30999. clear(): void;
  31000. /**
  31001. * Clone the current observable
  31002. * @returns a new observable
  31003. */
  31004. clone(): Observable<T>;
  31005. /**
  31006. * Does this observable handles observer registered with a given mask
  31007. * @param mask defines the mask to be tested
  31008. * @return whether or not one observer registered with the given mask is handeled
  31009. **/
  31010. hasSpecificMask(mask?: number): boolean;
  31011. }
  31012. }
  31013. declare module BABYLON {
  31014. /**
  31015. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31016. */
  31017. class PerformanceMonitor {
  31018. private _enabled;
  31019. private _rollingFrameTime;
  31020. private _lastFrameTimeMs;
  31021. /**
  31022. * constructor
  31023. * @param frameSampleSize The number of samples required to saturate the sliding window
  31024. */
  31025. constructor(frameSampleSize?: number);
  31026. /**
  31027. * Samples current frame
  31028. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31029. */
  31030. sampleFrame(timeMs?: number): void;
  31031. /**
  31032. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31033. * @return Average frame time in milliseconds
  31034. */
  31035. readonly averageFrameTime: number;
  31036. /**
  31037. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31038. * @return Frame time variance in milliseconds squared
  31039. */
  31040. readonly averageFrameTimeVariance: number;
  31041. /**
  31042. * Returns the frame time of the most recent frame
  31043. * @return Frame time in milliseconds
  31044. */
  31045. readonly instantaneousFrameTime: number;
  31046. /**
  31047. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31048. * @return Framerate in frames per second
  31049. */
  31050. readonly averageFPS: number;
  31051. /**
  31052. * Returns the average framerate in frames per second using the most recent frame time
  31053. * @return Framerate in frames per second
  31054. */
  31055. readonly instantaneousFPS: number;
  31056. /**
  31057. * Returns true if enough samples have been taken to completely fill the sliding window
  31058. * @return true if saturated
  31059. */
  31060. readonly isSaturated: boolean;
  31061. /**
  31062. * Enables contributions to the sliding window sample set
  31063. */
  31064. enable(): void;
  31065. /**
  31066. * Disables contributions to the sliding window sample set
  31067. * Samples will not be interpolated over the disabled period
  31068. */
  31069. disable(): void;
  31070. /**
  31071. * Returns true if sampling is enabled
  31072. * @return true if enabled
  31073. */
  31074. readonly isEnabled: boolean;
  31075. /**
  31076. * Resets performance monitor
  31077. */
  31078. reset(): void;
  31079. }
  31080. /**
  31081. * RollingAverage
  31082. *
  31083. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31084. */
  31085. class RollingAverage {
  31086. /**
  31087. * Current average
  31088. */
  31089. average: number;
  31090. /**
  31091. * Current variance
  31092. */
  31093. variance: number;
  31094. protected _samples: Array<number>;
  31095. protected _sampleCount: number;
  31096. protected _pos: number;
  31097. protected _m2: number;
  31098. /**
  31099. * constructor
  31100. * @param length The number of samples required to saturate the sliding window
  31101. */
  31102. constructor(length: number);
  31103. /**
  31104. * Adds a sample to the sample set
  31105. * @param v The sample value
  31106. */
  31107. add(v: number): void;
  31108. /**
  31109. * Returns previously added values or null if outside of history or outside the sliding window domain
  31110. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31111. * @return Value previously recorded with add() or null if outside of range
  31112. */
  31113. history(i: number): number;
  31114. /**
  31115. * Returns true if enough samples have been taken to completely fill the sliding window
  31116. * @return true if sample-set saturated
  31117. */
  31118. isSaturated(): boolean;
  31119. /**
  31120. * Resets the rolling average (equivalent to 0 samples taken so far)
  31121. */
  31122. reset(): void;
  31123. /**
  31124. * Wraps a value around the sample range boundaries
  31125. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31126. * @return Wrapped position in sample range
  31127. */
  31128. protected _wrapPosition(i: number): number;
  31129. }
  31130. }
  31131. declare module BABYLON {
  31132. /**
  31133. * Helper class that provides a small promise polyfill
  31134. */
  31135. class PromisePolyfill {
  31136. /**
  31137. * Static function used to check if the polyfill is required
  31138. * If this is the case then the function will inject the polyfill to window.Promise
  31139. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31140. */
  31141. static Apply(force?: boolean): void;
  31142. }
  31143. }
  31144. declare module BABYLON {
  31145. /**
  31146. * Defines the root class used to create scene optimization to use with SceneOptimizer
  31147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31148. */
  31149. class SceneOptimization {
  31150. /**
  31151. * Defines the priority of this optimization (0 by default which means first in the list)
  31152. */
  31153. priority: number;
  31154. /**
  31155. * Gets a string describing the action executed by the current optimization
  31156. * @returns description string
  31157. */
  31158. getDescription(): string;
  31159. /**
  31160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31161. * @param scene defines the current scene where to apply this optimization
  31162. * @param optimizer defines the current optimizer
  31163. * @returns true if everything that can be done was applied
  31164. */
  31165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31166. /**
  31167. * Creates the SceneOptimization object
  31168. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31169. * @param desc defines the description associated with the optimization
  31170. */
  31171. constructor(
  31172. /**
  31173. * Defines the priority of this optimization (0 by default which means first in the list)
  31174. */
  31175. priority?: number);
  31176. }
  31177. /**
  31178. * Defines an optimization used to reduce the size of render target textures
  31179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31180. */
  31181. class TextureOptimization extends SceneOptimization {
  31182. /**
  31183. * Defines the priority of this optimization (0 by default which means first in the list)
  31184. */
  31185. priority: number;
  31186. /**
  31187. * 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
  31188. */
  31189. maximumSize: number;
  31190. /**
  31191. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31192. */
  31193. step: number;
  31194. /**
  31195. * Gets a string describing the action executed by the current optimization
  31196. * @returns description string
  31197. */
  31198. getDescription(): string;
  31199. /**
  31200. * Creates the TextureOptimization object
  31201. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31202. * @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
  31203. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31204. */
  31205. constructor(
  31206. /**
  31207. * Defines the priority of this optimization (0 by default which means first in the list)
  31208. */
  31209. priority?: number,
  31210. /**
  31211. * 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
  31212. */
  31213. maximumSize?: number,
  31214. /**
  31215. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31216. */
  31217. step?: number);
  31218. /**
  31219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31220. * @param scene defines the current scene where to apply this optimization
  31221. * @param optimizer defines the current optimizer
  31222. * @returns true if everything that can be done was applied
  31223. */
  31224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31225. }
  31226. /**
  31227. * Defines an optimization used to increase or decrease the rendering resolution
  31228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31229. */
  31230. class HardwareScalingOptimization extends SceneOptimization {
  31231. /**
  31232. * Defines the priority of this optimization (0 by default which means first in the list)
  31233. */
  31234. priority: number;
  31235. /**
  31236. * Defines the maximum scale to use (2 by default)
  31237. */
  31238. maximumScale: number;
  31239. /**
  31240. * Defines the step to use between two passes (0.5 by default)
  31241. */
  31242. step: number;
  31243. private _currentScale;
  31244. private _directionOffset;
  31245. /**
  31246. * Gets a string describing the action executed by the current optimization
  31247. * @return description string
  31248. */
  31249. getDescription(): string;
  31250. /**
  31251. * Creates the HardwareScalingOptimization object
  31252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31253. * @param maximumScale defines the maximum scale to use (2 by default)
  31254. * @param step defines the step to use between two passes (0.5 by default)
  31255. */
  31256. constructor(
  31257. /**
  31258. * Defines the priority of this optimization (0 by default which means first in the list)
  31259. */
  31260. priority?: number,
  31261. /**
  31262. * Defines the maximum scale to use (2 by default)
  31263. */
  31264. maximumScale?: number,
  31265. /**
  31266. * Defines the step to use between two passes (0.5 by default)
  31267. */
  31268. step?: number);
  31269. /**
  31270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31271. * @param scene defines the current scene where to apply this optimization
  31272. * @param optimizer defines the current optimizer
  31273. * @returns true if everything that can be done was applied
  31274. */
  31275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31276. }
  31277. /**
  31278. * Defines an optimization used to remove shadows
  31279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31280. */
  31281. class ShadowsOptimization extends SceneOptimization {
  31282. /**
  31283. * Gets a string describing the action executed by the current optimization
  31284. * @return description string
  31285. */
  31286. getDescription(): string;
  31287. /**
  31288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31289. * @param scene defines the current scene where to apply this optimization
  31290. * @param optimizer defines the current optimizer
  31291. * @returns true if everything that can be done was applied
  31292. */
  31293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31294. }
  31295. /**
  31296. * Defines an optimization used to turn post-processes off
  31297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31298. */
  31299. class PostProcessesOptimization extends SceneOptimization {
  31300. /**
  31301. * Gets a string describing the action executed by the current optimization
  31302. * @return description string
  31303. */
  31304. getDescription(): string;
  31305. /**
  31306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31307. * @param scene defines the current scene where to apply this optimization
  31308. * @param optimizer defines the current optimizer
  31309. * @returns true if everything that can be done was applied
  31310. */
  31311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31312. }
  31313. /**
  31314. * Defines an optimization used to turn lens flares off
  31315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31316. */
  31317. class LensFlaresOptimization extends SceneOptimization {
  31318. /**
  31319. * Gets a string describing the action executed by the current optimization
  31320. * @return description string
  31321. */
  31322. getDescription(): string;
  31323. /**
  31324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31325. * @param scene defines the current scene where to apply this optimization
  31326. * @param optimizer defines the current optimizer
  31327. * @returns true if everything that can be done was applied
  31328. */
  31329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31330. }
  31331. /**
  31332. * Defines an optimization based on user defined callback.
  31333. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31334. */
  31335. class CustomOptimization extends SceneOptimization {
  31336. /**
  31337. * Callback called to apply the custom optimization.
  31338. */
  31339. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  31340. /**
  31341. * Callback called to get custom description
  31342. */
  31343. onGetDescription: () => string;
  31344. /**
  31345. * Gets a string describing the action executed by the current optimization
  31346. * @returns description string
  31347. */
  31348. getDescription(): string;
  31349. /**
  31350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31351. * @param scene defines the current scene where to apply this optimization
  31352. * @param optimizer defines the current optimizer
  31353. * @returns true if everything that can be done was applied
  31354. */
  31355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31356. }
  31357. /**
  31358. * Defines an optimization used to turn particles off
  31359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31360. */
  31361. class ParticlesOptimization extends SceneOptimization {
  31362. /**
  31363. * Gets a string describing the action executed by the current optimization
  31364. * @return description string
  31365. */
  31366. getDescription(): string;
  31367. /**
  31368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31369. * @param scene defines the current scene where to apply this optimization
  31370. * @param optimizer defines the current optimizer
  31371. * @returns true if everything that can be done was applied
  31372. */
  31373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31374. }
  31375. /**
  31376. * Defines an optimization used to turn render targets off
  31377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31378. */
  31379. class RenderTargetsOptimization extends SceneOptimization {
  31380. /**
  31381. * Gets a string describing the action executed by the current optimization
  31382. * @return description string
  31383. */
  31384. getDescription(): string;
  31385. /**
  31386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31387. * @param scene defines the current scene where to apply this optimization
  31388. * @param optimizer defines the current optimizer
  31389. * @returns true if everything that can be done was applied
  31390. */
  31391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31392. }
  31393. /**
  31394. * Defines an optimization used to merge meshes with compatible materials
  31395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31396. */
  31397. class MergeMeshesOptimization extends SceneOptimization {
  31398. private static _UpdateSelectionTree;
  31399. /**
  31400. * Gets or sets a boolean which defines if optimization octree has to be updated
  31401. */
  31402. /**
  31403. * Gets or sets a boolean which defines if optimization octree has to be updated
  31404. */
  31405. static UpdateSelectionTree: boolean;
  31406. /**
  31407. * Gets a string describing the action executed by the current optimization
  31408. * @return description string
  31409. */
  31410. getDescription(): string;
  31411. private _canBeMerged;
  31412. /**
  31413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31414. * @param scene defines the current scene where to apply this optimization
  31415. * @param optimizer defines the current optimizer
  31416. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  31417. * @returns true if everything that can be done was applied
  31418. */
  31419. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  31420. }
  31421. /**
  31422. * Defines a list of options used by SceneOptimizer
  31423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31424. */
  31425. class SceneOptimizerOptions {
  31426. /**
  31427. * Defines the target frame rate to reach (60 by default)
  31428. */
  31429. targetFrameRate: number;
  31430. /**
  31431. * Defines the interval between two checkes (2000ms by default)
  31432. */
  31433. trackerDuration: number;
  31434. /**
  31435. * Gets the list of optimizations to apply
  31436. */
  31437. optimizations: SceneOptimization[];
  31438. /**
  31439. * Creates a new list of options used by SceneOptimizer
  31440. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  31441. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  31442. */
  31443. constructor(
  31444. /**
  31445. * Defines the target frame rate to reach (60 by default)
  31446. */
  31447. targetFrameRate?: number,
  31448. /**
  31449. * Defines the interval between two checkes (2000ms by default)
  31450. */
  31451. trackerDuration?: number);
  31452. /**
  31453. * Add a new optimization
  31454. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  31455. * @returns the current SceneOptimizerOptions
  31456. */
  31457. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  31458. /**
  31459. * Add a new custom optimization
  31460. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  31461. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  31462. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31463. * @returns the current SceneOptimizerOptions
  31464. */
  31465. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  31466. /**
  31467. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  31468. * @param targetFrameRate defines the target frame rate (60 by default)
  31469. * @returns a SceneOptimizerOptions object
  31470. */
  31471. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31472. /**
  31473. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  31474. * @param targetFrameRate defines the target frame rate (60 by default)
  31475. * @returns a SceneOptimizerOptions object
  31476. */
  31477. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31478. /**
  31479. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31480. * @param targetFrameRate defines the target frame rate (60 by default)
  31481. * @returns a SceneOptimizerOptions object
  31482. */
  31483. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31484. }
  31485. /**
  31486. * Class used to run optimizations in order to reach a target frame rate
  31487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31488. */
  31489. class SceneOptimizer implements IDisposable {
  31490. private _isRunning;
  31491. private _options;
  31492. private _scene;
  31493. private _currentPriorityLevel;
  31494. private _targetFrameRate;
  31495. private _trackerDuration;
  31496. private _currentFrameRate;
  31497. private _sceneDisposeObserver;
  31498. private _improvementMode;
  31499. /**
  31500. * Defines an observable called when the optimizer reaches the target frame rate
  31501. */
  31502. onSuccessObservable: Observable<SceneOptimizer>;
  31503. /**
  31504. * Defines an observable called when the optimizer enables an optimization
  31505. */
  31506. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31507. /**
  31508. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31509. */
  31510. onFailureObservable: Observable<SceneOptimizer>;
  31511. /**
  31512. * Gets a boolean indicating if the optimizer is in improvement mode
  31513. */
  31514. readonly isInImprovementMode: boolean;
  31515. /**
  31516. * Gets the current priority level (0 at start)
  31517. */
  31518. readonly currentPriorityLevel: number;
  31519. /**
  31520. * Gets the current frame rate checked by the SceneOptimizer
  31521. */
  31522. readonly currentFrameRate: number;
  31523. /**
  31524. * Gets or sets the current target frame rate (60 by default)
  31525. */
  31526. /**
  31527. * Gets or sets the current target frame rate (60 by default)
  31528. */
  31529. targetFrameRate: number;
  31530. /**
  31531. * Gets or sets the current interval between two checks (every 2000ms by default)
  31532. */
  31533. /**
  31534. * Gets or sets the current interval between two checks (every 2000ms by default)
  31535. */
  31536. trackerDuration: number;
  31537. /**
  31538. * Gets the list of active optimizations
  31539. */
  31540. readonly optimizations: SceneOptimization[];
  31541. /**
  31542. * Creates a new SceneOptimizer
  31543. * @param scene defines the scene to work on
  31544. * @param options defines the options to use with the SceneOptimizer
  31545. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31546. * @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)
  31547. */
  31548. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31549. /**
  31550. * Stops the current optimizer
  31551. */
  31552. stop(): void;
  31553. /**
  31554. * Reset the optimizer to initial step (current priority level = 0)
  31555. */
  31556. reset(): void;
  31557. /**
  31558. * Start the optimizer. By default it will try to reach a specific framerate
  31559. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31560. */
  31561. start(): void;
  31562. private _checkCurrentState;
  31563. /**
  31564. * Release all resources
  31565. */
  31566. dispose(): void;
  31567. /**
  31568. * Helper function to create a SceneOptimizer with one single line of code
  31569. * @param scene defines the scene to work on
  31570. * @param options defines the options to use with the SceneOptimizer
  31571. * @param onSuccess defines a callback to call on success
  31572. * @param onFailure defines a callback to call on failure
  31573. * @returns the new SceneOptimizer object
  31574. */
  31575. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31576. }
  31577. }
  31578. declare module BABYLON {
  31579. class SceneSerializer {
  31580. static ClearCache(): void;
  31581. static Serialize(scene: Scene): any;
  31582. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31583. }
  31584. }
  31585. declare module BABYLON {
  31586. class SmartArray<T> {
  31587. data: Array<T>;
  31588. length: number;
  31589. protected _id: number;
  31590. [index: number]: T;
  31591. constructor(capacity: number);
  31592. push(value: T): void;
  31593. forEach(func: (content: T) => void): void;
  31594. sort(compareFn: (a: T, b: T) => number): void;
  31595. reset(): void;
  31596. dispose(): void;
  31597. concat(array: any): void;
  31598. indexOf(value: T): number;
  31599. contains(value: T): boolean;
  31600. private static _GlobalId;
  31601. }
  31602. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31603. private _duplicateId;
  31604. [index: number]: T;
  31605. push(value: T): void;
  31606. pushNoDuplicate(value: T): boolean;
  31607. reset(): void;
  31608. concatWithNoDuplicate(array: any): void;
  31609. }
  31610. }
  31611. declare module BABYLON {
  31612. /**
  31613. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31614. * The underlying implementation relies on an associative array to ensure the best performances.
  31615. * The value can be anything including 'null' but except 'undefined'
  31616. */
  31617. class StringDictionary<T> {
  31618. /**
  31619. * This will clear this dictionary and copy the content from the 'source' one.
  31620. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31621. * @param source the dictionary to take the content from and copy to this dictionary
  31622. */
  31623. copyFrom(source: StringDictionary<T>): void;
  31624. /**
  31625. * Get a value based from its key
  31626. * @param key the given key to get the matching value from
  31627. * @return the value if found, otherwise undefined is returned
  31628. */
  31629. get(key: string): T | undefined;
  31630. /**
  31631. * Get a value from its key or add it if it doesn't exist.
  31632. * This method will ensure you that a given key/data will be present in the dictionary.
  31633. * @param key the given key to get the matching value from
  31634. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31635. * The factory will only be invoked if there's no data for the given key.
  31636. * @return the value corresponding to the key.
  31637. */
  31638. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31639. /**
  31640. * Get a value from its key if present in the dictionary otherwise add it
  31641. * @param key the key to get the value from
  31642. * @param val if there's no such key/value pair in the dictionary add it with this value
  31643. * @return the value corresponding to the key
  31644. */
  31645. getOrAdd(key: string, val: T): T;
  31646. /**
  31647. * Check if there's a given key in the dictionary
  31648. * @param key the key to check for
  31649. * @return true if the key is present, false otherwise
  31650. */
  31651. contains(key: string): boolean;
  31652. /**
  31653. * Add a new key and its corresponding value
  31654. * @param key the key to add
  31655. * @param value the value corresponding to the key
  31656. * @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
  31657. */
  31658. add(key: string, value: T): boolean;
  31659. set(key: string, value: T): boolean;
  31660. /**
  31661. * Get the element of the given key and remove it from the dictionary
  31662. * @param key
  31663. */
  31664. getAndRemove(key: string): Nullable<T>;
  31665. /**
  31666. * Remove a key/value from the dictionary.
  31667. * @param key the key to remove
  31668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31669. */
  31670. remove(key: string): boolean;
  31671. /**
  31672. * Clear the whole content of the dictionary
  31673. */
  31674. clear(): void;
  31675. readonly count: number;
  31676. /**
  31677. * Execute a callback on each key/val of the dictionary.
  31678. * Note that you can remove any element in this dictionary in the callback implementation
  31679. * @param callback the callback to execute on a given key/value pair
  31680. */
  31681. forEach(callback: (key: string, val: T) => void): void;
  31682. /**
  31683. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31684. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31685. * Note that you can remove any element in this dictionary in the callback implementation
  31686. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31687. */
  31688. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31689. private _count;
  31690. private _data;
  31691. }
  31692. }
  31693. declare module BABYLON {
  31694. class Tags {
  31695. static EnableFor(obj: any): void;
  31696. static DisableFor(obj: any): void;
  31697. static HasTags(obj: any): boolean;
  31698. static GetTags(obj: any, asString?: boolean): any;
  31699. static AddTagsTo(obj: any, tagsString: string): void;
  31700. static _AddTagTo(obj: any, tag: string): void;
  31701. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31702. static _RemoveTagFrom(obj: any, tag: string): void;
  31703. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31704. }
  31705. }
  31706. declare module BABYLON {
  31707. class TextureTools {
  31708. /**
  31709. * Uses the GPU to create a copy texture rescaled at a given size
  31710. * @param texture Texture to copy from
  31711. * @param width Desired width
  31712. * @param height Desired height
  31713. * @return Generated texture
  31714. */
  31715. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31716. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31717. private static _environmentBRDFBase64Texture;
  31718. }
  31719. }
  31720. declare module BABYLON {
  31721. class TGATools {
  31722. private static _TYPE_INDEXED;
  31723. private static _TYPE_RGB;
  31724. private static _TYPE_GREY;
  31725. private static _TYPE_RLE_INDEXED;
  31726. private static _TYPE_RLE_RGB;
  31727. private static _TYPE_RLE_GREY;
  31728. private static _ORIGIN_MASK;
  31729. private static _ORIGIN_SHIFT;
  31730. private static _ORIGIN_BL;
  31731. private static _ORIGIN_BR;
  31732. private static _ORIGIN_UL;
  31733. private static _ORIGIN_UR;
  31734. static GetTGAHeader(data: Uint8Array): any;
  31735. /**
  31736. * Uploads TGA content to a Babylon Texture
  31737. * @hidden
  31738. */
  31739. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31740. 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;
  31741. 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;
  31742. 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;
  31743. 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;
  31744. 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;
  31745. 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;
  31746. }
  31747. }
  31748. declare module BABYLON {
  31749. interface IAnimatable {
  31750. animations: Array<Animation>;
  31751. }
  31752. /** Interface used by value gradients (color, factor, ...) */
  31753. interface IValueGradient {
  31754. /**
  31755. * Gets or sets the gradient value (between 0 and 1)
  31756. */
  31757. gradient: number;
  31758. }
  31759. /** Class used to store color gradient */
  31760. class ColorGradient implements IValueGradient {
  31761. /**
  31762. * Gets or sets the gradient value (between 0 and 1)
  31763. */
  31764. gradient: number;
  31765. /**
  31766. * Gets or sets first associated color
  31767. */
  31768. color1: Color4;
  31769. /**
  31770. * Gets or sets second associated color
  31771. */
  31772. color2?: Color4;
  31773. /**
  31774. * Will get a color picked randomly between color1 and color2.
  31775. * If color2 is undefined then color1 will be used
  31776. * @param result defines the target Color4 to store the result in
  31777. */
  31778. getColorToRef(result: Color4): void;
  31779. }
  31780. /** Class used to store factor gradient */
  31781. class FactorGradient implements IValueGradient {
  31782. /**
  31783. * Gets or sets the gradient value (between 0 and 1)
  31784. */
  31785. gradient: number;
  31786. /**
  31787. * Gets or sets first associated factor
  31788. */
  31789. factor1: number;
  31790. /**
  31791. * Gets or sets second associated factor
  31792. */
  31793. factor2?: number;
  31794. /**
  31795. * Will get a number picked randomly between factor1 and factor2.
  31796. * If factor2 is undefined then factor1 will be used
  31797. * @returns the picked number
  31798. */
  31799. getFactor(): number;
  31800. }
  31801. class LoadFileError extends Error {
  31802. request?: XMLHttpRequest | undefined;
  31803. private static _setPrototypeOf;
  31804. constructor(message: string, request?: XMLHttpRequest | undefined);
  31805. }
  31806. class RetryStrategy {
  31807. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31808. }
  31809. interface IFileRequest {
  31810. /**
  31811. * Raised when the request is complete (success or error).
  31812. */
  31813. onCompleteObservable: Observable<IFileRequest>;
  31814. /**
  31815. * Aborts the request for a file.
  31816. */
  31817. abort: () => void;
  31818. }
  31819. class Tools {
  31820. static BaseUrl: string;
  31821. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31822. /**
  31823. * Default behaviour for cors in the application.
  31824. * It can be a string if the expected behavior is identical in the entire app.
  31825. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31826. */
  31827. static CorsBehavior: string | ((url: string | string[]) => string);
  31828. static UseFallbackTexture: boolean;
  31829. /**
  31830. * Use this object to register external classes like custom textures or material
  31831. * to allow the laoders to instantiate them
  31832. */
  31833. static RegisteredExternalClasses: {
  31834. [key: string]: Object;
  31835. };
  31836. static fallbackTexture: string;
  31837. /**
  31838. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31839. * @param u defines the coordinate on X axis
  31840. * @param v defines the coordinate on Y axis
  31841. * @param width defines the width of the source data
  31842. * @param height defines the height of the source data
  31843. * @param pixels defines the source byte array
  31844. * @param color defines the output color
  31845. */
  31846. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31847. /**
  31848. * Interpolates between a and b via alpha
  31849. * @param a The lower value (returned when alpha = 0)
  31850. * @param b The upper value (returned when alpha = 1)
  31851. * @param alpha The interpolation-factor
  31852. * @return The mixed value
  31853. */
  31854. static Mix(a: number, b: number, alpha: number): number;
  31855. static Instantiate(className: string): any;
  31856. /**
  31857. * Provides a slice function that will work even on IE
  31858. * @param data defines the array to slice
  31859. * @param start defines the start of the data (optional)
  31860. * @param end defines the end of the data (optional)
  31861. * @returns the new sliced array
  31862. */
  31863. static Slice<T>(data: T, start?: number, end?: number): T;
  31864. static SetImmediate(action: () => void): void;
  31865. static IsExponentOfTwo(value: number): boolean;
  31866. private static _tmpFloatArray;
  31867. /**
  31868. * Returns the nearest 32-bit single precision float representation of a Number
  31869. * @param value A Number. If the parameter is of a different type, it will get converted
  31870. * to a number or to NaN if it cannot be converted
  31871. * @returns number
  31872. */
  31873. static FloatRound(value: number): number;
  31874. /**
  31875. * Find the next highest power of two.
  31876. * @param x Number to start search from.
  31877. * @return Next highest power of two.
  31878. */
  31879. static CeilingPOT(x: number): number;
  31880. /**
  31881. * Find the next lowest power of two.
  31882. * @param x Number to start search from.
  31883. * @return Next lowest power of two.
  31884. */
  31885. static FloorPOT(x: number): number;
  31886. /**
  31887. * Find the nearest power of two.
  31888. * @param x Number to start search from.
  31889. * @return Next nearest power of two.
  31890. */
  31891. static NearestPOT(x: number): number;
  31892. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31893. static GetFilename(path: string): string;
  31894. /**
  31895. * Extracts the "folder" part of a path (everything before the filename).
  31896. * @param uri The URI to extract the info from
  31897. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31898. * @returns The "folder" part of the path
  31899. */
  31900. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31901. static GetDOMTextContent(element: HTMLElement): string;
  31902. static ToDegrees(angle: number): number;
  31903. static ToRadians(angle: number): number;
  31904. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31905. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31906. minimum: Vector3;
  31907. maximum: Vector3;
  31908. };
  31909. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31910. minimum: Vector3;
  31911. maximum: Vector3;
  31912. };
  31913. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31914. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31915. minimum: Vector2;
  31916. maximum: Vector2;
  31917. };
  31918. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31919. static GetPointerPrefix(): string;
  31920. /**
  31921. * @param func - the function to be called
  31922. * @param requester - the object that will request the next frame. Falls back to window.
  31923. */
  31924. static QueueNewFrame(func: () => void, requester?: any): number;
  31925. static RequestFullscreen(element: HTMLElement): void;
  31926. static ExitFullscreen(): void;
  31927. static SetCorsBehavior(url: string | string[], element: {
  31928. crossOrigin: string | null;
  31929. }): void;
  31930. static CleanUrl(url: string): string;
  31931. static PreprocessUrl: (url: string) => string;
  31932. /**
  31933. * Loads an image as an HTMLImageElement.
  31934. * @param input url string, ArrayBuffer, or Blob to load
  31935. * @param onLoad callback called when the image successfully loads
  31936. * @param onError callback called when the image fails to load
  31937. * @param database database for caching
  31938. * @returns the HTMLImageElement of the loaded image
  31939. */
  31940. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31941. 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;
  31942. /**
  31943. * Load a script (identified by an url). When the url returns, the
  31944. * content of this file is added into a new script element, attached to the DOM (body element)
  31945. */
  31946. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31947. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31948. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31949. static FileAsURL(content: string): string;
  31950. static Format(value: number, decimals?: number): string;
  31951. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31952. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31953. static IsEmpty(obj: any): boolean;
  31954. static RegisterTopRootEvents(events: {
  31955. name: string;
  31956. handler: Nullable<(e: FocusEvent) => any>;
  31957. }[]): void;
  31958. static UnregisterTopRootEvents(events: {
  31959. name: string;
  31960. handler: Nullable<(e: FocusEvent) => any>;
  31961. }[]): void;
  31962. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31963. /**
  31964. * Converts the canvas data to blob.
  31965. * This acts as a polyfill for browsers not supporting the to blob function.
  31966. * @param canvas Defines the canvas to extract the data from
  31967. * @param successCallback Defines the callback triggered once the data are available
  31968. * @param mimeType Defines the mime type of the result
  31969. */
  31970. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31971. /**
  31972. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31973. * @param successCallback Defines the callback triggered once the data are available
  31974. * @param mimeType Defines the mime type of the result
  31975. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31976. */
  31977. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31978. /**
  31979. * Downloads a blob in the browser
  31980. * @param blob defines the blob to download
  31981. * @param fileName defines the name of the downloaded file
  31982. */
  31983. static Download(blob: Blob, fileName: string): void;
  31984. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31985. /**
  31986. * Generates an image screenshot from the specified camera.
  31987. *
  31988. * @param engine The engine to use for rendering
  31989. * @param camera The camera to use for rendering
  31990. * @param size This parameter can be set to a single number or to an object with the
  31991. * following (optional) properties: precision, width, height. If a single number is passed,
  31992. * it will be used for both width and height. If an object is passed, the screenshot size
  31993. * will be derived from the parameters. The precision property is a multiplier allowing
  31994. * rendering at a higher or lower resolution.
  31995. * @param successCallback The callback receives a single parameter which contains the
  31996. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31997. * src parameter of an <img> to display it.
  31998. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31999. * Check your browser for supported MIME types.
  32000. * @param samples Texture samples (default: 1)
  32001. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32002. * @param fileName A name for for the downloaded file.
  32003. * @constructor
  32004. */
  32005. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32006. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  32007. /**
  32008. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32009. * Be aware Math.random() could cause collisions, but:
  32010. * "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"
  32011. */
  32012. static RandomId(): string;
  32013. /**
  32014. * Test if the given uri is a base64 string.
  32015. * @param uri The uri to test
  32016. * @return True if the uri is a base64 string or false otherwise.
  32017. */
  32018. static IsBase64(uri: string): boolean;
  32019. /**
  32020. * Decode the given base64 uri.
  32021. * @param uri The uri to decode
  32022. * @return The decoded base64 data.
  32023. */
  32024. static DecodeBase64(uri: string): ArrayBuffer;
  32025. private static _NoneLogLevel;
  32026. private static _MessageLogLevel;
  32027. private static _WarningLogLevel;
  32028. private static _ErrorLogLevel;
  32029. private static _LogCache;
  32030. static errorsCount: number;
  32031. static OnNewCacheEntry: (entry: string) => void;
  32032. static readonly NoneLogLevel: number;
  32033. static readonly MessageLogLevel: number;
  32034. static readonly WarningLogLevel: number;
  32035. static readonly ErrorLogLevel: number;
  32036. static readonly AllLogLevel: number;
  32037. private static _AddLogEntry;
  32038. private static _FormatMessage;
  32039. private static _LogDisabled;
  32040. private static _LogEnabled;
  32041. private static _WarnDisabled;
  32042. private static _WarnEnabled;
  32043. private static _ErrorDisabled;
  32044. private static _ErrorEnabled;
  32045. static Log: (message: string) => void;
  32046. static Warn: (message: string) => void;
  32047. static Error: (message: string) => void;
  32048. static readonly LogCache: string;
  32049. static ClearLogCache(): void;
  32050. static LogLevels: number;
  32051. /**
  32052. * Check if the loaded document was accessed via `file:`-Protocol.
  32053. * @returns boolean
  32054. */
  32055. static IsFileURL(): boolean;
  32056. static IsWindowObjectExist(): boolean;
  32057. private static _PerformanceNoneLogLevel;
  32058. private static _PerformanceUserMarkLogLevel;
  32059. private static _PerformanceConsoleLogLevel;
  32060. private static _performance;
  32061. static readonly PerformanceNoneLogLevel: number;
  32062. static readonly PerformanceUserMarkLogLevel: number;
  32063. static readonly PerformanceConsoleLogLevel: number;
  32064. static PerformanceLogLevel: number;
  32065. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32066. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32067. static _StartUserMark(counterName: string, condition?: boolean): void;
  32068. static _EndUserMark(counterName: string, condition?: boolean): void;
  32069. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  32070. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  32071. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32072. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32073. static readonly Now: number;
  32074. /**
  32075. * This method will return the name of the class used to create the instance of the given object.
  32076. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32077. * @param object the object to get the class name from
  32078. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  32079. */
  32080. static GetClassName(object: any, isType?: boolean): string;
  32081. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32082. /**
  32083. * This method will return the name of the full name of the class, including its owning module (if any).
  32084. * 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).
  32085. * @param object the object to get the class name from
  32086. * @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.
  32087. */
  32088. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32089. /**
  32090. * 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.
  32091. * @param array
  32092. */
  32093. static arrayOrStringFeeder(array: any): (i: number) => number;
  32094. /**
  32095. * Compute the hashCode of a stream of number
  32096. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  32097. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  32098. * @return the hash code computed
  32099. */
  32100. static hashCodeFromStream(feeder: (index: number) => number): number;
  32101. /**
  32102. * Returns a promise that resolves after the given amount of time.
  32103. * @param delay Number of milliseconds to delay
  32104. * @returns Promise that resolves after the given amount of time
  32105. */
  32106. static DelayAsync(delay: number): Promise<void>;
  32107. /**
  32108. * Gets the current gradient from an array of IValueGradient
  32109. * @param ratio defines the current ratio to get
  32110. * @param gradients defines the array of IValueGradient
  32111. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32112. */
  32113. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32114. }
  32115. /**
  32116. * This class is used to track a performance counter which is number based.
  32117. * The user has access to many properties which give statistics of different nature
  32118. *
  32119. * The implementer can track two kinds of Performance Counter: time and count
  32120. * 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.
  32121. * 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.
  32122. */
  32123. class PerfCounter {
  32124. static Enabled: boolean;
  32125. /**
  32126. * Returns the smallest value ever
  32127. */
  32128. readonly min: number;
  32129. /**
  32130. * Returns the biggest value ever
  32131. */
  32132. readonly max: number;
  32133. /**
  32134. * Returns the average value since the performance counter is running
  32135. */
  32136. readonly average: number;
  32137. /**
  32138. * Returns the average value of the last second the counter was monitored
  32139. */
  32140. readonly lastSecAverage: number;
  32141. /**
  32142. * Returns the current value
  32143. */
  32144. readonly current: number;
  32145. readonly total: number;
  32146. readonly count: number;
  32147. constructor();
  32148. /**
  32149. * Call this method to start monitoring a new frame.
  32150. * 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.
  32151. */
  32152. fetchNewFrame(): void;
  32153. /**
  32154. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32155. * @param newCount the count value to add to the monitored count
  32156. * @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.
  32157. */
  32158. addCount(newCount: number, fetchResult: boolean): void;
  32159. /**
  32160. * Start monitoring this performance counter
  32161. */
  32162. beginMonitoring(): void;
  32163. /**
  32164. * Compute the time lapsed since the previous beginMonitoring() call.
  32165. * @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
  32166. */
  32167. endMonitoring(newFrame?: boolean): void;
  32168. private _fetchResult;
  32169. private _startMonitoringTime;
  32170. private _min;
  32171. private _max;
  32172. private _average;
  32173. private _current;
  32174. private _totalValueCount;
  32175. private _totalAccumulated;
  32176. private _lastSecAverage;
  32177. private _lastSecAccumulated;
  32178. private _lastSecTime;
  32179. private _lastSecValueCount;
  32180. }
  32181. /**
  32182. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32183. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32184. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32185. * @param name The name of the class, case should be preserved
  32186. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32187. */
  32188. function className(name: string, module?: string): (target: Object) => void;
  32189. /**
  32190. * An implementation of a loop for asynchronous functions.
  32191. */
  32192. class AsyncLoop {
  32193. iterations: number;
  32194. private _fn;
  32195. private _successCallback;
  32196. index: number;
  32197. private _done;
  32198. /**
  32199. * Constroctor.
  32200. * @param iterations the number of iterations.
  32201. * @param _fn the function to run each iteration
  32202. * @param _successCallback the callback that will be called upon succesful execution
  32203. * @param offset starting offset.
  32204. */
  32205. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  32206. /**
  32207. * Execute the next iteration. Must be called after the last iteration was finished.
  32208. */
  32209. executeNext(): void;
  32210. /**
  32211. * Break the loop and run the success callback.
  32212. */
  32213. breakLoop(): void;
  32214. /**
  32215. * Helper function
  32216. */
  32217. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  32218. /**
  32219. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32220. * @param iterations total number of iterations
  32221. * @param syncedIterations number of synchronous iterations in each async iteration.
  32222. * @param fn the function to call each iteration.
  32223. * @param callback a success call back that will be called when iterating stops.
  32224. * @param breakFunction a break condition (optional)
  32225. * @param timeout timeout settings for the setTimeout function. default - 0.
  32226. * @constructor
  32227. */
  32228. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  32229. }
  32230. }
  32231. interface HTMLCanvasElement {
  32232. /** Track wether a record is in progress */
  32233. isRecording: boolean;
  32234. /** Capture Stream method defined by some browsers */
  32235. captureStream(fps?: number): MediaStream;
  32236. }
  32237. interface MediaRecorder {
  32238. /** Starts recording */
  32239. start(timeSlice: number): void;
  32240. /** Stops recording */
  32241. stop(): void;
  32242. /** Event raised when an error arised. */
  32243. onerror: (event: ErrorEvent) => void;
  32244. /** Event raised when the recording stops. */
  32245. onstop: (event: Event) => void;
  32246. /** Event raised when a new chunk of data is available and should be tracked. */
  32247. ondataavailable: (event: Event) => void;
  32248. }
  32249. interface MediaRecorderOptions {
  32250. /** The mime type you want to use as the recording container for the new MediaRecorder */
  32251. mimeType?: string;
  32252. /** The chosen bitrate for the audio component of the media. */
  32253. audioBitsPerSecond?: number;
  32254. /** The chosen bitrate for the video component of the media. */
  32255. videoBitsPerSecond?: number;
  32256. /** 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. */
  32257. bitsPerSecond?: number;
  32258. }
  32259. interface MediaRecorderConstructor {
  32260. /**
  32261. * A reference to the prototype.
  32262. */
  32263. readonly prototype: MediaRecorder;
  32264. /**
  32265. * Creates a new MediaRecorder.
  32266. * @param stream Defines the stream to record.
  32267. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  32268. */
  32269. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  32270. }
  32271. /**
  32272. * MediaRecoreder object available in some browsers.
  32273. */
  32274. declare var MediaRecorder: MediaRecorderConstructor;
  32275. declare module BABYLON {
  32276. /**
  32277. * This represents the different options avilable for the video capture.
  32278. */
  32279. interface VideoRecorderOptions {
  32280. /** Defines the mime type of the video */
  32281. mimeType: string;
  32282. /** Defines the video the video should be recorded at */
  32283. fps: number;
  32284. /** Defines the chunk size for the recording data */
  32285. recordChunckSize: number;
  32286. }
  32287. /**
  32288. * This can helps recording videos from BabylonJS.
  32289. * This is based on the available WebRTC functionalities of the browser.
  32290. *
  32291. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  32292. */
  32293. class VideoRecorder {
  32294. private static readonly _defaultOptions;
  32295. /**
  32296. * Returns wehther or not the VideoRecorder is available in your browser.
  32297. * @param engine Defines the Babylon Engine to check the support for
  32298. * @returns true if supported otherwise false
  32299. */
  32300. static IsSupported(engine: Engine): boolean;
  32301. private readonly _options;
  32302. private _canvas;
  32303. private _mediaRecorder;
  32304. private _recordedChunks;
  32305. private _fileName;
  32306. private _resolve;
  32307. private _reject;
  32308. /**
  32309. * True wether a recording is already in progress.
  32310. */
  32311. readonly isRecording: boolean;
  32312. /**
  32313. * Create a new VideoCapture object which can help converting what you see in Babylon to
  32314. * a video file.
  32315. * @param engine Defines the BabylonJS Engine you wish to record
  32316. * @param options Defines options that can be used to customized the capture
  32317. */
  32318. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  32319. /**
  32320. * Stops the current recording before the default capture timeout passed in the startRecording
  32321. * functions.
  32322. */
  32323. stopRecording(): void;
  32324. /**
  32325. * Starts recording the canvas for a max duration specified in parameters.
  32326. * @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.
  32327. * @param maxDuration Defines the maximum recording time in seconds.
  32328. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  32329. * @return a promise callback at the end of the recording with the video data in Blob.
  32330. */
  32331. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  32332. /**
  32333. * Releases internal resources used during the recording.
  32334. */
  32335. dispose(): void;
  32336. private _handleDataAvailable;
  32337. private _handleError;
  32338. private _handleStop;
  32339. }
  32340. }
  32341. declare module BABYLON {
  32342. /**
  32343. * Defines the potential axis of a Joystick
  32344. */
  32345. enum JoystickAxis {
  32346. /** X axis */
  32347. X = 0,
  32348. /** Y axis */
  32349. Y = 1,
  32350. /** Z axis */
  32351. Z = 2
  32352. }
  32353. /**
  32354. * Class used to define virtual joystick (used in touch mode)
  32355. */
  32356. class VirtualJoystick {
  32357. /**
  32358. * Gets or sets a boolean indicating that left and right values must be inverted
  32359. */
  32360. reverseLeftRight: boolean;
  32361. /**
  32362. * Gets or sets a boolean indicating that up and down values must be inverted
  32363. */
  32364. reverseUpDown: boolean;
  32365. /**
  32366. * Gets the offset value for the position (ie. the change of the position value)
  32367. */
  32368. deltaPosition: Vector3;
  32369. /**
  32370. * Gets a boolean indicating if the virtual joystick was pressed
  32371. */
  32372. pressed: boolean;
  32373. private static _globalJoystickIndex;
  32374. private static vjCanvas;
  32375. private static vjCanvasContext;
  32376. private static vjCanvasWidth;
  32377. private static vjCanvasHeight;
  32378. private static halfWidth;
  32379. private _action;
  32380. private _axisTargetedByLeftAndRight;
  32381. private _axisTargetedByUpAndDown;
  32382. private _joystickSensibility;
  32383. private _inversedSensibility;
  32384. private _joystickPointerID;
  32385. private _joystickColor;
  32386. private _joystickPointerPos;
  32387. private _joystickPreviousPointerPos;
  32388. private _joystickPointerStartPos;
  32389. private _deltaJoystickVector;
  32390. private _leftJoystick;
  32391. private _touches;
  32392. private _onPointerDownHandlerRef;
  32393. private _onPointerMoveHandlerRef;
  32394. private _onPointerUpHandlerRef;
  32395. private _onResize;
  32396. /**
  32397. * Creates a new virtual joystick
  32398. * @param leftJoystick defines that the joystick is for left hand (false by default)
  32399. */
  32400. constructor(leftJoystick?: boolean);
  32401. /**
  32402. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32403. * @param newJoystickSensibility defines the new sensibility
  32404. */
  32405. setJoystickSensibility(newJoystickSensibility: number): void;
  32406. private _onPointerDown;
  32407. private _onPointerMove;
  32408. private _onPointerUp;
  32409. /**
  32410. * Change the color of the virtual joystick
  32411. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32412. */
  32413. setJoystickColor(newColor: string): void;
  32414. /**
  32415. * Defines a callback to call when the joystick is touched
  32416. * @param action defines the callback
  32417. */
  32418. setActionOnTouch(action: () => any): void;
  32419. /**
  32420. * Defines which axis you'd like to control for left & right
  32421. * @param axis defines the axis to use
  32422. */
  32423. setAxisForLeftRight(axis: JoystickAxis): void;
  32424. /**
  32425. * Defines which axis you'd like to control for up & down
  32426. * @param axis defines the axis to use
  32427. */
  32428. setAxisForUpDown(axis: JoystickAxis): void;
  32429. private _drawVirtualJoystick;
  32430. /**
  32431. * Release internal HTML canvas
  32432. */
  32433. releaseCanvas(): void;
  32434. }
  32435. }
  32436. declare module BABYLON {
  32437. /**
  32438. * Helper class to push actions to a pool of workers.
  32439. */
  32440. class WorkerPool implements IDisposable {
  32441. private _workerInfos;
  32442. private _pendingActions;
  32443. /**
  32444. * Constructor
  32445. * @param workers Array of workers to use for actions
  32446. */
  32447. constructor(workers: Array<Worker>);
  32448. /**
  32449. * Terminates all workers and clears any pending actions.
  32450. */
  32451. dispose(): void;
  32452. /**
  32453. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32454. * pended until a worker has completed its action.
  32455. * @param action The action to perform. Call onComplete when the action is complete.
  32456. */
  32457. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32458. private _execute;
  32459. }
  32460. }
  32461. declare module BABYLON {
  32462. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32463. readonly name: string;
  32464. private _zoomStopsAnimation;
  32465. private _idleRotationSpeed;
  32466. private _idleRotationWaitTime;
  32467. private _idleRotationSpinupTime;
  32468. /**
  32469. * Sets the flag that indicates if user zooming should stop animation.
  32470. */
  32471. /**
  32472. * Gets the flag that indicates if user zooming should stop animation.
  32473. */
  32474. zoomStopsAnimation: boolean;
  32475. /**
  32476. * Sets the default speed at which the camera rotates around the model.
  32477. */
  32478. /**
  32479. * Gets the default speed at which the camera rotates around the model.
  32480. */
  32481. idleRotationSpeed: number;
  32482. /**
  32483. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32484. */
  32485. /**
  32486. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32487. */
  32488. idleRotationWaitTime: number;
  32489. /**
  32490. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32491. */
  32492. /**
  32493. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32494. */
  32495. idleRotationSpinupTime: number;
  32496. /**
  32497. * Gets a value indicating if the camera is currently rotating because of this behavior
  32498. */
  32499. readonly rotationInProgress: boolean;
  32500. private _onPrePointerObservableObserver;
  32501. private _onAfterCheckInputsObserver;
  32502. private _attachedCamera;
  32503. private _isPointerDown;
  32504. private _lastFrameTime;
  32505. private _lastInteractionTime;
  32506. private _cameraRotationSpeed;
  32507. init(): void;
  32508. attach(camera: ArcRotateCamera): void;
  32509. detach(): void;
  32510. /**
  32511. * Returns true if user is scrolling.
  32512. * @return true if user is scrolling.
  32513. */
  32514. private _userIsZooming;
  32515. private _lastFrameRadius;
  32516. private _shouldAnimationStopForInteraction;
  32517. /**
  32518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32519. */
  32520. private _applyUserInteraction;
  32521. private _userIsMoving;
  32522. }
  32523. }
  32524. declare module BABYLON {
  32525. /**
  32526. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32527. */
  32528. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32529. readonly name: string;
  32530. /**
  32531. * The easing function used by animations
  32532. */
  32533. static EasingFunction: BackEase;
  32534. /**
  32535. * The easing mode used by animations
  32536. */
  32537. static EasingMode: number;
  32538. /**
  32539. * The duration of the animation, in milliseconds
  32540. */
  32541. transitionDuration: number;
  32542. /**
  32543. * Length of the distance animated by the transition when lower radius is reached
  32544. */
  32545. lowerRadiusTransitionRange: number;
  32546. /**
  32547. * Length of the distance animated by the transition when upper radius is reached
  32548. */
  32549. upperRadiusTransitionRange: number;
  32550. private _autoTransitionRange;
  32551. /**
  32552. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32553. */
  32554. /**
  32555. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32556. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32557. */
  32558. autoTransitionRange: boolean;
  32559. private _attachedCamera;
  32560. private _onAfterCheckInputsObserver;
  32561. private _onMeshTargetChangedObserver;
  32562. init(): void;
  32563. attach(camera: ArcRotateCamera): void;
  32564. detach(): void;
  32565. private _radiusIsAnimating;
  32566. private _radiusBounceTransition;
  32567. private _animatables;
  32568. private _cachedWheelPrecision;
  32569. /**
  32570. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32571. * @param radiusLimit The limit to check against.
  32572. * @return Bool to indicate if at limit.
  32573. */
  32574. private _isRadiusAtLimit;
  32575. /**
  32576. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32577. * @param radiusDelta The delta by which to animate to. Can be negative.
  32578. */
  32579. private _applyBoundRadiusAnimation;
  32580. /**
  32581. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32582. */
  32583. protected _clearAnimationLocks(): void;
  32584. /**
  32585. * Stops and removes all animations that have been applied to the camera
  32586. */
  32587. stopAllAnimations(): void;
  32588. }
  32589. }
  32590. declare module BABYLON {
  32591. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32592. readonly name: string;
  32593. private _mode;
  32594. private _radiusScale;
  32595. private _positionScale;
  32596. private _defaultElevation;
  32597. private _elevationReturnTime;
  32598. private _elevationReturnWaitTime;
  32599. private _zoomStopsAnimation;
  32600. private _framingTime;
  32601. /**
  32602. * The easing function used by animations
  32603. */
  32604. static EasingFunction: ExponentialEase;
  32605. /**
  32606. * The easing mode used by animations
  32607. */
  32608. static EasingMode: number;
  32609. /**
  32610. * Sets the current mode used by the behavior
  32611. */
  32612. /**
  32613. * Gets current mode used by the behavior.
  32614. */
  32615. mode: number;
  32616. /**
  32617. * Sets the scale applied to the radius (1 by default)
  32618. */
  32619. /**
  32620. * Gets the scale applied to the radius
  32621. */
  32622. radiusScale: number;
  32623. /**
  32624. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32625. */
  32626. /**
  32627. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32628. */
  32629. positionScale: number;
  32630. /**
  32631. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32632. * behaviour is triggered, in radians.
  32633. */
  32634. /**
  32635. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32636. * behaviour is triggered, in radians.
  32637. */
  32638. defaultElevation: number;
  32639. /**
  32640. * Sets the time (in milliseconds) taken to return to the default beta position.
  32641. * Negative value indicates camera should not return to default.
  32642. */
  32643. /**
  32644. * Gets the time (in milliseconds) taken to return to the default beta position.
  32645. * Negative value indicates camera should not return to default.
  32646. */
  32647. elevationReturnTime: number;
  32648. /**
  32649. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32650. */
  32651. /**
  32652. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32653. */
  32654. elevationReturnWaitTime: number;
  32655. /**
  32656. * Sets the flag that indicates if user zooming should stop animation.
  32657. */
  32658. /**
  32659. * Gets the flag that indicates if user zooming should stop animation.
  32660. */
  32661. zoomStopsAnimation: boolean;
  32662. /**
  32663. * Sets the transition time when framing the mesh, in milliseconds
  32664. */
  32665. /**
  32666. * Gets the transition time when framing the mesh, in milliseconds
  32667. */
  32668. framingTime: number;
  32669. private _onPrePointerObservableObserver;
  32670. private _onAfterCheckInputsObserver;
  32671. private _onMeshTargetChangedObserver;
  32672. private _attachedCamera;
  32673. private _isPointerDown;
  32674. private _lastInteractionTime;
  32675. init(): void;
  32676. attach(camera: ArcRotateCamera): void;
  32677. detach(): void;
  32678. private _animatables;
  32679. private _betaIsAnimating;
  32680. private _betaTransition;
  32681. private _radiusTransition;
  32682. private _vectorTransition;
  32683. /**
  32684. * Targets the given mesh and updates zoom level accordingly.
  32685. * @param mesh The mesh to target.
  32686. * @param radius Optional. If a cached radius position already exists, overrides default.
  32687. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32688. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32689. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32690. */
  32691. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32692. /**
  32693. * Targets the given mesh with its children and updates zoom level accordingly.
  32694. * @param mesh The mesh to target.
  32695. * @param radius Optional. If a cached radius position already exists, overrides default.
  32696. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32699. */
  32700. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32701. /**
  32702. * Targets the given meshes with their children and updates zoom level accordingly.
  32703. * @param meshes The mesh to target.
  32704. * @param radius Optional. If a cached radius position already exists, overrides default.
  32705. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32706. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32707. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32708. */
  32709. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32710. /**
  32711. * Targets the given mesh and updates zoom level accordingly.
  32712. * @param mesh The mesh to target.
  32713. * @param radius Optional. If a cached radius position already exists, overrides default.
  32714. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32715. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32716. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32717. */
  32718. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32719. /**
  32720. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32721. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32722. * frustum width.
  32723. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32724. * to fully enclose the mesh in the viewing frustum.
  32725. */
  32726. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32727. /**
  32728. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32729. * is automatically returned to its default position (expected to be above ground plane).
  32730. */
  32731. private _maintainCameraAboveGround;
  32732. /**
  32733. * Returns the frustum slope based on the canvas ratio and camera FOV
  32734. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32735. */
  32736. private _getFrustumSlope;
  32737. /**
  32738. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32739. */
  32740. private _clearAnimationLocks;
  32741. /**
  32742. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32743. */
  32744. private _applyUserInteraction;
  32745. /**
  32746. * Stops and removes all animations that have been applied to the camera
  32747. */
  32748. stopAllAnimations(): void;
  32749. /**
  32750. * Gets a value indicating if the user is moving the camera
  32751. */
  32752. readonly isUserIsMoving: boolean;
  32753. /**
  32754. * The camera can move all the way towards the mesh.
  32755. */
  32756. static IgnoreBoundsSizeMode: number;
  32757. /**
  32758. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32759. */
  32760. static FitFrustumSidesMode: number;
  32761. }
  32762. }
  32763. declare module BABYLON {
  32764. /**
  32765. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32766. */
  32767. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32768. private ui;
  32769. /**
  32770. * The name of the behavior
  32771. */
  32772. name: string;
  32773. /**
  32774. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32775. */
  32776. distanceAwayFromFace: number;
  32777. /**
  32778. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32779. */
  32780. distanceAwayFromBottomOfFace: number;
  32781. private _faceVectors;
  32782. private _target;
  32783. private _scene;
  32784. private _onRenderObserver;
  32785. private _tmpMatrix;
  32786. private _tmpVector;
  32787. /**
  32788. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32789. * @param ui The transform node that should be attched to the mesh
  32790. */
  32791. constructor(ui: BABYLON.TransformNode);
  32792. /**
  32793. * Initializes the behavior
  32794. */
  32795. init(): void;
  32796. private _closestFace;
  32797. private _zeroVector;
  32798. private _lookAtTmpMatrix;
  32799. private _lookAtToRef;
  32800. /**
  32801. * Attaches the AttachToBoxBehavior to the passed in mesh
  32802. * @param target The mesh that the specified node will be attached to
  32803. */
  32804. attach(target: BABYLON.Mesh): void;
  32805. /**
  32806. * Detaches the behavior from the mesh
  32807. */
  32808. detach(): void;
  32809. }
  32810. }
  32811. declare module BABYLON {
  32812. /**
  32813. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32814. */
  32815. class FadeInOutBehavior implements Behavior<Mesh> {
  32816. /**
  32817. * Time in milliseconds to delay before fading in (Default: 0)
  32818. */
  32819. delay: number;
  32820. /**
  32821. * Time in milliseconds for the mesh to fade in (Default: 300)
  32822. */
  32823. fadeInTime: number;
  32824. private _millisecondsPerFrame;
  32825. private _hovered;
  32826. private _hoverValue;
  32827. private _ownerNode;
  32828. /**
  32829. * Instatiates the FadeInOutBehavior
  32830. */
  32831. constructor();
  32832. /**
  32833. * The name of the behavior
  32834. */
  32835. readonly name: string;
  32836. /**
  32837. * Initializes the behavior
  32838. */
  32839. init(): void;
  32840. /**
  32841. * Attaches the fade behavior on the passed in mesh
  32842. * @param ownerNode The mesh that will be faded in/out once attached
  32843. */
  32844. attach(ownerNode: Mesh): void;
  32845. /**
  32846. * Detaches the behavior from the mesh
  32847. */
  32848. detach(): void;
  32849. /**
  32850. * Triggers the mesh to begin fading in or out
  32851. * @param value if the object should fade in or out (true to fade in)
  32852. */
  32853. fadeIn(value: boolean): void;
  32854. private _update;
  32855. private _setAllVisibility;
  32856. }
  32857. }
  32858. declare module BABYLON {
  32859. /**
  32860. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32861. */
  32862. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32863. private _dragBehaviorA;
  32864. private _dragBehaviorB;
  32865. private _startDistance;
  32866. private _initialScale;
  32867. private _targetScale;
  32868. private _ownerNode;
  32869. private _sceneRenderObserver;
  32870. constructor();
  32871. /**
  32872. * The name of the behavior
  32873. */
  32874. readonly name: string;
  32875. /**
  32876. * Initializes the behavior
  32877. */
  32878. init(): void;
  32879. private _getCurrentDistance;
  32880. /**
  32881. * Attaches the scale behavior the passed in mesh
  32882. * @param ownerNode The mesh that will be scaled around once attached
  32883. */
  32884. attach(ownerNode: Mesh): void;
  32885. /**
  32886. * Detaches the behavior from the mesh
  32887. */
  32888. detach(): void;
  32889. }
  32890. }
  32891. declare module BABYLON {
  32892. /**
  32893. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32894. */
  32895. class PointerDragBehavior implements Behavior<Mesh> {
  32896. private _attachedNode;
  32897. private _dragPlane;
  32898. private _scene;
  32899. private _pointerObserver;
  32900. private _beforeRenderObserver;
  32901. private static _planeScene;
  32902. /**
  32903. * 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)
  32904. */
  32905. maxDragAngle: number;
  32906. /**
  32907. * @hidden
  32908. */
  32909. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  32910. /**
  32911. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32912. */
  32913. currentDraggingPointerID: number;
  32914. /**
  32915. * The last position where the pointer hit the drag plane in world space
  32916. */
  32917. lastDragPosition: Vector3;
  32918. /**
  32919. * If the behavior is currently in a dragging state
  32920. */
  32921. dragging: boolean;
  32922. /**
  32923. * 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)
  32924. */
  32925. dragDeltaRatio: number;
  32926. /**
  32927. * If the drag plane orientation should be updated during the dragging (Default: true)
  32928. */
  32929. updateDragPlane: boolean;
  32930. private _debugMode;
  32931. private _moving;
  32932. /**
  32933. * Fires each time the attached mesh is dragged with the pointer
  32934. * * delta between last drag position and current drag position in world space
  32935. * * dragDistance along the drag axis
  32936. * * dragPlaneNormal normal of the current drag plane used during the drag
  32937. * * dragPlanePoint in world space where the drag intersects the drag plane
  32938. */
  32939. onDragObservable: Observable<{
  32940. delta: Vector3;
  32941. dragPlanePoint: Vector3;
  32942. dragPlaneNormal: Vector3;
  32943. dragDistance: number;
  32944. pointerId: number;
  32945. }>;
  32946. /**
  32947. * Fires each time a drag begins (eg. mouse down on mesh)
  32948. */
  32949. onDragStartObservable: Observable<{
  32950. dragPlanePoint: Vector3;
  32951. pointerId: number;
  32952. }>;
  32953. /**
  32954. * Fires each time a drag ends (eg. mouse release after drag)
  32955. */
  32956. onDragEndObservable: Observable<{
  32957. dragPlanePoint: Vector3;
  32958. pointerId: number;
  32959. }>;
  32960. /**
  32961. * If the attached mesh should be moved when dragged
  32962. */
  32963. moveAttached: boolean;
  32964. /**
  32965. * If the drag behavior will react to drag events (Default: true)
  32966. */
  32967. enabled: boolean;
  32968. /**
  32969. * If camera controls should be detached during the drag
  32970. */
  32971. detachCameraControls: boolean;
  32972. /**
  32973. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32974. */
  32975. useObjectOrienationForDragging: boolean;
  32976. private _options;
  32977. /**
  32978. * Creates a pointer drag behavior that can be attached to a mesh
  32979. * @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)
  32980. */
  32981. constructor(options?: {
  32982. dragAxis?: Vector3;
  32983. dragPlaneNormal?: Vector3;
  32984. });
  32985. /**
  32986. * The name of the behavior
  32987. */
  32988. readonly name: string;
  32989. /**
  32990. * Initializes the behavior
  32991. */
  32992. init(): void;
  32993. private _tmpVector;
  32994. private _alternatePickedPoint;
  32995. private _worldDragAxis;
  32996. private _targetPosition;
  32997. private _attachedElement;
  32998. /**
  32999. * Attaches the drag behavior the passed in mesh
  33000. * @param ownerNode The mesh that will be dragged around once attached
  33001. */
  33002. attach(ownerNode: Mesh): void;
  33003. releaseDrag(): void;
  33004. private _startDragRay;
  33005. private _lastPointerRay;
  33006. /**
  33007. * Simulates the start of a pointer drag event on the behavior
  33008. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  33009. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  33010. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  33011. */
  33012. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  33013. private _startDrag;
  33014. private _dragDelta;
  33015. private _moveDrag;
  33016. private _pickWithRayOnDragPlane;
  33017. private _pointA;
  33018. private _pointB;
  33019. private _pointC;
  33020. private _lineA;
  33021. private _lineB;
  33022. private _localAxis;
  33023. private _lookAt;
  33024. private _updateDragPlanePosition;
  33025. /**
  33026. * Detaches the behavior from the mesh
  33027. */
  33028. detach(): void;
  33029. }
  33030. }
  33031. declare module BABYLON {
  33032. /**
  33033. * 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
  33034. */
  33035. class SixDofDragBehavior implements Behavior<Mesh> {
  33036. private static _virtualScene;
  33037. private _ownerNode;
  33038. private _sceneRenderObserver;
  33039. private _scene;
  33040. private _targetPosition;
  33041. private _virtualOriginMesh;
  33042. private _virtualDragMesh;
  33043. private _pointerObserver;
  33044. private _moving;
  33045. private _startingOrientation;
  33046. /**
  33047. * 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)
  33048. */
  33049. private zDragFactor;
  33050. /**
  33051. * If the behavior is currently in a dragging state
  33052. */
  33053. dragging: boolean;
  33054. /**
  33055. * 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)
  33056. */
  33057. dragDeltaRatio: number;
  33058. /**
  33059. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33060. */
  33061. currentDraggingPointerID: number;
  33062. /**
  33063. * If camera controls should be detached during the drag
  33064. */
  33065. detachCameraControls: boolean;
  33066. constructor();
  33067. /**
  33068. * The name of the behavior
  33069. */
  33070. readonly name: string;
  33071. /**
  33072. * Initializes the behavior
  33073. */
  33074. init(): void;
  33075. /**
  33076. * Attaches the scale behavior the passed in mesh
  33077. * @param ownerNode The mesh that will be scaled around once attached
  33078. */
  33079. attach(ownerNode: Mesh): void;
  33080. /**
  33081. * Detaches the behavior from the mesh
  33082. */
  33083. detach(): void;
  33084. }
  33085. }
  33086. declare module BABYLON {
  33087. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  33088. camera: ArcRotateCamera;
  33089. gamepad: Nullable<Gamepad>;
  33090. private _onGamepadConnectedObserver;
  33091. private _onGamepadDisconnectedObserver;
  33092. gamepadRotationSensibility: number;
  33093. gamepadMoveSensibility: number;
  33094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33095. detachControl(element: Nullable<HTMLElement>): void;
  33096. checkInputs(): void;
  33097. getClassName(): string;
  33098. getSimpleName(): string;
  33099. }
  33100. }
  33101. declare module BABYLON {
  33102. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33103. camera: ArcRotateCamera;
  33104. private _keys;
  33105. keysUp: number[];
  33106. keysDown: number[];
  33107. keysLeft: number[];
  33108. keysRight: number[];
  33109. keysReset: number[];
  33110. panningSensibility: number;
  33111. zoomingSensibility: number;
  33112. useAltToZoom: boolean;
  33113. private _ctrlPressed;
  33114. private _altPressed;
  33115. private _onCanvasBlurObserver;
  33116. private _onKeyboardObserver;
  33117. private _engine;
  33118. private _scene;
  33119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33120. detachControl(element: Nullable<HTMLElement>): void;
  33121. checkInputs(): void;
  33122. getClassName(): string;
  33123. getSimpleName(): string;
  33124. }
  33125. }
  33126. declare module BABYLON {
  33127. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33128. camera: ArcRotateCamera;
  33129. private _wheel;
  33130. private _observer;
  33131. wheelPrecision: number;
  33132. /**
  33133. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33134. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33135. */
  33136. wheelDeltaPercentage: number;
  33137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33138. detachControl(element: Nullable<HTMLElement>): void;
  33139. getClassName(): string;
  33140. getSimpleName(): string;
  33141. }
  33142. }
  33143. declare module BABYLON {
  33144. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33145. camera: ArcRotateCamera;
  33146. buttons: number[];
  33147. angularSensibilityX: number;
  33148. angularSensibilityY: number;
  33149. pinchPrecision: number;
  33150. /**
  33151. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33152. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33153. */
  33154. pinchDeltaPercentage: number;
  33155. panningSensibility: number;
  33156. multiTouchPanning: boolean;
  33157. multiTouchPanAndZoom: boolean;
  33158. private _isPanClick;
  33159. pinchInwards: boolean;
  33160. private _pointerInput;
  33161. private _observer;
  33162. private _onMouseMove;
  33163. private _onGestureStart;
  33164. private _onGesture;
  33165. private _MSGestureHandler;
  33166. private _onLostFocus;
  33167. private _onContextMenu;
  33168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33169. detachControl(element: Nullable<HTMLElement>): void;
  33170. getClassName(): string;
  33171. getSimpleName(): string;
  33172. }
  33173. }
  33174. declare module BABYLON {
  33175. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  33176. camera: ArcRotateCamera;
  33177. alphaCorrection: number;
  33178. betaCorrection: number;
  33179. gammaCorrection: number;
  33180. private _alpha;
  33181. private _gamma;
  33182. private _dirty;
  33183. private _deviceOrientationHandler;
  33184. constructor();
  33185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33186. /** @hidden */
  33187. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  33188. checkInputs(): void;
  33189. detachControl(element: Nullable<HTMLElement>): void;
  33190. getClassName(): string;
  33191. getSimpleName(): string;
  33192. }
  33193. }
  33194. declare module BABYLON {
  33195. /**
  33196. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  33197. * Screen rotation is taken into account.
  33198. */
  33199. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  33200. private _camera;
  33201. private _screenOrientationAngle;
  33202. private _constantTranform;
  33203. private _screenQuaternion;
  33204. private _alpha;
  33205. private _beta;
  33206. private _gamma;
  33207. constructor();
  33208. camera: FreeCamera;
  33209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33210. private _orientationChanged;
  33211. private _deviceOrientation;
  33212. detachControl(element: Nullable<HTMLElement>): void;
  33213. checkInputs(): void;
  33214. getClassName(): string;
  33215. getSimpleName(): string;
  33216. }
  33217. }
  33218. declare module BABYLON {
  33219. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  33220. camera: FreeCamera;
  33221. gamepad: Nullable<Gamepad>;
  33222. private _onGamepadConnectedObserver;
  33223. private _onGamepadDisconnectedObserver;
  33224. gamepadAngularSensibility: number;
  33225. gamepadMoveSensibility: number;
  33226. private _cameraTransform;
  33227. private _deltaTransform;
  33228. private _vector3;
  33229. private _vector2;
  33230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33231. detachControl(element: Nullable<HTMLElement>): void;
  33232. checkInputs(): void;
  33233. getClassName(): string;
  33234. getSimpleName(): string;
  33235. }
  33236. }
  33237. declare module BABYLON {
  33238. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  33239. camera: FreeCamera;
  33240. private _keys;
  33241. private _onCanvasBlurObserver;
  33242. private _onKeyboardObserver;
  33243. private _engine;
  33244. private _scene;
  33245. keysUp: number[];
  33246. keysDown: number[];
  33247. keysLeft: number[];
  33248. keysRight: number[];
  33249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33250. detachControl(element: Nullable<HTMLElement>): void;
  33251. checkInputs(): void;
  33252. getClassName(): string;
  33253. /** @hidden */
  33254. _onLostFocus(e: FocusEvent): void;
  33255. getSimpleName(): string;
  33256. }
  33257. }
  33258. declare module BABYLON {
  33259. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  33260. touchEnabled: boolean;
  33261. camera: FreeCamera;
  33262. buttons: number[];
  33263. angularSensibility: number;
  33264. private _pointerInput;
  33265. private _onMouseMove;
  33266. private _observer;
  33267. private previousPosition;
  33268. constructor(touchEnabled?: boolean);
  33269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33270. detachControl(element: Nullable<HTMLElement>): void;
  33271. getClassName(): string;
  33272. getSimpleName(): string;
  33273. }
  33274. }
  33275. declare module BABYLON {
  33276. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  33277. camera: FreeCamera;
  33278. private _offsetX;
  33279. private _offsetY;
  33280. private _pointerPressed;
  33281. private _pointerInput;
  33282. private _observer;
  33283. private _onLostFocus;
  33284. touchAngularSensibility: number;
  33285. touchMoveSensibility: number;
  33286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33287. detachControl(element: Nullable<HTMLElement>): void;
  33288. checkInputs(): void;
  33289. getClassName(): string;
  33290. getSimpleName(): string;
  33291. }
  33292. }
  33293. declare module BABYLON {
  33294. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  33295. camera: FreeCamera;
  33296. private _leftjoystick;
  33297. private _rightjoystick;
  33298. getLeftJoystick(): VirtualJoystick;
  33299. getRightJoystick(): VirtualJoystick;
  33300. checkInputs(): void;
  33301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33302. detachControl(element: Nullable<HTMLElement>): void;
  33303. getClassName(): string;
  33304. getSimpleName(): string;
  33305. }
  33306. }
  33307. declare module BABYLON {
  33308. /**
  33309. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  33310. */
  33311. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  33312. /**
  33313. * Creates a new AnaglyphArcRotateCamera
  33314. * @param name defines camera name
  33315. * @param alpha defines alpha angle (in radians)
  33316. * @param beta defines beta angle (in radians)
  33317. * @param radius defines radius
  33318. * @param target defines camera target
  33319. * @param interaxialDistance defines distance between each color axis
  33320. * @param scene defines the hosting scene
  33321. */
  33322. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  33323. /**
  33324. * Gets camera class name
  33325. * @returns AnaglyphArcRotateCamera
  33326. */
  33327. getClassName(): string;
  33328. }
  33329. }
  33330. declare module BABYLON {
  33331. /**
  33332. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  33333. */
  33334. class AnaglyphFreeCamera extends FreeCamera {
  33335. /**
  33336. * Creates a new AnaglyphFreeCamera
  33337. * @param name defines camera name
  33338. * @param position defines initial position
  33339. * @param interaxialDistance defines distance between each color axis
  33340. * @param scene defines the hosting scene
  33341. */
  33342. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33343. /**
  33344. * Gets camera class name
  33345. * @returns AnaglyphFreeCamera
  33346. */
  33347. getClassName(): string;
  33348. }
  33349. }
  33350. declare module BABYLON {
  33351. /**
  33352. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  33353. */
  33354. class AnaglyphGamepadCamera extends GamepadCamera {
  33355. /**
  33356. * Creates a new AnaglyphGamepadCamera
  33357. * @param name defines camera name
  33358. * @param position defines initial position
  33359. * @param interaxialDistance defines distance between each color axis
  33360. * @param scene defines the hosting scene
  33361. */
  33362. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33363. /**
  33364. * Gets camera class name
  33365. * @returns AnaglyphGamepadCamera
  33366. */
  33367. getClassName(): string;
  33368. }
  33369. }
  33370. declare module BABYLON {
  33371. /**
  33372. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  33373. */
  33374. class AnaglyphUniversalCamera extends UniversalCamera {
  33375. /**
  33376. * Creates a new AnaglyphUniversalCamera
  33377. * @param name defines camera name
  33378. * @param position defines initial position
  33379. * @param interaxialDistance defines distance between each color axis
  33380. * @param scene defines the hosting scene
  33381. */
  33382. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33383. /**
  33384. * Gets camera class name
  33385. * @returns AnaglyphUniversalCamera
  33386. */
  33387. getClassName(): string;
  33388. }
  33389. }
  33390. declare module BABYLON {
  33391. /**
  33392. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  33393. */
  33394. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  33395. /**
  33396. * Creates a new StereoscopicArcRotateCamera
  33397. * @param name defines camera name
  33398. * @param alpha defines alpha angle (in radians)
  33399. * @param beta defines beta angle (in radians)
  33400. * @param radius defines radius
  33401. * @param target defines camera target
  33402. * @param interaxialDistance defines distance between each color axis
  33403. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33404. * @param scene defines the hosting scene
  33405. */
  33406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33407. /**
  33408. * Gets camera class name
  33409. * @returns StereoscopicArcRotateCamera
  33410. */
  33411. getClassName(): string;
  33412. }
  33413. }
  33414. declare module BABYLON {
  33415. /**
  33416. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33417. */
  33418. class StereoscopicFreeCamera extends FreeCamera {
  33419. /**
  33420. * Creates a new StereoscopicFreeCamera
  33421. * @param name defines camera name
  33422. * @param position defines initial position
  33423. * @param interaxialDistance defines distance between each color axis
  33424. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33425. * @param scene defines the hosting scene
  33426. */
  33427. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33428. /**
  33429. * Gets camera class name
  33430. * @returns StereoscopicFreeCamera
  33431. */
  33432. getClassName(): string;
  33433. }
  33434. }
  33435. declare module BABYLON {
  33436. /**
  33437. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33438. */
  33439. class StereoscopicGamepadCamera extends GamepadCamera {
  33440. /**
  33441. * Creates a new StereoscopicGamepadCamera
  33442. * @param name defines camera name
  33443. * @param position defines initial position
  33444. * @param interaxialDistance defines distance between each color axis
  33445. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33446. * @param scene defines the hosting scene
  33447. */
  33448. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33449. /**
  33450. * Gets camera class name
  33451. * @returns StereoscopicGamepadCamera
  33452. */
  33453. getClassName(): string;
  33454. }
  33455. }
  33456. declare module BABYLON {
  33457. /**
  33458. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33459. */
  33460. class StereoscopicUniversalCamera extends UniversalCamera {
  33461. /**
  33462. * Creates a new StereoscopicUniversalCamera
  33463. * @param name defines camera name
  33464. * @param position defines initial position
  33465. * @param interaxialDistance defines distance between each color axis
  33466. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33467. * @param scene defines the hosting scene
  33468. */
  33469. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33470. /**
  33471. * Gets camera class name
  33472. * @returns StereoscopicUniversalCamera
  33473. */
  33474. getClassName(): string;
  33475. }
  33476. }
  33477. declare module BABYLON {
  33478. class VRCameraMetrics {
  33479. hResolution: number;
  33480. vResolution: number;
  33481. hScreenSize: number;
  33482. vScreenSize: number;
  33483. vScreenCenter: number;
  33484. eyeToScreenDistance: number;
  33485. lensSeparationDistance: number;
  33486. interpupillaryDistance: number;
  33487. distortionK: number[];
  33488. chromaAbCorrection: number[];
  33489. postProcessScaleFactor: number;
  33490. lensCenterOffset: number;
  33491. compensateDistortion: boolean;
  33492. readonly aspectRatio: number;
  33493. readonly aspectRatioFov: number;
  33494. readonly leftHMatrix: Matrix;
  33495. readonly rightHMatrix: Matrix;
  33496. readonly leftPreViewMatrix: Matrix;
  33497. readonly rightPreViewMatrix: Matrix;
  33498. static GetDefault(): VRCameraMetrics;
  33499. }
  33500. }
  33501. declare module BABYLON {
  33502. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33503. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33504. getClassName(): string;
  33505. }
  33506. }
  33507. declare module BABYLON {
  33508. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33509. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33510. getClassName(): string;
  33511. }
  33512. }
  33513. declare module BABYLON {
  33514. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33515. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33516. getClassName(): string;
  33517. }
  33518. }
  33519. declare module BABYLON {
  33520. /**
  33521. * Options to modify the vr teleportation behavior.
  33522. */
  33523. interface VRTeleportationOptions {
  33524. /**
  33525. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33526. */
  33527. floorMeshName?: string;
  33528. /**
  33529. * A list of meshes to be used as the teleportation floor. (default: empty)
  33530. */
  33531. floorMeshes?: Mesh[];
  33532. }
  33533. /**
  33534. * Options to modify the vr experience helper's behavior.
  33535. */
  33536. interface VRExperienceHelperOptions extends WebVROptions {
  33537. /**
  33538. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  33539. */
  33540. createDeviceOrientationCamera?: boolean;
  33541. /**
  33542. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  33543. */
  33544. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33545. /**
  33546. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33547. */
  33548. laserToggle?: boolean;
  33549. /**
  33550. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33551. */
  33552. floorMeshes?: Mesh[];
  33553. }
  33554. /**
  33555. * Helps to quickly add VR support to an existing scene.
  33556. * See http://doc.babylonjs.com/how_to/webvr_helper
  33557. */
  33558. class VRExperienceHelper {
  33559. /** Options to modify the vr experience helper's behavior. */
  33560. webVROptions: VRExperienceHelperOptions;
  33561. private _scene;
  33562. private _position;
  33563. private _btnVR;
  33564. private _btnVRDisplayed;
  33565. private _webVRsupported;
  33566. private _webVRready;
  33567. private _webVRrequesting;
  33568. private _webVRpresenting;
  33569. private _hasEnteredVR;
  33570. private _fullscreenVRpresenting;
  33571. private _canvas;
  33572. private _webVRCamera;
  33573. private _vrDeviceOrientationCamera;
  33574. private _deviceOrientationCamera;
  33575. private _existingCamera;
  33576. private _onKeyDown;
  33577. private _onVrDisplayPresentChange;
  33578. private _onVRDisplayChanged;
  33579. private _onVRRequestPresentStart;
  33580. private _onVRRequestPresentComplete;
  33581. /**
  33582. * Observable raised when entering VR.
  33583. */
  33584. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33585. /**
  33586. * Observable raised when exiting VR.
  33587. */
  33588. onExitingVRObservable: Observable<VRExperienceHelper>;
  33589. /**
  33590. * Observable raised when controller mesh is loaded.
  33591. */
  33592. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33593. /** Return this.onEnteringVRObservable
  33594. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33595. */
  33596. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33597. /** Return this.onExitingVRObservable
  33598. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33599. */
  33600. readonly onExitingVR: Observable<VRExperienceHelper>;
  33601. /** Return this.onControllerMeshLoadedObservable
  33602. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33603. */
  33604. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33605. private _rayLength;
  33606. private _useCustomVRButton;
  33607. private _teleportationRequested;
  33608. private _teleportActive;
  33609. private _floorMeshName;
  33610. private _floorMeshesCollection;
  33611. private _rotationAllowed;
  33612. private _teleportBackwardsVector;
  33613. private _teleportationTarget;
  33614. private _isDefaultTeleportationTarget;
  33615. private _postProcessMove;
  33616. private _teleportationFillColor;
  33617. private _teleportationBorderColor;
  33618. private _rotationAngle;
  33619. private _haloCenter;
  33620. private _cameraGazer;
  33621. private _padSensibilityUp;
  33622. private _padSensibilityDown;
  33623. private _leftController;
  33624. private _rightController;
  33625. /**
  33626. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33627. */
  33628. onNewMeshSelected: Observable<AbstractMesh>;
  33629. /**
  33630. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33631. */
  33632. onNewMeshPicked: Observable<PickingInfo>;
  33633. private _circleEase;
  33634. /**
  33635. * Observable raised before camera teleportation
  33636. */
  33637. onBeforeCameraTeleport: Observable<Vector3>;
  33638. /**
  33639. * Observable raised after camera teleportation
  33640. */
  33641. onAfterCameraTeleport: Observable<Vector3>;
  33642. /**
  33643. * Observable raised when current selected mesh gets unselected
  33644. */
  33645. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33646. private _raySelectionPredicate;
  33647. /**
  33648. * To be optionaly changed by user to define custom ray selection
  33649. */
  33650. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33651. /**
  33652. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33653. */
  33654. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33655. /**
  33656. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33657. */
  33658. teleportationEnabled: boolean;
  33659. private _defaultHeight;
  33660. private _teleportationInitialized;
  33661. private _interactionsEnabled;
  33662. private _interactionsRequested;
  33663. private _displayGaze;
  33664. private _displayLaserPointer;
  33665. /**
  33666. * The mesh used to display where the user is going to teleport.
  33667. */
  33668. /**
  33669. * Sets the mesh to be used to display where the user is going to teleport.
  33670. */
  33671. teleportationTarget: Mesh;
  33672. /**
  33673. * 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
  33674. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33675. * See http://doc.babylonjs.com/resources/baking_transformations
  33676. */
  33677. gazeTrackerMesh: Mesh;
  33678. /**
  33679. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  33680. */
  33681. updateGazeTrackerScale: boolean;
  33682. /**
  33683. * The gaze tracking mesh corresponding to the left controller
  33684. */
  33685. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  33686. /**
  33687. * The gaze tracking mesh corresponding to the right controller
  33688. */
  33689. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  33690. /**
  33691. * If the ray of the gaze should be displayed.
  33692. */
  33693. /**
  33694. * Sets if the ray of the gaze should be displayed.
  33695. */
  33696. displayGaze: boolean;
  33697. /**
  33698. * If the ray of the LaserPointer should be displayed.
  33699. */
  33700. /**
  33701. * Sets if the ray of the LaserPointer should be displayed.
  33702. */
  33703. displayLaserPointer: boolean;
  33704. /**
  33705. * The deviceOrientationCamera used as the camera when not in VR.
  33706. */
  33707. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33708. /**
  33709. * Based on the current WebVR support, returns the current VR camera used.
  33710. */
  33711. readonly currentVRCamera: Nullable<Camera>;
  33712. /**
  33713. * The webVRCamera which is used when in VR.
  33714. */
  33715. readonly webVRCamera: WebVRFreeCamera;
  33716. /**
  33717. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33718. */
  33719. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33720. private readonly _teleportationRequestInitiated;
  33721. /**
  33722. * Instantiates a VRExperienceHelper.
  33723. * Helps to quickly add VR support to an existing scene.
  33724. * @param scene The scene the VRExperienceHelper belongs to.
  33725. * @param webVROptions Options to modify the vr experience helper's behavior.
  33726. */
  33727. constructor(scene: Scene,
  33728. /** Options to modify the vr experience helper's behavior. */
  33729. webVROptions?: VRExperienceHelperOptions);
  33730. private _onDefaultMeshLoaded;
  33731. private _onResize;
  33732. private _onFullscreenChange;
  33733. /**
  33734. * Gets a value indicating if we are currently in VR mode.
  33735. */
  33736. readonly isInVRMode: boolean;
  33737. private onVrDisplayPresentChange;
  33738. private onVRDisplayChanged;
  33739. private moveButtonToBottomRight;
  33740. private displayVRButton;
  33741. private updateButtonVisibility;
  33742. /**
  33743. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33744. * Otherwise, will use the fullscreen API.
  33745. */
  33746. enterVR(): void;
  33747. /**
  33748. * Attempt to exit VR, or fullscreen.
  33749. */
  33750. exitVR(): void;
  33751. /**
  33752. * The position of the vr experience helper.
  33753. */
  33754. /**
  33755. * Sets the position of the vr experience helper.
  33756. */
  33757. position: Vector3;
  33758. /**
  33759. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33760. */
  33761. enableInteractions(): void;
  33762. private readonly _noControllerIsActive;
  33763. private beforeRender;
  33764. private _isTeleportationFloor;
  33765. /**
  33766. * Adds a floor mesh to be used for teleportation.
  33767. * @param floorMesh the mesh to be used for teleportation.
  33768. */
  33769. addFloorMesh(floorMesh: Mesh): void;
  33770. /**
  33771. * Removes a floor mesh from being used for teleportation.
  33772. * @param floorMesh the mesh to be removed.
  33773. */
  33774. removeFloorMesh(floorMesh: Mesh): void;
  33775. /**
  33776. * Enables interactions and teleportation using the VR controllers and gaze.
  33777. * @param vrTeleportationOptions options to modify teleportation behavior.
  33778. */
  33779. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33780. private _onNewGamepadConnected;
  33781. private _tryEnableInteractionOnController;
  33782. private _onNewGamepadDisconnected;
  33783. private _enableInteractionOnController;
  33784. private _checkTeleportWithRay;
  33785. private _checkRotate;
  33786. private _checkTeleportBackwards;
  33787. private _enableTeleportationOnController;
  33788. private _createTeleportationCircles;
  33789. private _displayTeleportationTarget;
  33790. private _hideTeleportationTarget;
  33791. private _rotateCamera;
  33792. private _moveTeleportationSelectorTo;
  33793. private _workingVector;
  33794. private _workingQuaternion;
  33795. private _workingMatrix;
  33796. private _teleportCamera;
  33797. private _convertNormalToDirectionOfRay;
  33798. private _castRayAndSelectObject;
  33799. private _notifySelectedMeshUnselected;
  33800. /**
  33801. * Sets the color of the laser ray from the vr controllers.
  33802. * @param color new color for the ray.
  33803. */
  33804. changeLaserColor(color: Color3): void;
  33805. /**
  33806. * Sets the color of the ray from the vr headsets gaze.
  33807. * @param color new color for the ray.
  33808. */
  33809. changeGazeColor(color: Color3): void;
  33810. /**
  33811. * Exits VR and disposes of the vr experience helper
  33812. */
  33813. dispose(): void;
  33814. /**
  33815. * Gets the name of the VRExperienceHelper class
  33816. * @returns "VRExperienceHelper"
  33817. */
  33818. getClassName(): string;
  33819. }
  33820. }
  33821. declare module BABYLON {
  33822. /**
  33823. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33824. * IMPORTANT!! The data is right-hand data.
  33825. * @export
  33826. * @interface DevicePose
  33827. */
  33828. interface DevicePose {
  33829. /**
  33830. * The position of the device, values in array are [x,y,z].
  33831. */
  33832. readonly position: Nullable<Float32Array>;
  33833. /**
  33834. * The linearVelocity of the device, values in array are [x,y,z].
  33835. */
  33836. readonly linearVelocity: Nullable<Float32Array>;
  33837. /**
  33838. * The linearAcceleration of the device, values in array are [x,y,z].
  33839. */
  33840. readonly linearAcceleration: Nullable<Float32Array>;
  33841. /**
  33842. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33843. */
  33844. readonly orientation: Nullable<Float32Array>;
  33845. /**
  33846. * The angularVelocity of the device, values in array are [x,y,z].
  33847. */
  33848. readonly angularVelocity: Nullable<Float32Array>;
  33849. /**
  33850. * The angularAcceleration of the device, values in array are [x,y,z].
  33851. */
  33852. readonly angularAcceleration: Nullable<Float32Array>;
  33853. }
  33854. /**
  33855. * Interface representing a pose controlled object in Babylon.
  33856. * A pose controlled object has both regular pose values as well as pose values
  33857. * from an external device such as a VR head mounted display
  33858. */
  33859. interface PoseControlled {
  33860. /**
  33861. * The position of the object in babylon space.
  33862. */
  33863. position: Vector3;
  33864. /**
  33865. * The rotation quaternion of the object in babylon space.
  33866. */
  33867. rotationQuaternion: Quaternion;
  33868. /**
  33869. * The position of the device in babylon space.
  33870. */
  33871. devicePosition?: Vector3;
  33872. /**
  33873. * The rotation quaternion of the device in babylon space.
  33874. */
  33875. deviceRotationQuaternion: Quaternion;
  33876. /**
  33877. * The raw pose coming from the device.
  33878. */
  33879. rawPose: Nullable<DevicePose>;
  33880. /**
  33881. * The scale of the device to be used when translating from device space to babylon space.
  33882. */
  33883. deviceScaleFactor: number;
  33884. /**
  33885. * Updates the poseControlled values based on the input device pose.
  33886. * @param poseData the pose data to update the object with
  33887. */
  33888. updateFromDevice(poseData: DevicePose): void;
  33889. }
  33890. /**
  33891. * Set of options to customize the webVRCamera
  33892. */
  33893. interface WebVROptions {
  33894. /**
  33895. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33896. */
  33897. trackPosition?: boolean;
  33898. /**
  33899. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33900. */
  33901. positionScale?: number;
  33902. /**
  33903. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33904. */
  33905. displayName?: string;
  33906. /**
  33907. * Should the native controller meshes be initialized. (default: true)
  33908. */
  33909. controllerMeshes?: boolean;
  33910. /**
  33911. * Creating a default HemiLight only on controllers. (default: true)
  33912. */
  33913. defaultLightingOnControllers?: boolean;
  33914. /**
  33915. * If you don't want to use the default VR button of the helper. (default: false)
  33916. */
  33917. useCustomVRButton?: boolean;
  33918. /**
  33919. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33920. */
  33921. customVRButton?: HTMLButtonElement;
  33922. /**
  33923. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33924. */
  33925. rayLength?: number;
  33926. /**
  33927. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33928. */
  33929. defaultHeight?: number;
  33930. }
  33931. /**
  33932. * This represents a WebVR camera.
  33933. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33934. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33935. */
  33936. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33937. private webVROptions;
  33938. /**
  33939. * @hidden
  33940. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33941. */
  33942. _vrDevice: any;
  33943. /**
  33944. * The rawPose of the vrDevice.
  33945. */
  33946. rawPose: Nullable<DevicePose>;
  33947. private _onVREnabled;
  33948. private _specsVersion;
  33949. private _attached;
  33950. private _frameData;
  33951. protected _descendants: Array<Node>;
  33952. private _deviceRoomPosition;
  33953. /** @hidden */
  33954. _deviceRoomRotationQuaternion: Quaternion;
  33955. private _standingMatrix;
  33956. /**
  33957. * Represents device position in babylon space.
  33958. */
  33959. devicePosition: Vector3;
  33960. /**
  33961. * Represents device rotation in babylon space.
  33962. */
  33963. deviceRotationQuaternion: Quaternion;
  33964. /**
  33965. * The scale of the device to be used when translating from device space to babylon space.
  33966. */
  33967. deviceScaleFactor: number;
  33968. private _deviceToWorld;
  33969. private _worldToDevice;
  33970. /**
  33971. * References to the webVR controllers for the vrDevice.
  33972. */
  33973. controllers: Array<WebVRController>;
  33974. /**
  33975. * Emits an event when a controller is attached.
  33976. */
  33977. onControllersAttachedObservable: Observable<WebVRController[]>;
  33978. /**
  33979. * Emits an event when a controller's mesh has been loaded;
  33980. */
  33981. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33982. /**
  33983. * Emits an event when the HMD's pose has been updated.
  33984. */
  33985. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33986. private _poseSet;
  33987. /**
  33988. * If the rig cameras be used as parent instead of this camera.
  33989. */
  33990. rigParenting: boolean;
  33991. private _lightOnControllers;
  33992. private _defaultHeight?;
  33993. /**
  33994. * Instantiates a WebVRFreeCamera.
  33995. * @param name The name of the WebVRFreeCamera
  33996. * @param position The starting anchor position for the camera
  33997. * @param scene The scene the camera belongs to
  33998. * @param webVROptions a set of customizable options for the webVRCamera
  33999. */
  34000. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  34001. /**
  34002. * Gets the device distance from the ground in meters.
  34003. * @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.
  34004. */
  34005. deviceDistanceToRoomGround(): number;
  34006. /**
  34007. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34008. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  34009. */
  34010. useStandingMatrix(callback?: (bool: boolean) => void): void;
  34011. /**
  34012. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34013. * @returns A promise with a boolean set to if the standing matrix is supported.
  34014. */
  34015. useStandingMatrixAsync(): Promise<boolean>;
  34016. /**
  34017. * Disposes the camera
  34018. */
  34019. dispose(): void;
  34020. /**
  34021. * Gets a vrController by name.
  34022. * @param name The name of the controller to retreive
  34023. * @returns the controller matching the name specified or null if not found
  34024. */
  34025. getControllerByName(name: string): Nullable<WebVRController>;
  34026. private _leftController;
  34027. /**
  34028. * The controller corrisponding to the users left hand.
  34029. */
  34030. readonly leftController: Nullable<WebVRController>;
  34031. private _rightController;
  34032. /**
  34033. * The controller corrisponding to the users right hand.
  34034. */
  34035. readonly rightController: Nullable<WebVRController>;
  34036. /**
  34037. * Casts a ray forward from the vrCamera's gaze.
  34038. * @param length Length of the ray (default: 100)
  34039. * @returns the ray corrisponding to the gaze
  34040. */
  34041. getForwardRay(length?: number): Ray;
  34042. /**
  34043. * @hidden
  34044. * Updates the camera based on device's frame data
  34045. */
  34046. _checkInputs(): void;
  34047. /**
  34048. * Updates the poseControlled values based on the input device pose.
  34049. * @param poseData Pose coming from the device
  34050. */
  34051. updateFromDevice(poseData: DevicePose): void;
  34052. private _htmlElementAttached;
  34053. private _detachIfAttached;
  34054. /**
  34055. * WebVR's attach control will start broadcasting frames to the device.
  34056. * Note that in certain browsers (chrome for example) this function must be called
  34057. * within a user-interaction callback. Example:
  34058. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  34059. *
  34060. * @param element html element to attach the vrDevice to
  34061. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  34062. */
  34063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34064. /**
  34065. * Detaches the camera from the html element and disables VR
  34066. *
  34067. * @param element html element to detach from
  34068. */
  34069. detachControl(element: HTMLElement): void;
  34070. /**
  34071. * @returns the name of this class
  34072. */
  34073. getClassName(): string;
  34074. /**
  34075. * Calls resetPose on the vrDisplay
  34076. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  34077. */
  34078. resetToCurrentRotation(): void;
  34079. /**
  34080. * @hidden
  34081. * Updates the rig cameras (left and right eye)
  34082. */
  34083. _updateRigCameras(): void;
  34084. private _workingVector;
  34085. private _oneVector;
  34086. private _workingMatrix;
  34087. private updateCacheCalled;
  34088. private _correctPositionIfNotTrackPosition;
  34089. /**
  34090. * @hidden
  34091. * Updates the cached values of the camera
  34092. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  34093. */
  34094. _updateCache(ignoreParentClass?: boolean): void;
  34095. /**
  34096. * Updates the current device position and rotation in the babylon world
  34097. */
  34098. update(): void;
  34099. /**
  34100. * @hidden
  34101. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  34102. * @returns an identity matrix
  34103. */
  34104. _getViewMatrix(): Matrix;
  34105. private _tmpMatrix;
  34106. /**
  34107. * This function is called by the two RIG cameras.
  34108. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  34109. */
  34110. protected _getWebVRViewMatrix(): Matrix;
  34111. protected _getWebVRProjectionMatrix(): Matrix;
  34112. private _onGamepadConnectedObserver;
  34113. private _onGamepadDisconnectedObserver;
  34114. /**
  34115. * Initializes the controllers and their meshes
  34116. */
  34117. initControllers(): void;
  34118. }
  34119. }
  34120. declare module BABYLON {
  34121. interface IOctreeContainer<T> {
  34122. blocks: Array<OctreeBlock<T>>;
  34123. }
  34124. class Octree<T> {
  34125. maxDepth: number;
  34126. blocks: Array<OctreeBlock<T>>;
  34127. dynamicContent: T[];
  34128. private _maxBlockCapacity;
  34129. private _selectionContent;
  34130. private _creationFunc;
  34131. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  34132. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  34133. addMesh(entry: T): void;
  34134. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  34135. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  34136. intersectsRay(ray: Ray): SmartArray<T>;
  34137. 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;
  34138. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  34139. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  34140. }
  34141. }
  34142. declare module BABYLON {
  34143. class OctreeBlock<T> {
  34144. entries: T[];
  34145. blocks: Array<OctreeBlock<T>>;
  34146. private _depth;
  34147. private _maxDepth;
  34148. private _capacity;
  34149. private _minPoint;
  34150. private _maxPoint;
  34151. private _boundingVectors;
  34152. private _creationFunc;
  34153. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  34154. readonly capacity: number;
  34155. readonly minPoint: Vector3;
  34156. readonly maxPoint: Vector3;
  34157. addEntry(entry: T): void;
  34158. addEntries(entries: T[]): void;
  34159. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34160. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34161. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  34162. createInnerBlocks(): void;
  34163. }
  34164. }
  34165. declare module BABYLON {
  34166. interface Engine {
  34167. /**
  34168. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  34169. * @return the new query
  34170. */
  34171. createQuery(): WebGLQuery;
  34172. /**
  34173. * Delete and release a webGL query
  34174. * @param query defines the query to delete
  34175. * @return the current engine
  34176. */
  34177. deleteQuery(query: WebGLQuery): Engine;
  34178. /**
  34179. * Check if a given query has resolved and got its value
  34180. * @param query defines the query to check
  34181. * @returns true if the query got its value
  34182. */
  34183. isQueryResultAvailable(query: WebGLQuery): boolean;
  34184. /**
  34185. * Gets the value of a given query
  34186. * @param query defines the query to check
  34187. * @returns the value of the query
  34188. */
  34189. getQueryResult(query: WebGLQuery): number;
  34190. /**
  34191. * Initiates an occlusion query
  34192. * @param algorithmType defines the algorithm to use
  34193. * @param query defines the query to use
  34194. * @returns the current engine
  34195. * @see http://doc.babylonjs.com/features/occlusionquery
  34196. */
  34197. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  34198. /**
  34199. * Ends an occlusion query
  34200. * @see http://doc.babylonjs.com/features/occlusionquery
  34201. * @param algorithmType defines the algorithm to use
  34202. * @returns the current engine
  34203. */
  34204. endOcclusionQuery(algorithmType: number): Engine;
  34205. /**
  34206. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  34207. * Please note that only one query can be issued at a time
  34208. * @returns a time token used to track the time span
  34209. */
  34210. startTimeQuery(): Nullable<_TimeToken>;
  34211. /**
  34212. * Ends a time query
  34213. * @param token defines the token used to measure the time span
  34214. * @returns the time spent (in ns)
  34215. */
  34216. endTimeQuery(token: _TimeToken): int;
  34217. /** @hidden */
  34218. _currentNonTimestampToken: Nullable<_TimeToken>;
  34219. /** @hidden */
  34220. _createTimeQuery(): WebGLQuery;
  34221. /** @hidden */
  34222. _deleteTimeQuery(query: WebGLQuery): void;
  34223. /** @hidden */
  34224. _getGlAlgorithmType(algorithmType: number): number;
  34225. /** @hidden */
  34226. _getTimeQueryResult(query: WebGLQuery): any;
  34227. /** @hidden */
  34228. _getTimeQueryAvailability(query: WebGLQuery): any;
  34229. }
  34230. }
  34231. declare module BABYLON {
  34232. interface Engine {
  34233. /**
  34234. * Creates a webGL transform feedback object
  34235. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  34236. * @returns the webGL transform feedback object
  34237. */
  34238. createTransformFeedback(): WebGLTransformFeedback;
  34239. /**
  34240. * Delete a webGL transform feedback object
  34241. * @param value defines the webGL transform feedback object to delete
  34242. */
  34243. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  34244. /**
  34245. * Bind a webGL transform feedback object to the webgl context
  34246. * @param value defines the webGL transform feedback object to bind
  34247. */
  34248. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  34249. /**
  34250. * Begins a transform feedback operation
  34251. * @param usePoints defines if points or triangles must be used
  34252. */
  34253. beginTransformFeedback(usePoints: boolean): void;
  34254. /**
  34255. * Ends a transform feedback operation
  34256. */
  34257. endTransformFeedback(): void;
  34258. /**
  34259. * Specify the varyings to use with transform feedback
  34260. * @param program defines the associated webGL program
  34261. * @param value defines the list of strings representing the varying names
  34262. */
  34263. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  34264. /**
  34265. * Bind a webGL buffer for a transform feedback operation
  34266. * @param value defines the webGL buffer to bind
  34267. */
  34268. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  34269. }
  34270. }
  34271. declare module BABYLON {
  34272. /**
  34273. * Google Daydream controller
  34274. */
  34275. class DaydreamController extends WebVRController {
  34276. /**
  34277. * Base Url for the controller model.
  34278. */
  34279. static MODEL_BASE_URL: string;
  34280. /**
  34281. * File name for the controller model.
  34282. */
  34283. static MODEL_FILENAME: string;
  34284. /**
  34285. * Gamepad Id prefix used to identify Daydream Controller.
  34286. */
  34287. static readonly GAMEPAD_ID_PREFIX: string;
  34288. /**
  34289. * Creates a new DaydreamController from a gamepad
  34290. * @param vrGamepad the gamepad that the controller should be created from
  34291. */
  34292. constructor(vrGamepad: any);
  34293. /**
  34294. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34295. * @param scene scene in which to add meshes
  34296. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34297. */
  34298. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34299. /**
  34300. * Called once for each button that changed state since the last frame
  34301. * @param buttonIdx Which button index changed
  34302. * @param state New state of the button
  34303. * @param changes Which properties on the state changed since last frame
  34304. */
  34305. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34306. }
  34307. }
  34308. declare module BABYLON {
  34309. /**
  34310. * Gear VR Controller
  34311. */
  34312. class GearVRController extends WebVRController {
  34313. /**
  34314. * Base Url for the controller model.
  34315. */
  34316. static MODEL_BASE_URL: string;
  34317. /**
  34318. * File name for the controller model.
  34319. */
  34320. static MODEL_FILENAME: string;
  34321. private _maxRotationDistFromHeadset;
  34322. private _draggedRoomRotation;
  34323. private _tmpVector;
  34324. /**
  34325. * Gamepad Id prefix used to identify this controller.
  34326. */
  34327. static readonly GAMEPAD_ID_PREFIX: string;
  34328. private readonly _buttonIndexToObservableNameMap;
  34329. /**
  34330. * Creates a new GearVRController from a gamepad
  34331. * @param vrGamepad the gamepad that the controller should be created from
  34332. */
  34333. constructor(vrGamepad: any);
  34334. /**
  34335. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34336. * @param poseData raw pose fromthe device
  34337. */
  34338. updateFromDevice(poseData: DevicePose): void;
  34339. /**
  34340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34341. * @param scene scene in which to add meshes
  34342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34343. */
  34344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34345. /**
  34346. * Called once for each button that changed state since the last frame
  34347. * @param buttonIdx Which button index changed
  34348. * @param state New state of the button
  34349. * @param changes Which properties on the state changed since last frame
  34350. */
  34351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34352. }
  34353. }
  34354. declare module BABYLON {
  34355. /**
  34356. * Generic Controller
  34357. */
  34358. class GenericController extends WebVRController {
  34359. /**
  34360. * Base Url for the controller model.
  34361. */
  34362. static readonly MODEL_BASE_URL: string;
  34363. /**
  34364. * File name for the controller model.
  34365. */
  34366. static readonly MODEL_FILENAME: string;
  34367. /**
  34368. * Creates a new GenericController from a gamepad
  34369. * @param vrGamepad the gamepad that the controller should be created from
  34370. */
  34371. constructor(vrGamepad: any);
  34372. /**
  34373. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34374. * @param scene scene in which to add meshes
  34375. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34376. */
  34377. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34378. /**
  34379. * Called once for each button that changed state since the last frame
  34380. * @param buttonIdx Which button index changed
  34381. * @param state New state of the button
  34382. * @param changes Which properties on the state changed since last frame
  34383. */
  34384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34385. }
  34386. }
  34387. declare module BABYLON {
  34388. /**
  34389. * Oculus Touch Controller
  34390. */
  34391. class OculusTouchController extends WebVRController {
  34392. /**
  34393. * Base Url for the controller model.
  34394. */
  34395. static MODEL_BASE_URL: string;
  34396. /**
  34397. * File name for the left controller model.
  34398. */
  34399. static MODEL_LEFT_FILENAME: string;
  34400. /**
  34401. * File name for the right controller model.
  34402. */
  34403. static MODEL_RIGHT_FILENAME: string;
  34404. /**
  34405. * Fired when the secondary trigger on this controller is modified
  34406. */
  34407. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34408. /**
  34409. * Fired when the thumb rest on this controller is modified
  34410. */
  34411. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34412. /**
  34413. * Creates a new OculusTouchController from a gamepad
  34414. * @param vrGamepad the gamepad that the controller should be created from
  34415. */
  34416. constructor(vrGamepad: any);
  34417. /**
  34418. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34419. * @param scene scene in which to add meshes
  34420. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34421. */
  34422. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34423. /**
  34424. * Fired when the A button on this controller is modified
  34425. */
  34426. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34427. /**
  34428. * Fired when the B button on this controller is modified
  34429. */
  34430. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34431. /**
  34432. * Fired when the X button on this controller is modified
  34433. */
  34434. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34435. /**
  34436. * Fired when the Y button on this controller is modified
  34437. */
  34438. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34439. /**
  34440. * Called once for each button that changed state since the last frame
  34441. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34442. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34443. * 2) secondary trigger (same)
  34444. * 3) A (right) X (left), touch, pressed = value
  34445. * 4) B / Y
  34446. * 5) thumb rest
  34447. * @param buttonIdx Which button index changed
  34448. * @param state New state of the button
  34449. * @param changes Which properties on the state changed since last frame
  34450. */
  34451. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34452. }
  34453. }
  34454. declare module BABYLON {
  34455. /**
  34456. * Defines the types of pose enabled controllers that are supported
  34457. */
  34458. enum PoseEnabledControllerType {
  34459. /**
  34460. * HTC Vive
  34461. */
  34462. VIVE = 0,
  34463. /**
  34464. * Oculus Rift
  34465. */
  34466. OCULUS = 1,
  34467. /**
  34468. * Windows mixed reality
  34469. */
  34470. WINDOWS = 2,
  34471. /**
  34472. * Samsung gear VR
  34473. */
  34474. GEAR_VR = 3,
  34475. /**
  34476. * Google Daydream
  34477. */
  34478. DAYDREAM = 4,
  34479. /**
  34480. * Generic
  34481. */
  34482. GENERIC = 5
  34483. }
  34484. /**
  34485. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34486. */
  34487. interface MutableGamepadButton {
  34488. /**
  34489. * Value of the button/trigger
  34490. */
  34491. value: number;
  34492. /**
  34493. * If the button/trigger is currently touched
  34494. */
  34495. touched: boolean;
  34496. /**
  34497. * If the button/trigger is currently pressed
  34498. */
  34499. pressed: boolean;
  34500. }
  34501. /**
  34502. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34503. * @hidden
  34504. */
  34505. interface ExtendedGamepadButton extends GamepadButton {
  34506. /**
  34507. * If the button/trigger is currently pressed
  34508. */
  34509. readonly pressed: boolean;
  34510. /**
  34511. * If the button/trigger is currently touched
  34512. */
  34513. readonly touched: boolean;
  34514. /**
  34515. * Value of the button/trigger
  34516. */
  34517. readonly value: number;
  34518. }
  34519. /**
  34520. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34521. */
  34522. class PoseEnabledControllerHelper {
  34523. /**
  34524. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34525. * @param vrGamepad the gamepad to initialized
  34526. * @returns a vr controller of the type the gamepad identified as
  34527. */
  34528. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  34529. }
  34530. /**
  34531. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34532. */
  34533. class PoseEnabledController extends Gamepad implements PoseControlled {
  34534. private _deviceRoomPosition;
  34535. private _deviceRoomRotationQuaternion;
  34536. /**
  34537. * The device position in babylon space
  34538. */
  34539. devicePosition: Vector3;
  34540. /**
  34541. * The device rotation in babylon space
  34542. */
  34543. deviceRotationQuaternion: Quaternion;
  34544. /**
  34545. * The scale factor of the device in babylon space
  34546. */
  34547. deviceScaleFactor: number;
  34548. /**
  34549. * (Likely devicePosition should be used instead) The device position in its room space
  34550. */
  34551. position: Vector3;
  34552. /**
  34553. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  34554. */
  34555. rotationQuaternion: Quaternion;
  34556. /**
  34557. * The type of controller (Eg. Windows mixed reality)
  34558. */
  34559. controllerType: PoseEnabledControllerType;
  34560. protected _calculatedPosition: Vector3;
  34561. private _calculatedRotation;
  34562. /**
  34563. * The raw pose from the device
  34564. */
  34565. rawPose: DevicePose;
  34566. /**
  34567. * Internal, the mesh attached to the controller
  34568. * @hidden
  34569. */
  34570. _mesh: Nullable<AbstractMesh>;
  34571. private _poseControlledCamera;
  34572. private _leftHandSystemQuaternion;
  34573. /**
  34574. * Internal, matrix used to convert room space to babylon space
  34575. * @hidden
  34576. */
  34577. _deviceToWorld: Matrix;
  34578. /**
  34579. * Node to be used when casting a ray from the controller
  34580. * @hidden
  34581. */
  34582. _pointingPoseNode: Nullable<AbstractMesh>;
  34583. /**
  34584. * Name of the child mesh that can be used to cast a ray from the controller
  34585. */
  34586. static readonly POINTING_POSE: string;
  34587. /**
  34588. * Creates a new PoseEnabledController from a gamepad
  34589. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34590. */
  34591. constructor(browserGamepad: any);
  34592. private _workingMatrix;
  34593. /**
  34594. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34595. */
  34596. update(): void;
  34597. /**
  34598. * Updates only the pose device and mesh without doing any button event checking
  34599. */
  34600. protected _updatePoseAndMesh(): void;
  34601. /**
  34602. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34603. * @param poseData raw pose fromthe device
  34604. */
  34605. updateFromDevice(poseData: DevicePose): void;
  34606. /**
  34607. * @hidden
  34608. */
  34609. _meshAttachedObservable: Observable<AbstractMesh>;
  34610. /**
  34611. * Attaches a mesh to the controller
  34612. * @param mesh the mesh to be attached
  34613. */
  34614. attachToMesh(mesh: AbstractMesh): void;
  34615. /**
  34616. * Attaches the controllers mesh to a camera
  34617. * @param camera the camera the mesh should be attached to
  34618. */
  34619. attachToPoseControlledCamera(camera: TargetCamera): void;
  34620. /**
  34621. * Disposes of the controller
  34622. */
  34623. dispose(): void;
  34624. /**
  34625. * The mesh that is attached to the controller
  34626. */
  34627. readonly mesh: Nullable<AbstractMesh>;
  34628. /**
  34629. * Gets the ray of the controller in the direction the controller is pointing
  34630. * @param length the length the resulting ray should be
  34631. * @returns a ray in the direction the controller is pointing
  34632. */
  34633. getForwardRay(length?: number): Ray;
  34634. }
  34635. }
  34636. declare module BABYLON {
  34637. /**
  34638. * Vive Controller
  34639. */
  34640. class ViveController extends WebVRController {
  34641. /**
  34642. * Base Url for the controller model.
  34643. */
  34644. static MODEL_BASE_URL: string;
  34645. /**
  34646. * File name for the controller model.
  34647. */
  34648. static MODEL_FILENAME: string;
  34649. /**
  34650. * Creates a new ViveController from a gamepad
  34651. * @param vrGamepad the gamepad that the controller should be created from
  34652. */
  34653. constructor(vrGamepad: any);
  34654. /**
  34655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34656. * @param scene scene in which to add meshes
  34657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34658. */
  34659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34660. /**
  34661. * Fired when the left button on this controller is modified
  34662. */
  34663. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34664. /**
  34665. * Fired when the right button on this controller is modified
  34666. */
  34667. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34668. /**
  34669. * Fired when the menu button on this controller is modified
  34670. */
  34671. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34672. /**
  34673. * Called once for each button that changed state since the last frame
  34674. * Vive mapping:
  34675. * 0: touchpad
  34676. * 1: trigger
  34677. * 2: left AND right buttons
  34678. * 3: menu button
  34679. * @param buttonIdx Which button index changed
  34680. * @param state New state of the button
  34681. * @param changes Which properties on the state changed since last frame
  34682. */
  34683. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34684. }
  34685. }
  34686. declare module BABYLON {
  34687. /**
  34688. * Defines the WebVRController object that represents controllers tracked in 3D space
  34689. */
  34690. abstract class WebVRController extends PoseEnabledController {
  34691. /**
  34692. * Internal, the default controller model for the controller
  34693. */
  34694. protected _defaultModel: AbstractMesh;
  34695. /**
  34696. * Fired when the trigger state has changed
  34697. */
  34698. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34699. /**
  34700. * Fired when the main button state has changed
  34701. */
  34702. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34703. /**
  34704. * Fired when the secondary button state has changed
  34705. */
  34706. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34707. /**
  34708. * Fired when the pad state has changed
  34709. */
  34710. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34711. /**
  34712. * Fired when controllers stick values have changed
  34713. */
  34714. onPadValuesChangedObservable: Observable<StickValues>;
  34715. /**
  34716. * Array of button availible on the controller
  34717. */
  34718. protected _buttons: Array<MutableGamepadButton>;
  34719. private _onButtonStateChange;
  34720. /**
  34721. * Fired when a controller button's state has changed
  34722. * @param callback the callback containing the button that was modified
  34723. */
  34724. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34725. /**
  34726. * X and Y axis corrisponding to the controllers joystick
  34727. */
  34728. pad: StickValues;
  34729. /**
  34730. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34731. */
  34732. hand: string;
  34733. /**
  34734. * The default controller model for the controller
  34735. */
  34736. readonly defaultModel: AbstractMesh;
  34737. /**
  34738. * Creates a new WebVRController from a gamepad
  34739. * @param vrGamepad the gamepad that the WebVRController should be created from
  34740. */
  34741. constructor(vrGamepad: any);
  34742. /**
  34743. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34744. */
  34745. update(): void;
  34746. /**
  34747. * Function to be called when a button is modified
  34748. */
  34749. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34750. /**
  34751. * Loads a mesh and attaches it to the controller
  34752. * @param scene the scene the mesh should be added to
  34753. * @param meshLoaded callback for when the mesh has been loaded
  34754. */
  34755. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34756. private _setButtonValue;
  34757. private _changes;
  34758. private _checkChanges;
  34759. /**
  34760. * Disposes of th webVRCOntroller
  34761. */
  34762. dispose(): void;
  34763. }
  34764. }
  34765. declare module BABYLON {
  34766. /**
  34767. * Defines the WindowsMotionController object that the state of the windows motion controller
  34768. */
  34769. class WindowsMotionController extends WebVRController {
  34770. /**
  34771. * The base url used to load the left and right controller models
  34772. */
  34773. static MODEL_BASE_URL: string;
  34774. /**
  34775. * The name of the left controller model file
  34776. */
  34777. static MODEL_LEFT_FILENAME: string;
  34778. /**
  34779. * The name of the right controller model file
  34780. */
  34781. static MODEL_RIGHT_FILENAME: string;
  34782. /**
  34783. * The controller name prefix for this controller type
  34784. */
  34785. static readonly GAMEPAD_ID_PREFIX: string;
  34786. /**
  34787. * The controller id pattern for this controller type
  34788. */
  34789. private static readonly GAMEPAD_ID_PATTERN;
  34790. private _loadedMeshInfo;
  34791. private readonly _mapping;
  34792. /**
  34793. * Fired when the trackpad on this controller is clicked
  34794. */
  34795. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34796. /**
  34797. * Fired when the trackpad on this controller is modified
  34798. */
  34799. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34800. /**
  34801. * The current x and y values of this controller's trackpad
  34802. */
  34803. trackpad: StickValues;
  34804. /**
  34805. * Creates a new WindowsMotionController from a gamepad
  34806. * @param vrGamepad the gamepad that the controller should be created from
  34807. */
  34808. constructor(vrGamepad: any);
  34809. /**
  34810. * Fired when the trigger on this controller is modified
  34811. */
  34812. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34813. /**
  34814. * Fired when the menu button on this controller is modified
  34815. */
  34816. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34817. /**
  34818. * Fired when the grip button on this controller is modified
  34819. */
  34820. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34821. /**
  34822. * Fired when the thumbstick button on this controller is modified
  34823. */
  34824. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34825. /**
  34826. * Fired when the touchpad button on this controller is modified
  34827. */
  34828. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34829. /**
  34830. * Fired when the touchpad values on this controller are modified
  34831. */
  34832. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34833. private _updateTrackpad;
  34834. /**
  34835. * Called once per frame by the engine.
  34836. */
  34837. update(): void;
  34838. /**
  34839. * Called once for each button that changed state since the last frame
  34840. * @param buttonIdx Which button index changed
  34841. * @param state New state of the button
  34842. * @param changes Which properties on the state changed since last frame
  34843. */
  34844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34845. /**
  34846. * Moves the buttons on the controller mesh based on their current state
  34847. * @param buttonName the name of the button to move
  34848. * @param buttonValue the value of the button which determines the buttons new position
  34849. */
  34850. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34851. /**
  34852. * Moves the axis on the controller mesh based on its current state
  34853. * @param axis the index of the axis
  34854. * @param axisValue the value of the axis which determines the meshes new position
  34855. * @hidden
  34856. */
  34857. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34858. /**
  34859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34860. * @param scene scene in which to add meshes
  34861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34862. */
  34863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34864. /**
  34865. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34866. * can be transformed by button presses and axes values, based on this._mapping.
  34867. *
  34868. * @param scene scene in which the meshes exist
  34869. * @param meshes list of meshes that make up the controller model to process
  34870. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34871. */
  34872. private processModel;
  34873. private createMeshInfo;
  34874. /**
  34875. * Gets the ray of the controller in the direction the controller is pointing
  34876. * @param length the length the resulting ray should be
  34877. * @returns a ray in the direction the controller is pointing
  34878. */
  34879. getForwardRay(length?: number): Ray;
  34880. /**
  34881. * Disposes of the controller
  34882. */
  34883. dispose(): void;
  34884. }
  34885. }
  34886. declare module BABYLON {
  34887. /**
  34888. * Interface to implement to create a shadow generator compatible with BJS.
  34889. */
  34890. interface IShadowGenerator {
  34891. /**
  34892. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34893. * @returns The render target texture if present otherwise, null
  34894. */
  34895. getShadowMap(): Nullable<RenderTargetTexture>;
  34896. /**
  34897. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34898. * @returns The render target texture if the shadow map is present otherwise, null
  34899. */
  34900. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34901. /**
  34902. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34903. * @param subMesh The submesh we want to render in the shadow map
  34904. * @param useInstances Defines wether will draw in the map using instances
  34905. * @returns true if ready otherwise, false
  34906. */
  34907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34908. /**
  34909. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34910. * @param defines Defines of the material we want to update
  34911. * @param lightIndex Index of the light in the enabled light list of the material
  34912. */
  34913. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34914. /**
  34915. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34916. * defined in the generator but impacting the effect).
  34917. * It implies the unifroms available on the materials are the standard BJS ones.
  34918. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34919. * @param effect The effect we are binfing the information for
  34920. */
  34921. bindShadowLight(lightIndex: string, effect: Effect): void;
  34922. /**
  34923. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34924. * (eq to shadow prjection matrix * light transform matrix)
  34925. * @returns The transform matrix used to create the shadow map
  34926. */
  34927. getTransformMatrix(): Matrix;
  34928. /**
  34929. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34930. * Cube and 2D textures for instance.
  34931. */
  34932. recreateShadowMap(): void;
  34933. /**
  34934. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34935. * @param onCompiled Callback triggered at the and of the effects compilation
  34936. * @param options Sets of optional options forcing the compilation with different modes
  34937. */
  34938. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34939. useInstances: boolean;
  34940. }>): void;
  34941. /**
  34942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34943. * @param options Sets of optional options forcing the compilation with different modes
  34944. * @returns A promise that resolves when the compilation completes
  34945. */
  34946. forceCompilationAsync(options?: Partial<{
  34947. useInstances: boolean;
  34948. }>): Promise<void>;
  34949. /**
  34950. * Serializes the shadow generator setup to a json object.
  34951. * @returns The serialized JSON object
  34952. */
  34953. serialize(): any;
  34954. /**
  34955. * Disposes the Shadow map and related Textures and effects.
  34956. */
  34957. dispose(): void;
  34958. }
  34959. /**
  34960. * Default implementation IShadowGenerator.
  34961. * This is the main object responsible of generating shadows in the framework.
  34962. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34963. */
  34964. class ShadowGenerator implements IShadowGenerator {
  34965. /**
  34966. * Shadow generator mode None: no filtering applied.
  34967. */
  34968. static readonly FILTER_NONE: number;
  34969. /**
  34970. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34971. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34972. */
  34973. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34974. /**
  34975. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34976. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34977. */
  34978. static readonly FILTER_POISSONSAMPLING: number;
  34979. /**
  34980. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34981. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34982. */
  34983. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34984. /**
  34985. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34986. * edge artifacts on steep falloff.
  34987. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34988. */
  34989. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34990. /**
  34991. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34992. * edge artifacts on steep falloff.
  34993. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34994. */
  34995. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34996. /**
  34997. * Shadow generator mode PCF: Percentage Closer Filtering
  34998. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34999. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  35000. */
  35001. static readonly FILTER_PCF: number;
  35002. /**
  35003. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  35004. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  35005. * Contact Hardening
  35006. */
  35007. static readonly FILTER_PCSS: number;
  35008. /**
  35009. * Reserved for PCF and PCSS
  35010. * Highest Quality.
  35011. *
  35012. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  35013. *
  35014. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  35015. */
  35016. static readonly QUALITY_HIGH: number;
  35017. /**
  35018. * Reserved for PCF and PCSS
  35019. * Good tradeoff for quality/perf cross devices
  35020. *
  35021. * Execute PCF on a 3*3 kernel.
  35022. *
  35023. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  35024. */
  35025. static readonly QUALITY_MEDIUM: number;
  35026. /**
  35027. * Reserved for PCF and PCSS
  35028. * The lowest quality but the fastest.
  35029. *
  35030. * Execute PCF on a 1*1 kernel.
  35031. *
  35032. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  35033. */
  35034. static readonly QUALITY_LOW: number;
  35035. private _bias;
  35036. /**
  35037. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  35038. */
  35039. /**
  35040. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  35041. */
  35042. bias: number;
  35043. private _normalBias;
  35044. /**
  35045. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35046. */
  35047. /**
  35048. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35049. */
  35050. normalBias: number;
  35051. private _blurBoxOffset;
  35052. /**
  35053. * Gets the blur box offset: offset applied during the blur pass.
  35054. * Only usefull if useKernelBlur = false
  35055. */
  35056. /**
  35057. * Sets the blur box offset: offset applied during the blur pass.
  35058. * Only usefull if useKernelBlur = false
  35059. */
  35060. blurBoxOffset: number;
  35061. private _blurScale;
  35062. /**
  35063. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  35064. * 2 means half of the size.
  35065. */
  35066. /**
  35067. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  35068. * 2 means half of the size.
  35069. */
  35070. blurScale: number;
  35071. private _blurKernel;
  35072. /**
  35073. * Gets the blur kernel: kernel size of the blur pass.
  35074. * Only usefull if useKernelBlur = true
  35075. */
  35076. /**
  35077. * Sets the blur kernel: kernel size of the blur pass.
  35078. * Only usefull if useKernelBlur = true
  35079. */
  35080. blurKernel: number;
  35081. private _useKernelBlur;
  35082. /**
  35083. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  35084. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35085. */
  35086. /**
  35087. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  35088. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35089. */
  35090. useKernelBlur: boolean;
  35091. private _depthScale;
  35092. /**
  35093. * Gets the depth scale used in ESM mode.
  35094. */
  35095. /**
  35096. * Sets the depth scale used in ESM mode.
  35097. * This can override the scale stored on the light.
  35098. */
  35099. depthScale: number;
  35100. private _filter;
  35101. /**
  35102. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  35103. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35104. */
  35105. /**
  35106. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  35107. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35108. */
  35109. filter: number;
  35110. /**
  35111. * Gets if the current filter is set to Poisson Sampling.
  35112. */
  35113. /**
  35114. * Sets the current filter to Poisson Sampling.
  35115. */
  35116. usePoissonSampling: boolean;
  35117. /**
  35118. * Gets if the current filter is set to VSM.
  35119. * DEPRECATED. Should use useExponentialShadowMap instead.
  35120. */
  35121. /**
  35122. * Sets the current filter is to VSM.
  35123. * DEPRECATED. Should use useExponentialShadowMap instead.
  35124. */
  35125. useVarianceShadowMap: boolean;
  35126. /**
  35127. * Gets if the current filter is set to blurred VSM.
  35128. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35129. */
  35130. /**
  35131. * Sets the current filter is to blurred VSM.
  35132. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35133. */
  35134. useBlurVarianceShadowMap: boolean;
  35135. /**
  35136. * Gets if the current filter is set to ESM.
  35137. */
  35138. /**
  35139. * Sets the current filter is to ESM.
  35140. */
  35141. useExponentialShadowMap: boolean;
  35142. /**
  35143. * Gets if the current filter is set to filtered ESM.
  35144. */
  35145. /**
  35146. * Gets if the current filter is set to filtered ESM.
  35147. */
  35148. useBlurExponentialShadowMap: boolean;
  35149. /**
  35150. * Gets if the current filter is set to "close ESM" (using the inverse of the
  35151. * exponential to prevent steep falloff artifacts).
  35152. */
  35153. /**
  35154. * Sets the current filter to "close ESM" (using the inverse of the
  35155. * exponential to prevent steep falloff artifacts).
  35156. */
  35157. useCloseExponentialShadowMap: boolean;
  35158. /**
  35159. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  35160. * exponential to prevent steep falloff artifacts).
  35161. */
  35162. /**
  35163. * Sets the current filter to filtered "close ESM" (using the inverse of the
  35164. * exponential to prevent steep falloff artifacts).
  35165. */
  35166. useBlurCloseExponentialShadowMap: boolean;
  35167. /**
  35168. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  35169. */
  35170. /**
  35171. * Sets the current filter to "PCF" (percentage closer filtering).
  35172. */
  35173. usePercentageCloserFiltering: boolean;
  35174. private _filteringQuality;
  35175. /**
  35176. * Gets the PCF or PCSS Quality.
  35177. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35178. */
  35179. /**
  35180. * Sets the PCF or PCSS Quality.
  35181. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35182. */
  35183. filteringQuality: number;
  35184. /**
  35185. * Gets if the current filter is set to "PCSS" (contact hardening).
  35186. */
  35187. /**
  35188. * Sets the current filter to "PCSS" (contact hardening).
  35189. */
  35190. useContactHardeningShadow: boolean;
  35191. private _contactHardeningLightSizeUVRatio;
  35192. /**
  35193. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35194. * Using a ratio helps keeping shape stability independently of the map size.
  35195. *
  35196. * It does not account for the light projection as it was having too much
  35197. * instability during the light setup or during light position changes.
  35198. *
  35199. * Only valid if useContactHardeningShadow is true.
  35200. */
  35201. /**
  35202. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35203. * Using a ratio helps keeping shape stability independently of the map size.
  35204. *
  35205. * It does not account for the light projection as it was having too much
  35206. * instability during the light setup or during light position changes.
  35207. *
  35208. * Only valid if useContactHardeningShadow is true.
  35209. */
  35210. contactHardeningLightSizeUVRatio: number;
  35211. private _darkness;
  35212. /**
  35213. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  35214. * 0 means strongest and 1 would means no shadow.
  35215. * @returns the darkness.
  35216. */
  35217. getDarkness(): number;
  35218. /**
  35219. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  35220. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  35221. * @returns the shadow generator allowing fluent coding.
  35222. */
  35223. setDarkness(darkness: number): ShadowGenerator;
  35224. private _transparencyShadow;
  35225. /**
  35226. * Sets the ability to have transparent shadow (boolean).
  35227. * @param transparent True if transparent else False
  35228. * @returns the shadow generator allowing fluent coding
  35229. */
  35230. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  35231. private _shadowMap;
  35232. private _shadowMap2;
  35233. /**
  35234. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35235. * @returns The render target texture if present otherwise, null
  35236. */
  35237. getShadowMap(): Nullable<RenderTargetTexture>;
  35238. /**
  35239. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35240. * @returns The render target texture if the shadow map is present otherwise, null
  35241. */
  35242. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35243. /**
  35244. * Helper function to add a mesh and its descendants to the list of shadow casters.
  35245. * @param mesh Mesh to add
  35246. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  35247. * @returns the Shadow Generator itself
  35248. */
  35249. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35250. /**
  35251. * Helper function to remove a mesh and its descendants from the list of shadow casters
  35252. * @param mesh Mesh to remove
  35253. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  35254. * @returns the Shadow Generator itself
  35255. */
  35256. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35257. /**
  35258. * Controls the extent to which the shadows fade out at the edge of the frustum
  35259. * Used only by directionals and spots
  35260. */
  35261. frustumEdgeFalloff: number;
  35262. private _light;
  35263. /**
  35264. * Returns the associated light object.
  35265. * @returns the light generating the shadow
  35266. */
  35267. getLight(): IShadowLight;
  35268. /**
  35269. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  35270. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  35271. * It might on the other hand introduce peter panning.
  35272. */
  35273. forceBackFacesOnly: boolean;
  35274. private _scene;
  35275. private _lightDirection;
  35276. private _effect;
  35277. private _viewMatrix;
  35278. private _projectionMatrix;
  35279. private _transformMatrix;
  35280. private _cachedPosition;
  35281. private _cachedDirection;
  35282. private _cachedDefines;
  35283. private _currentRenderID;
  35284. private _boxBlurPostprocess;
  35285. private _kernelBlurXPostprocess;
  35286. private _kernelBlurYPostprocess;
  35287. private _blurPostProcesses;
  35288. private _mapSize;
  35289. private _currentFaceIndex;
  35290. private _currentFaceIndexCache;
  35291. private _textureType;
  35292. private _defaultTextureMatrix;
  35293. /**
  35294. * Creates a ShadowGenerator object.
  35295. * A ShadowGenerator is the required tool to use the shadows.
  35296. * Each light casting shadows needs to use its own ShadowGenerator.
  35297. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  35298. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  35299. * @param light The light object generating the shadows.
  35300. * @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.
  35301. */
  35302. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  35303. private _initializeGenerator;
  35304. private _initializeShadowMap;
  35305. private _initializeBlurRTTAndPostProcesses;
  35306. private _renderForShadowMap;
  35307. private _renderSubMeshForShadowMap;
  35308. private _applyFilterValues;
  35309. /**
  35310. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35311. * @param onCompiled Callback triggered at the and of the effects compilation
  35312. * @param options Sets of optional options forcing the compilation with different modes
  35313. */
  35314. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35315. useInstances: boolean;
  35316. }>): void;
  35317. /**
  35318. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35319. * @param options Sets of optional options forcing the compilation with different modes
  35320. * @returns A promise that resolves when the compilation completes
  35321. */
  35322. forceCompilationAsync(options?: Partial<{
  35323. useInstances: boolean;
  35324. }>): Promise<void>;
  35325. /**
  35326. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35327. * @param subMesh The submesh we want to render in the shadow map
  35328. * @param useInstances Defines wether will draw in the map using instances
  35329. * @returns true if ready otherwise, false
  35330. */
  35331. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35332. /**
  35333. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35334. * @param defines Defines of the material we want to update
  35335. * @param lightIndex Index of the light in the enabled light list of the material
  35336. */
  35337. prepareDefines(defines: any, lightIndex: number): void;
  35338. /**
  35339. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35340. * defined in the generator but impacting the effect).
  35341. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35342. * @param effect The effect we are binfing the information for
  35343. */
  35344. bindShadowLight(lightIndex: string, effect: Effect): void;
  35345. /**
  35346. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35347. * (eq to shadow prjection matrix * light transform matrix)
  35348. * @returns The transform matrix used to create the shadow map
  35349. */
  35350. getTransformMatrix(): Matrix;
  35351. /**
  35352. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35353. * Cube and 2D textures for instance.
  35354. */
  35355. recreateShadowMap(): void;
  35356. private _disposeBlurPostProcesses;
  35357. private _disposeRTTandPostProcesses;
  35358. /**
  35359. * Disposes the ShadowGenerator.
  35360. * Returns nothing.
  35361. */
  35362. dispose(): void;
  35363. /**
  35364. * Serializes the shadow generator setup to a json object.
  35365. * @returns The serialized JSON object
  35366. */
  35367. serialize(): any;
  35368. /**
  35369. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35370. * @param parsedShadowGenerator The JSON object to parse
  35371. * @param scene The scene to create the shadow map for
  35372. * @returns The parsed shadow generator
  35373. */
  35374. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35375. }
  35376. }
  35377. declare module BABYLON {
  35378. /**
  35379. * Defines the shadow generator component responsible to manage any shadow generators
  35380. * in a given scene.
  35381. */
  35382. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  35383. /**
  35384. * The component name helpfull to identify the component in the list of scene components.
  35385. */
  35386. readonly name: string;
  35387. /**
  35388. * The scene the component belongs to.
  35389. */
  35390. scene: Scene;
  35391. /**
  35392. * Creates a new instance of the component for the given scene
  35393. * @param scene Defines the scene to register the component in
  35394. */
  35395. constructor(scene: Scene);
  35396. /**
  35397. * Registers the component in a given scene
  35398. */
  35399. register(): void;
  35400. /**
  35401. * Rebuilds the elements related to this component in case of
  35402. * context lost for instance.
  35403. */
  35404. rebuild(): void;
  35405. /**
  35406. * Serializes the component data to the specified json object
  35407. * @param serializationObject The object to serialize to
  35408. */
  35409. serialize(serializationObject: any): void;
  35410. /**
  35411. * Adds all the element from the container to the scene
  35412. * @param container the container holding the elements
  35413. */
  35414. addFromContainer(container: AbstractScene): void;
  35415. /**
  35416. * Removes all the elements in the container from the scene
  35417. * @param container contains the elements to remove
  35418. */
  35419. removeFromContainer(container: AbstractScene): void;
  35420. /**
  35421. * Rebuilds the elements related to this component in case of
  35422. * context lost for instance.
  35423. */
  35424. dispose(): void;
  35425. private _gatherRenderTargets;
  35426. }
  35427. }
  35428. declare module BABYLON {
  35429. }
  35430. declare module BABYLON {
  35431. /**
  35432. * Particle emitter emitting particles from the inside of a box.
  35433. * It emits the particles randomly between 2 given directions.
  35434. */
  35435. class BoxParticleEmitter implements IParticleEmitterType {
  35436. /**
  35437. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35438. */
  35439. direction1: Vector3;
  35440. /**
  35441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35442. */
  35443. direction2: Vector3;
  35444. /**
  35445. * 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.
  35446. */
  35447. minEmitBox: Vector3;
  35448. /**
  35449. * 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.
  35450. */
  35451. maxEmitBox: Vector3;
  35452. /**
  35453. * Creates a new instance BoxParticleEmitter
  35454. */
  35455. constructor();
  35456. /**
  35457. * Called by the particle System when the direction is computed for the created particle.
  35458. * @param worldMatrix is the world matrix of the particle system
  35459. * @param directionToUpdate is the direction vector to update with the result
  35460. * @param particle is the particle we are computed the direction for
  35461. */
  35462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35463. /**
  35464. * Called by the particle System when the position is computed for the created particle.
  35465. * @param worldMatrix is the world matrix of the particle system
  35466. * @param positionToUpdate is the position vector to update with the result
  35467. * @param particle is the particle we are computed the position for
  35468. */
  35469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35470. /**
  35471. * Clones the current emitter and returns a copy of it
  35472. * @returns the new emitter
  35473. */
  35474. clone(): BoxParticleEmitter;
  35475. /**
  35476. * Called by the GPUParticleSystem to setup the update shader
  35477. * @param effect defines the update shader
  35478. */
  35479. applyToShader(effect: Effect): void;
  35480. /**
  35481. * Returns a string to use to update the GPU particles update shader
  35482. * @returns a string containng the defines string
  35483. */
  35484. getEffectDefines(): string;
  35485. /**
  35486. * Returns the string "BoxParticleEmitter"
  35487. * @returns a string containing the class name
  35488. */
  35489. getClassName(): string;
  35490. /**
  35491. * Serializes the particle system to a JSON object.
  35492. * @returns the JSON object
  35493. */
  35494. serialize(): any;
  35495. /**
  35496. * Parse properties from a JSON object
  35497. * @param serializationObject defines the JSON object
  35498. */
  35499. parse(serializationObject: any): void;
  35500. }
  35501. }
  35502. declare module BABYLON {
  35503. /**
  35504. * Particle emitter emitting particles from the inside of a cone.
  35505. * It emits the particles alongside the cone volume from the base to the particle.
  35506. * The emission direction might be randomized.
  35507. */
  35508. class ConeParticleEmitter implements IParticleEmitterType {
  35509. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35510. directionRandomizer: number;
  35511. private _radius;
  35512. private _angle;
  35513. private _height;
  35514. /**
  35515. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  35516. */
  35517. radiusRange: number;
  35518. /**
  35519. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  35520. */
  35521. heightRange: number;
  35522. /**
  35523. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  35524. */
  35525. emitFromSpawnPointOnly: boolean;
  35526. /**
  35527. * Gets or sets the radius of the emission cone
  35528. */
  35529. radius: number;
  35530. /**
  35531. * Gets or sets the angle of the emission cone
  35532. */
  35533. angle: number;
  35534. private _buildHeight;
  35535. /**
  35536. * Creates a new instance ConeParticleEmitter
  35537. * @param radius the radius of the emission cone (1 by default)
  35538. * @param angles the cone base angle (PI by default)
  35539. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  35540. */
  35541. constructor(radius?: number, angle?: number,
  35542. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  35543. directionRandomizer?: number);
  35544. /**
  35545. * Called by the particle System when the direction is computed for the created particle.
  35546. * @param worldMatrix is the world matrix of the particle system
  35547. * @param directionToUpdate is the direction vector to update with the result
  35548. * @param particle is the particle we are computed the direction for
  35549. */
  35550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35551. /**
  35552. * Called by the particle System when the position is computed for the created particle.
  35553. * @param worldMatrix is the world matrix of the particle system
  35554. * @param positionToUpdate is the position vector to update with the result
  35555. * @param particle is the particle we are computed the position for
  35556. */
  35557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35558. /**
  35559. * Clones the current emitter and returns a copy of it
  35560. * @returns the new emitter
  35561. */
  35562. clone(): ConeParticleEmitter;
  35563. /**
  35564. * Called by the GPUParticleSystem to setup the update shader
  35565. * @param effect defines the update shader
  35566. */
  35567. applyToShader(effect: Effect): void;
  35568. /**
  35569. * Returns a string to use to update the GPU particles update shader
  35570. * @returns a string containng the defines string
  35571. */
  35572. getEffectDefines(): string;
  35573. /**
  35574. * Returns the string "ConeParticleEmitter"
  35575. * @returns a string containing the class name
  35576. */
  35577. getClassName(): string;
  35578. /**
  35579. * Serializes the particle system to a JSON object.
  35580. * @returns the JSON object
  35581. */
  35582. serialize(): any;
  35583. /**
  35584. * Parse properties from a JSON object
  35585. * @param serializationObject defines the JSON object
  35586. */
  35587. parse(serializationObject: any): void;
  35588. }
  35589. }
  35590. declare module BABYLON {
  35591. /**
  35592. * Particle emitter emitting particles from the inside of a cylinder.
  35593. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  35594. */
  35595. class CylinderParticleEmitter implements IParticleEmitterType {
  35596. /**
  35597. * The radius of the emission cylinder.
  35598. */
  35599. radius: number;
  35600. /**
  35601. * The height of the emission cylinder.
  35602. */
  35603. height: number;
  35604. /**
  35605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35606. */
  35607. radiusRange: number;
  35608. /**
  35609. * How much to randomize the particle direction [0-1].
  35610. */
  35611. directionRandomizer: number;
  35612. /**
  35613. * Creates a new instance CylinderParticleEmitter
  35614. * @param radius the radius of the emission cylinder (1 by default)
  35615. * @param height the height of the emission cylinder (1 by default)
  35616. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  35617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35618. */
  35619. constructor(
  35620. /**
  35621. * The radius of the emission cylinder.
  35622. */
  35623. radius?: number,
  35624. /**
  35625. * The height of the emission cylinder.
  35626. */
  35627. height?: number,
  35628. /**
  35629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35630. */
  35631. radiusRange?: number,
  35632. /**
  35633. * How much to randomize the particle direction [0-1].
  35634. */
  35635. directionRandomizer?: number);
  35636. /**
  35637. * Called by the particle System when the direction is computed for the created particle.
  35638. * @param worldMatrix is the world matrix of the particle system
  35639. * @param directionToUpdate is the direction vector to update with the result
  35640. * @param particle is the particle we are computed the direction for
  35641. */
  35642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35643. /**
  35644. * Called by the particle System when the position is computed for the created particle.
  35645. * @param worldMatrix is the world matrix of the particle system
  35646. * @param positionToUpdate is the position vector to update with the result
  35647. * @param particle is the particle we are computed the position for
  35648. */
  35649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35650. /**
  35651. * Clones the current emitter and returns a copy of it
  35652. * @returns the new emitter
  35653. */
  35654. clone(): CylinderParticleEmitter;
  35655. /**
  35656. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35657. * @param effect defines the update shader
  35658. */
  35659. applyToShader(effect: Effect): void;
  35660. /**
  35661. * Returns a string to use to update the GPU particles update shader
  35662. * @returns a string containng the defines string
  35663. */
  35664. getEffectDefines(): string;
  35665. /**
  35666. * Returns the string "CylinderParticleEmitter"
  35667. * @returns a string containing the class name
  35668. */
  35669. getClassName(): string;
  35670. /**
  35671. * Serializes the particle system to a JSON object.
  35672. * @returns the JSON object
  35673. */
  35674. serialize(): any;
  35675. /**
  35676. * Parse properties from a JSON object
  35677. * @param serializationObject defines the JSON object
  35678. */
  35679. parse(serializationObject: any): void;
  35680. }
  35681. /**
  35682. * Particle emitter emitting particles from the inside of a cylinder.
  35683. * It emits the particles randomly between two vectors.
  35684. */
  35685. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  35686. /**
  35687. * The min limit of the emission direction.
  35688. */
  35689. direction1: Vector3;
  35690. /**
  35691. * The max limit of the emission direction.
  35692. */
  35693. direction2: Vector3;
  35694. /**
  35695. * Creates a new instance CylinderDirectedParticleEmitter
  35696. * @param radius the radius of the emission cylinder (1 by default)
  35697. * @param height the height of the emission cylinder (1 by default)
  35698. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  35699. * @param direction1 the min limit of the emission direction (up vector by default)
  35700. * @param direction2 the max limit of the emission direction (up vector by default)
  35701. */
  35702. constructor(radius?: number, height?: number, radiusRange?: number,
  35703. /**
  35704. * The min limit of the emission direction.
  35705. */
  35706. direction1?: Vector3,
  35707. /**
  35708. * The max limit of the emission direction.
  35709. */
  35710. direction2?: Vector3);
  35711. /**
  35712. * Called by the particle System when the direction is computed for the created particle.
  35713. * @param worldMatrix is the world matrix of the particle system
  35714. * @param directionToUpdate is the direction vector to update with the result
  35715. * @param particle is the particle we are computed the direction for
  35716. */
  35717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35718. /**
  35719. * Clones the current emitter and returns a copy of it
  35720. * @returns the new emitter
  35721. */
  35722. clone(): CylinderDirectedParticleEmitter;
  35723. /**
  35724. * Called by the GPUParticleSystem to setup the update shader
  35725. * @param effect defines the update shader
  35726. */
  35727. applyToShader(effect: Effect): void;
  35728. /**
  35729. * Returns a string to use to update the GPU particles update shader
  35730. * @returns a string containng the defines string
  35731. */
  35732. getEffectDefines(): string;
  35733. /**
  35734. * Returns the string "CylinderDirectedParticleEmitter"
  35735. * @returns a string containing the class name
  35736. */
  35737. getClassName(): string;
  35738. /**
  35739. * Serializes the particle system to a JSON object.
  35740. * @returns the JSON object
  35741. */
  35742. serialize(): any;
  35743. /**
  35744. * Parse properties from a JSON object
  35745. * @param serializationObject defines the JSON object
  35746. */
  35747. parse(serializationObject: any): void;
  35748. }
  35749. }
  35750. declare module BABYLON {
  35751. /**
  35752. * Particle emitter emitting particles from the inside of a hemisphere.
  35753. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  35754. */
  35755. class HemisphericParticleEmitter implements IParticleEmitterType {
  35756. /**
  35757. * The radius of the emission hemisphere.
  35758. */
  35759. radius: number;
  35760. /**
  35761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35762. */
  35763. radiusRange: number;
  35764. /**
  35765. * How much to randomize the particle direction [0-1].
  35766. */
  35767. directionRandomizer: number;
  35768. /**
  35769. * Creates a new instance HemisphericParticleEmitter
  35770. * @param radius the radius of the emission hemisphere (1 by default)
  35771. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  35772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35773. */
  35774. constructor(
  35775. /**
  35776. * The radius of the emission hemisphere.
  35777. */
  35778. radius?: number,
  35779. /**
  35780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35781. */
  35782. radiusRange?: number,
  35783. /**
  35784. * How much to randomize the particle direction [0-1].
  35785. */
  35786. directionRandomizer?: number);
  35787. /**
  35788. * Called by the particle System when the direction is computed for the created particle.
  35789. * @param worldMatrix is the world matrix of the particle system
  35790. * @param directionToUpdate is the direction vector to update with the result
  35791. * @param particle is the particle we are computed the direction for
  35792. */
  35793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35794. /**
  35795. * Called by the particle System when the position is computed for the created particle.
  35796. * @param worldMatrix is the world matrix of the particle system
  35797. * @param positionToUpdate is the position vector to update with the result
  35798. * @param particle is the particle we are computed the position for
  35799. */
  35800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35801. /**
  35802. * Clones the current emitter and returns a copy of it
  35803. * @returns the new emitter
  35804. */
  35805. clone(): HemisphericParticleEmitter;
  35806. /**
  35807. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35808. * @param effect defines the update shader
  35809. */
  35810. applyToShader(effect: Effect): void;
  35811. /**
  35812. * Returns a string to use to update the GPU particles update shader
  35813. * @returns a string containng the defines string
  35814. */
  35815. getEffectDefines(): string;
  35816. /**
  35817. * Returns the string "HemisphericParticleEmitter"
  35818. * @returns a string containing the class name
  35819. */
  35820. getClassName(): string;
  35821. /**
  35822. * Serializes the particle system to a JSON object.
  35823. * @returns the JSON object
  35824. */
  35825. serialize(): any;
  35826. /**
  35827. * Parse properties from a JSON object
  35828. * @param serializationObject defines the JSON object
  35829. */
  35830. parse(serializationObject: any): void;
  35831. }
  35832. }
  35833. declare module BABYLON {
  35834. /**
  35835. * Particle emitter represents a volume emitting particles.
  35836. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  35837. */
  35838. interface IParticleEmitterType {
  35839. /**
  35840. * Called by the particle System when the direction is computed for the created particle.
  35841. * @param worldMatrix is the world matrix of the particle system
  35842. * @param directionToUpdate is the direction vector to update with the result
  35843. * @param particle is the particle we are computed the direction for
  35844. */
  35845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35846. /**
  35847. * Called by the particle System when the position is computed for the created particle.
  35848. * @param worldMatrix is the world matrix of the particle system
  35849. * @param positionToUpdate is the position vector to update with the result
  35850. * @param particle is the particle we are computed the position for
  35851. */
  35852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35853. /**
  35854. * Clones the current emitter and returns a copy of it
  35855. * @returns the new emitter
  35856. */
  35857. clone(): IParticleEmitterType;
  35858. /**
  35859. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  35860. * @param effect defines the update shader
  35861. */
  35862. applyToShader(effect: Effect): void;
  35863. /**
  35864. * Returns a string to use to update the GPU particles update shader
  35865. * @returns the effect defines string
  35866. */
  35867. getEffectDefines(): string;
  35868. /**
  35869. * Returns a string representing the class name
  35870. * @returns a string containing the class name
  35871. */
  35872. getClassName(): string;
  35873. /**
  35874. * Serializes the particle system to a JSON object.
  35875. * @returns the JSON object
  35876. */
  35877. serialize(): any;
  35878. /**
  35879. * Parse properties from a JSON object
  35880. * @param serializationObject defines the JSON object
  35881. */
  35882. parse(serializationObject: any): void;
  35883. }
  35884. }
  35885. declare module BABYLON {
  35886. /**
  35887. * Particle emitter emitting particles from a point.
  35888. * It emits the particles randomly between 2 given directions.
  35889. */
  35890. class PointParticleEmitter implements IParticleEmitterType {
  35891. /**
  35892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35893. */
  35894. direction1: Vector3;
  35895. /**
  35896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35897. */
  35898. direction2: Vector3;
  35899. /**
  35900. * Creates a new instance PointParticleEmitter
  35901. */
  35902. constructor();
  35903. /**
  35904. * Called by the particle System when the direction is computed for the created particle.
  35905. * @param worldMatrix is the world matrix of the particle system
  35906. * @param directionToUpdate is the direction vector to update with the result
  35907. * @param particle is the particle we are computed the direction for
  35908. */
  35909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35910. /**
  35911. * Called by the particle System when the position is computed for the created particle.
  35912. * @param worldMatrix is the world matrix of the particle system
  35913. * @param positionToUpdate is the position vector to update with the result
  35914. * @param particle is the particle we are computed the position for
  35915. */
  35916. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  35917. /**
  35918. * Clones the current emitter and returns a copy of it
  35919. * @returns the new emitter
  35920. */
  35921. clone(): PointParticleEmitter;
  35922. /**
  35923. * Called by the GPUParticleSystem to setup the update shader
  35924. * @param effect defines the update shader
  35925. */
  35926. applyToShader(effect: Effect): void;
  35927. /**
  35928. * Returns a string to use to update the GPU particles update shader
  35929. * @returns a string containng the defines string
  35930. */
  35931. getEffectDefines(): string;
  35932. /**
  35933. * Returns the string "PointParticleEmitter"
  35934. * @returns a string containing the class name
  35935. */
  35936. getClassName(): string;
  35937. /**
  35938. * Serializes the particle system to a JSON object.
  35939. * @returns the JSON object
  35940. */
  35941. serialize(): any;
  35942. /**
  35943. * Parse properties from a JSON object
  35944. * @param serializationObject defines the JSON object
  35945. */
  35946. parse(serializationObject: any): void;
  35947. }
  35948. }
  35949. declare module BABYLON {
  35950. /**
  35951. * Particle emitter emitting particles from the inside of a sphere.
  35952. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  35953. */
  35954. class SphereParticleEmitter implements IParticleEmitterType {
  35955. /**
  35956. * The radius of the emission sphere.
  35957. */
  35958. radius: number;
  35959. /**
  35960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35961. */
  35962. radiusRange: number;
  35963. /**
  35964. * How much to randomize the particle direction [0-1].
  35965. */
  35966. directionRandomizer: number;
  35967. /**
  35968. * Creates a new instance SphereParticleEmitter
  35969. * @param radius the radius of the emission sphere (1 by default)
  35970. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  35971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  35972. */
  35973. constructor(
  35974. /**
  35975. * The radius of the emission sphere.
  35976. */
  35977. radius?: number,
  35978. /**
  35979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  35980. */
  35981. radiusRange?: number,
  35982. /**
  35983. * How much to randomize the particle direction [0-1].
  35984. */
  35985. directionRandomizer?: number);
  35986. /**
  35987. * Called by the particle System when the direction is computed for the created particle.
  35988. * @param worldMatrix is the world matrix of the particle system
  35989. * @param directionToUpdate is the direction vector to update with the result
  35990. * @param particle is the particle we are computed the direction for
  35991. */
  35992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  35993. /**
  35994. * Called by the particle System when the position is computed for the created particle.
  35995. * @param worldMatrix is the world matrix of the particle system
  35996. * @param positionToUpdate is the position vector to update with the result
  35997. * @param particle is the particle we are computed the position for
  35998. */
  35999. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36000. /**
  36001. * Clones the current emitter and returns a copy of it
  36002. * @returns the new emitter
  36003. */
  36004. clone(): SphereParticleEmitter;
  36005. /**
  36006. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36007. * @param effect defines the update shader
  36008. */
  36009. applyToShader(effect: Effect): void;
  36010. /**
  36011. * Returns a string to use to update the GPU particles update shader
  36012. * @returns a string containng the defines string
  36013. */
  36014. getEffectDefines(): string;
  36015. /**
  36016. * Returns the string "SphereParticleEmitter"
  36017. * @returns a string containing the class name
  36018. */
  36019. getClassName(): string;
  36020. /**
  36021. * Serializes the particle system to a JSON object.
  36022. * @returns the JSON object
  36023. */
  36024. serialize(): any;
  36025. /**
  36026. * Parse properties from a JSON object
  36027. * @param serializationObject defines the JSON object
  36028. */
  36029. parse(serializationObject: any): void;
  36030. }
  36031. /**
  36032. * Particle emitter emitting particles from the inside of a sphere.
  36033. * It emits the particles randomly between two vectors.
  36034. */
  36035. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  36036. /**
  36037. * The min limit of the emission direction.
  36038. */
  36039. direction1: Vector3;
  36040. /**
  36041. * The max limit of the emission direction.
  36042. */
  36043. direction2: Vector3;
  36044. /**
  36045. * Creates a new instance SphereDirectedParticleEmitter
  36046. * @param radius the radius of the emission sphere (1 by default)
  36047. * @param direction1 the min limit of the emission direction (up vector by default)
  36048. * @param direction2 the max limit of the emission direction (up vector by default)
  36049. */
  36050. constructor(radius?: number,
  36051. /**
  36052. * The min limit of the emission direction.
  36053. */
  36054. direction1?: Vector3,
  36055. /**
  36056. * The max limit of the emission direction.
  36057. */
  36058. direction2?: Vector3);
  36059. /**
  36060. * Called by the particle System when the direction is computed for the created particle.
  36061. * @param worldMatrix is the world matrix of the particle system
  36062. * @param directionToUpdate is the direction vector to update with the result
  36063. * @param particle is the particle we are computed the direction for
  36064. */
  36065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36066. /**
  36067. * Clones the current emitter and returns a copy of it
  36068. * @returns the new emitter
  36069. */
  36070. clone(): SphereDirectedParticleEmitter;
  36071. /**
  36072. * Called by the GPUParticleSystem to setup the update shader
  36073. * @param effect defines the update shader
  36074. */
  36075. applyToShader(effect: Effect): void;
  36076. /**
  36077. * Returns a string to use to update the GPU particles update shader
  36078. * @returns a string containng the defines string
  36079. */
  36080. getEffectDefines(): string;
  36081. /**
  36082. * Returns the string "SphereDirectedParticleEmitter"
  36083. * @returns a string containing the class name
  36084. */
  36085. getClassName(): string;
  36086. /**
  36087. * Serializes the particle system to a JSON object.
  36088. * @returns the JSON object
  36089. */
  36090. serialize(): any;
  36091. /**
  36092. * Parse properties from a JSON object
  36093. * @param serializationObject defines the JSON object
  36094. */
  36095. parse(serializationObject: any): void;
  36096. }
  36097. }
  36098. declare module BABYLON {
  36099. class CannonJSPlugin implements IPhysicsEnginePlugin {
  36100. private _useDeltaForWorldStep;
  36101. world: any;
  36102. name: string;
  36103. private _physicsMaterials;
  36104. private _fixedTimeStep;
  36105. BJSCANNON: any;
  36106. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  36107. setGravity(gravity: Vector3): void;
  36108. setTimeStep(timeStep: number): void;
  36109. getTimeStep(): number;
  36110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36114. private _processChildMeshes;
  36115. removePhysicsBody(impostor: PhysicsImpostor): void;
  36116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36117. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36118. private _addMaterial;
  36119. private _checkWithEpsilon;
  36120. private _createShape;
  36121. private _createHeightmap;
  36122. private _minus90X;
  36123. private _plus90X;
  36124. private _tmpPosition;
  36125. private _tmpDeltaPosition;
  36126. private _tmpUnityRotation;
  36127. private _updatePhysicsBodyTransformation;
  36128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36130. isSupported(): boolean;
  36131. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36132. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36133. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36136. getBodyMass(impostor: PhysicsImpostor): number;
  36137. getBodyFriction(impostor: PhysicsImpostor): number;
  36138. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36139. getBodyRestitution(impostor: PhysicsImpostor): number;
  36140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36141. sleepBody(impostor: PhysicsImpostor): void;
  36142. wakeUpBody(impostor: PhysicsImpostor): void;
  36143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36144. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  36145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  36146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36147. getRadius(impostor: PhysicsImpostor): number;
  36148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36149. dispose(): void;
  36150. private _extendNamespace;
  36151. }
  36152. }
  36153. declare module BABYLON {
  36154. class OimoJSPlugin implements IPhysicsEnginePlugin {
  36155. world: any;
  36156. name: string;
  36157. BJSOIMO: any;
  36158. constructor(iterations?: number);
  36159. setGravity(gravity: Vector3): void;
  36160. setTimeStep(timeStep: number): void;
  36161. getTimeStep(): number;
  36162. private _tmpImpostorsArray;
  36163. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36164. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36165. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36166. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36167. private _tmpPositionVector;
  36168. removePhysicsBody(impostor: PhysicsImpostor): void;
  36169. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36170. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36171. isSupported(): boolean;
  36172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36179. getBodyMass(impostor: PhysicsImpostor): number;
  36180. getBodyFriction(impostor: PhysicsImpostor): number;
  36181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36182. getBodyRestitution(impostor: PhysicsImpostor): number;
  36183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36184. sleepBody(impostor: PhysicsImpostor): void;
  36185. wakeUpBody(impostor: PhysicsImpostor): void;
  36186. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36187. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  36188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  36189. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36190. getRadius(impostor: PhysicsImpostor): number;
  36191. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36192. dispose(): void;
  36193. }
  36194. }
  36195. declare var DracoDecoderModule: any;
  36196. declare var WebAssembly: any;
  36197. declare module BABYLON {
  36198. /**
  36199. * Configuration for Draco compression
  36200. */
  36201. interface IDracoCompressionConfiguration {
  36202. /**
  36203. * Configuration for the decoder.
  36204. */
  36205. decoder?: {
  36206. /**
  36207. * The url to the WebAssembly module.
  36208. */
  36209. wasmUrl?: string;
  36210. /**
  36211. * The url to the WebAssembly binary.
  36212. */
  36213. wasmBinaryUrl?: string;
  36214. /**
  36215. * The url to the fallback JavaScript module.
  36216. */
  36217. fallbackUrl?: string;
  36218. };
  36219. }
  36220. /**
  36221. * Draco compression (https://google.github.io/draco/)
  36222. *
  36223. * This class wraps the Draco module.
  36224. *
  36225. * **Encoder**
  36226. *
  36227. * The encoder is not currently implemented.
  36228. *
  36229. * **Decoder**
  36230. *
  36231. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  36232. *
  36233. * To update the configuration, use the following code:
  36234. * ```javascript
  36235. * BABYLON.DracoCompression.Configuration = {
  36236. * decoder: {
  36237. * wasmUrl: "<url to the WebAssembly library>",
  36238. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  36239. * fallbackUrl: "<url to the fallback JavaScript library>",
  36240. * }
  36241. * };
  36242. * ```
  36243. *
  36244. * 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.
  36245. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  36246. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  36247. *
  36248. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  36249. * ```javascript
  36250. * var dracoCompression = new BABYLON.DracoCompression();
  36251. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  36252. * [BABYLON.VertexBuffer.PositionKind]: 0
  36253. * });
  36254. * ```
  36255. *
  36256. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  36257. */
  36258. class DracoCompression implements IDisposable {
  36259. private static _DecoderModulePromise;
  36260. /**
  36261. * The configuration. Defaults to the following urls:
  36262. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  36263. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  36264. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  36265. */
  36266. static Configuration: IDracoCompressionConfiguration;
  36267. /**
  36268. * Returns true if the decoder is available.
  36269. */
  36270. static readonly DecoderAvailable: boolean;
  36271. /**
  36272. * Constructor
  36273. */
  36274. constructor();
  36275. /**
  36276. * Stop all async operations and release resources.
  36277. */
  36278. dispose(): void;
  36279. /**
  36280. * Decode Draco compressed mesh data to vertex data.
  36281. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  36282. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  36283. * @returns A promise that resolves with the decoded vertex data
  36284. */
  36285. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  36286. [kind: string]: number;
  36287. }): Promise<VertexData>;
  36288. private static _GetDecoderModule;
  36289. private static _LoadScriptAsync;
  36290. private static _LoadFileAsync;
  36291. }
  36292. }
  36293. declare module BABYLON {
  36294. /**
  36295. * Background material used to create an efficient environement around your scene.
  36296. */
  36297. class BackgroundMaterial extends PushMaterial {
  36298. /**
  36299. * Standard reflectance value at parallel view angle.
  36300. */
  36301. static StandardReflectance0: number;
  36302. /**
  36303. * Standard reflectance value at grazing angle.
  36304. */
  36305. static StandardReflectance90: number;
  36306. protected _primaryColor: Color3;
  36307. /**
  36308. * Key light Color (multiply against the environement texture)
  36309. */
  36310. primaryColor: Color3;
  36311. protected __perceptualColor: Nullable<Color3>;
  36312. /**
  36313. * Experimental Internal Use Only.
  36314. *
  36315. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  36316. * This acts as a helper to set the primary color to a more "human friendly" value.
  36317. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  36318. * output color as close as possible from the chosen value.
  36319. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  36320. * part of lighting setup.)
  36321. */
  36322. _perceptualColor: Nullable<Color3>;
  36323. protected _primaryColorShadowLevel: float;
  36324. /**
  36325. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  36326. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  36327. */
  36328. primaryColorShadowLevel: float;
  36329. protected _primaryColorHighlightLevel: float;
  36330. /**
  36331. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  36332. * The primary color is used at the level chosen to define what the white area would look.
  36333. */
  36334. primaryColorHighlightLevel: float;
  36335. protected _reflectionTexture: Nullable<BaseTexture>;
  36336. /**
  36337. * Reflection Texture used in the material.
  36338. * Should be author in a specific way for the best result (refer to the documentation).
  36339. */
  36340. reflectionTexture: Nullable<BaseTexture>;
  36341. protected _reflectionBlur: float;
  36342. /**
  36343. * Reflection Texture level of blur.
  36344. *
  36345. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  36346. * texture twice.
  36347. */
  36348. reflectionBlur: float;
  36349. protected _diffuseTexture: Nullable<BaseTexture>;
  36350. /**
  36351. * Diffuse Texture used in the material.
  36352. * Should be author in a specific way for the best result (refer to the documentation).
  36353. */
  36354. diffuseTexture: Nullable<BaseTexture>;
  36355. protected _shadowLights: Nullable<IShadowLight[]>;
  36356. /**
  36357. * Specify the list of lights casting shadow on the material.
  36358. * All scene shadow lights will be included if null.
  36359. */
  36360. shadowLights: Nullable<IShadowLight[]>;
  36361. protected _shadowLevel: float;
  36362. /**
  36363. * Helps adjusting the shadow to a softer level if required.
  36364. * 0 means black shadows and 1 means no shadows.
  36365. */
  36366. shadowLevel: float;
  36367. protected _sceneCenter: Vector3;
  36368. /**
  36369. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  36370. * It is usually zero but might be interesting to modify according to your setup.
  36371. */
  36372. sceneCenter: Vector3;
  36373. protected _opacityFresnel: boolean;
  36374. /**
  36375. * This helps specifying that the material is falling off to the sky box at grazing angle.
  36376. * This helps ensuring a nice transition when the camera goes under the ground.
  36377. */
  36378. opacityFresnel: boolean;
  36379. protected _reflectionFresnel: boolean;
  36380. /**
  36381. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  36382. * This helps adding a mirror texture on the ground.
  36383. */
  36384. reflectionFresnel: boolean;
  36385. protected _reflectionFalloffDistance: number;
  36386. /**
  36387. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  36388. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  36389. */
  36390. reflectionFalloffDistance: number;
  36391. protected _reflectionAmount: number;
  36392. /**
  36393. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  36394. */
  36395. reflectionAmount: number;
  36396. protected _reflectionReflectance0: number;
  36397. /**
  36398. * This specifies the weight of the reflection at grazing angle.
  36399. */
  36400. reflectionReflectance0: number;
  36401. protected _reflectionReflectance90: number;
  36402. /**
  36403. * This specifies the weight of the reflection at a perpendicular point of view.
  36404. */
  36405. reflectionReflectance90: number;
  36406. /**
  36407. * Sets the reflection reflectance fresnel values according to the default standard
  36408. * empirically know to work well :-)
  36409. */
  36410. reflectionStandardFresnelWeight: number;
  36411. protected _useRGBColor: boolean;
  36412. /**
  36413. * Helps to directly use the maps channels instead of their level.
  36414. */
  36415. useRGBColor: boolean;
  36416. protected _enableNoise: boolean;
  36417. /**
  36418. * This helps reducing the banding effect that could occur on the background.
  36419. */
  36420. enableNoise: boolean;
  36421. /**
  36422. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  36423. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  36424. * Recommended to be keep at 1.0 except for special cases.
  36425. */
  36426. fovMultiplier: number;
  36427. private _fovMultiplier;
  36428. /**
  36429. * Enable the FOV adjustment feature controlled by fovMultiplier.
  36430. */
  36431. useEquirectangularFOV: boolean;
  36432. private _maxSimultaneousLights;
  36433. /**
  36434. * Number of Simultaneous lights allowed on the material.
  36435. */
  36436. maxSimultaneousLights: int;
  36437. /**
  36438. * Default configuration related to image processing available in the Background Material.
  36439. */
  36440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36441. /**
  36442. * Keep track of the image processing observer to allow dispose and replace.
  36443. */
  36444. private _imageProcessingObserver;
  36445. /**
  36446. * Attaches a new image processing configuration to the PBR Material.
  36447. * @param configuration (if null the scene configuration will be use)
  36448. */
  36449. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36450. /**
  36451. * Gets the image processing configuration used either in this material.
  36452. */
  36453. /**
  36454. * Sets the Default image processing configuration used either in the this material.
  36455. *
  36456. * If sets to null, the scene one is in use.
  36457. */
  36458. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  36459. /**
  36460. * Gets wether the color curves effect is enabled.
  36461. */
  36462. /**
  36463. * Sets wether the color curves effect is enabled.
  36464. */
  36465. cameraColorCurvesEnabled: boolean;
  36466. /**
  36467. * Gets wether the color grading effect is enabled.
  36468. */
  36469. /**
  36470. * Gets wether the color grading effect is enabled.
  36471. */
  36472. cameraColorGradingEnabled: boolean;
  36473. /**
  36474. * Gets wether tonemapping is enabled or not.
  36475. */
  36476. /**
  36477. * Sets wether tonemapping is enabled or not
  36478. */
  36479. cameraToneMappingEnabled: boolean;
  36480. /**
  36481. * The camera exposure used on this material.
  36482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36483. * This corresponds to a photographic exposure.
  36484. */
  36485. /**
  36486. * The camera exposure used on this material.
  36487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36488. * This corresponds to a photographic exposure.
  36489. */
  36490. cameraExposure: float;
  36491. /**
  36492. * Gets The camera contrast used on this material.
  36493. */
  36494. /**
  36495. * Sets The camera contrast used on this material.
  36496. */
  36497. cameraContrast: float;
  36498. /**
  36499. * Gets the Color Grading 2D Lookup Texture.
  36500. */
  36501. /**
  36502. * Sets the Color Grading 2D Lookup Texture.
  36503. */
  36504. cameraColorGradingTexture: Nullable<BaseTexture>;
  36505. /**
  36506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36508. * 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;
  36509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36510. */
  36511. /**
  36512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36514. * 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;
  36515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36516. */
  36517. cameraColorCurves: Nullable<ColorCurves>;
  36518. /**
  36519. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  36520. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  36521. */
  36522. switchToBGR: boolean;
  36523. private _renderTargets;
  36524. private _reflectionControls;
  36525. private _white;
  36526. private _primaryShadowColor;
  36527. private _primaryHighlightColor;
  36528. /**
  36529. * Instantiates a Background Material in the given scene
  36530. * @param name The friendly name of the material
  36531. * @param scene The scene to add the material to
  36532. */
  36533. constructor(name: string, scene: Scene);
  36534. /**
  36535. * The entire material has been created in order to prevent overdraw.
  36536. * @returns false
  36537. */
  36538. needAlphaTesting(): boolean;
  36539. /**
  36540. * The entire material has been created in order to prevent overdraw.
  36541. * @returns true if blending is enable
  36542. */
  36543. needAlphaBlending(): boolean;
  36544. /**
  36545. * Checks wether the material is ready to be rendered for a given mesh.
  36546. * @param mesh The mesh to render
  36547. * @param subMesh The submesh to check against
  36548. * @param useInstances Specify wether or not the material is used with instances
  36549. * @returns true if all the dependencies are ready (Textures, Effects...)
  36550. */
  36551. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36552. /**
  36553. * Compute the primary color according to the chosen perceptual color.
  36554. */
  36555. private _computePrimaryColorFromPerceptualColor;
  36556. /**
  36557. * Compute the highlights and shadow colors according to their chosen levels.
  36558. */
  36559. private _computePrimaryColors;
  36560. /**
  36561. * Build the uniform buffer used in the material.
  36562. */
  36563. buildUniformLayout(): void;
  36564. /**
  36565. * Unbind the material.
  36566. */
  36567. unbind(): void;
  36568. /**
  36569. * Bind only the world matrix to the material.
  36570. * @param world The world matrix to bind.
  36571. */
  36572. bindOnlyWorldMatrix(world: Matrix): void;
  36573. /**
  36574. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  36575. * @param world The world matrix to bind.
  36576. * @param subMesh The submesh to bind for.
  36577. */
  36578. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36579. /**
  36580. * Dispose the material.
  36581. * @param forceDisposeEffect Force disposal of the associated effect.
  36582. * @param forceDisposeTextures Force disposal of the associated textures.
  36583. */
  36584. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36585. /**
  36586. * Clones the material.
  36587. * @param name The cloned name.
  36588. * @returns The cloned material.
  36589. */
  36590. clone(name: string): BackgroundMaterial;
  36591. /**
  36592. * Serializes the current material to its JSON representation.
  36593. * @returns The JSON representation.
  36594. */
  36595. serialize(): any;
  36596. /**
  36597. * Gets the class name of the material
  36598. * @returns "BackgroundMaterial"
  36599. */
  36600. getClassName(): string;
  36601. /**
  36602. * Parse a JSON input to create back a background material.
  36603. * @param source The JSON data to parse
  36604. * @param scene The scene to create the parsed material in
  36605. * @param rootUrl The root url of the assets the material depends upon
  36606. * @returns the instantiated BackgroundMaterial.
  36607. */
  36608. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  36609. }
  36610. }
  36611. declare module BABYLON {
  36612. /**
  36613. * The Physically based material base class of BJS.
  36614. *
  36615. * This offers the main features of a standard PBR material.
  36616. * For more information, please refer to the documentation :
  36617. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36618. */
  36619. abstract class PBRBaseMaterial extends PushMaterial {
  36620. /**
  36621. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  36622. */
  36623. static readonly LIGHTFALLOFF_PHYSICAL: number;
  36624. /**
  36625. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  36626. * to enhance interoperability with other engines.
  36627. */
  36628. static readonly LIGHTFALLOFF_GLTF: number;
  36629. /**
  36630. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  36631. * to enhance interoperability with other materials.
  36632. */
  36633. static readonly LIGHTFALLOFF_STANDARD: number;
  36634. /**
  36635. * Intensity of the direct lights e.g. the four lights available in your scene.
  36636. * This impacts both the direct diffuse and specular highlights.
  36637. */
  36638. protected _directIntensity: number;
  36639. /**
  36640. * Intensity of the emissive part of the material.
  36641. * This helps controlling the emissive effect without modifying the emissive color.
  36642. */
  36643. protected _emissiveIntensity: number;
  36644. /**
  36645. * Intensity of the environment e.g. how much the environment will light the object
  36646. * either through harmonics for rough material or through the refelction for shiny ones.
  36647. */
  36648. protected _environmentIntensity: number;
  36649. /**
  36650. * This is a special control allowing the reduction of the specular highlights coming from the
  36651. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36652. */
  36653. protected _specularIntensity: number;
  36654. /**
  36655. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  36656. */
  36657. private _lightingInfos;
  36658. /**
  36659. * Debug Control allowing disabling the bump map on this material.
  36660. */
  36661. protected _disableBumpMap: boolean;
  36662. /**
  36663. * AKA Diffuse Texture in standard nomenclature.
  36664. */
  36665. protected _albedoTexture: BaseTexture;
  36666. /**
  36667. * AKA Occlusion Texture in other nomenclature.
  36668. */
  36669. protected _ambientTexture: BaseTexture;
  36670. /**
  36671. * AKA Occlusion Texture Intensity in other nomenclature.
  36672. */
  36673. protected _ambientTextureStrength: number;
  36674. /**
  36675. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36676. * 1 means it completely occludes it
  36677. * 0 mean it has no impact
  36678. */
  36679. protected _ambientTextureImpactOnAnalyticalLights: number;
  36680. /**
  36681. * Stores the alpha values in a texture.
  36682. */
  36683. protected _opacityTexture: BaseTexture;
  36684. /**
  36685. * Stores the reflection values in a texture.
  36686. */
  36687. protected _reflectionTexture: BaseTexture;
  36688. /**
  36689. * Stores the refraction values in a texture.
  36690. */
  36691. protected _refractionTexture: BaseTexture;
  36692. /**
  36693. * Stores the emissive values in a texture.
  36694. */
  36695. protected _emissiveTexture: BaseTexture;
  36696. /**
  36697. * AKA Specular texture in other nomenclature.
  36698. */
  36699. protected _reflectivityTexture: BaseTexture;
  36700. /**
  36701. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36702. */
  36703. protected _metallicTexture: BaseTexture;
  36704. /**
  36705. * Specifies the metallic scalar of the metallic/roughness workflow.
  36706. * Can also be used to scale the metalness values of the metallic texture.
  36707. */
  36708. protected _metallic: Nullable<number>;
  36709. /**
  36710. * Specifies the roughness scalar of the metallic/roughness workflow.
  36711. * Can also be used to scale the roughness values of the metallic texture.
  36712. */
  36713. protected _roughness: Nullable<number>;
  36714. /**
  36715. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36716. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36717. */
  36718. protected _microSurfaceTexture: BaseTexture;
  36719. /**
  36720. * Stores surface normal data used to displace a mesh in a texture.
  36721. */
  36722. protected _bumpTexture: BaseTexture;
  36723. /**
  36724. * Stores the pre-calculated light information of a mesh in a texture.
  36725. */
  36726. protected _lightmapTexture: BaseTexture;
  36727. /**
  36728. * The color of a material in ambient lighting.
  36729. */
  36730. protected _ambientColor: Color3;
  36731. /**
  36732. * AKA Diffuse Color in other nomenclature.
  36733. */
  36734. protected _albedoColor: Color3;
  36735. /**
  36736. * AKA Specular Color in other nomenclature.
  36737. */
  36738. protected _reflectivityColor: Color3;
  36739. /**
  36740. * The color applied when light is reflected from a material.
  36741. */
  36742. protected _reflectionColor: Color3;
  36743. /**
  36744. * The color applied when light is emitted from a material.
  36745. */
  36746. protected _emissiveColor: Color3;
  36747. /**
  36748. * AKA Glossiness in other nomenclature.
  36749. */
  36750. protected _microSurface: number;
  36751. /**
  36752. * source material index of refraction (IOR)' / 'destination material IOR.
  36753. */
  36754. protected _indexOfRefraction: number;
  36755. /**
  36756. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36757. */
  36758. protected _invertRefractionY: boolean;
  36759. /**
  36760. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36761. * Materials half opaque for instance using refraction could benefit from this control.
  36762. */
  36763. protected _linkRefractionWithTransparency: boolean;
  36764. /**
  36765. * Specifies that the material will use the light map as a show map.
  36766. */
  36767. protected _useLightmapAsShadowmap: boolean;
  36768. /**
  36769. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36770. * makes the reflect vector face the model (under horizon).
  36771. */
  36772. protected _useHorizonOcclusion: boolean;
  36773. /**
  36774. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36775. * too much the area relying on ambient texture to define their ambient occlusion.
  36776. */
  36777. protected _useRadianceOcclusion: boolean;
  36778. /**
  36779. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36780. */
  36781. protected _useAlphaFromAlbedoTexture: boolean;
  36782. /**
  36783. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36784. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36785. */
  36786. protected _useSpecularOverAlpha: boolean;
  36787. /**
  36788. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36789. */
  36790. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36791. /**
  36792. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36793. */
  36794. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  36795. /**
  36796. * Specifies if the metallic texture contains the roughness information in its green channel.
  36797. */
  36798. protected _useRoughnessFromMetallicTextureGreen: boolean;
  36799. /**
  36800. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36801. */
  36802. protected _useMetallnessFromMetallicTextureBlue: boolean;
  36803. /**
  36804. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36805. */
  36806. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  36807. /**
  36808. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36809. */
  36810. protected _useAmbientInGrayScale: boolean;
  36811. /**
  36812. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36813. * The material will try to infer what glossiness each pixel should be.
  36814. */
  36815. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  36816. /**
  36817. * Defines the falloff type used in this material.
  36818. * It by default is Physical.
  36819. */
  36820. protected _lightFalloff: number;
  36821. /**
  36822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36824. */
  36825. protected _useRadianceOverAlpha: boolean;
  36826. /**
  36827. * Allows using an object space normal map (instead of tangent space).
  36828. */
  36829. protected _useObjectSpaceNormalMap: boolean;
  36830. /**
  36831. * Allows using the bump map in parallax mode.
  36832. */
  36833. protected _useParallax: boolean;
  36834. /**
  36835. * Allows using the bump map in parallax occlusion mode.
  36836. */
  36837. protected _useParallaxOcclusion: boolean;
  36838. /**
  36839. * Controls the scale bias of the parallax mode.
  36840. */
  36841. protected _parallaxScaleBias: number;
  36842. /**
  36843. * If sets to true, disables all the lights affecting the material.
  36844. */
  36845. protected _disableLighting: boolean;
  36846. /**
  36847. * Number of Simultaneous lights allowed on the material.
  36848. */
  36849. protected _maxSimultaneousLights: number;
  36850. /**
  36851. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  36852. */
  36853. protected _invertNormalMapX: boolean;
  36854. /**
  36855. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  36856. */
  36857. protected _invertNormalMapY: boolean;
  36858. /**
  36859. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36860. */
  36861. protected _twoSidedLighting: boolean;
  36862. /**
  36863. * Defines the alpha limits in alpha test mode.
  36864. */
  36865. protected _alphaCutOff: number;
  36866. /**
  36867. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36868. */
  36869. protected _forceAlphaTest: boolean;
  36870. /**
  36871. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36872. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36873. */
  36874. protected _useAlphaFresnel: boolean;
  36875. /**
  36876. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36877. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36878. */
  36879. protected _useLinearAlphaFresnel: boolean;
  36880. /**
  36881. * The transparency mode of the material.
  36882. */
  36883. protected _transparencyMode: Nullable<number>;
  36884. /**
  36885. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  36886. * from cos thetav and roughness:
  36887. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  36888. */
  36889. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  36890. /**
  36891. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36892. */
  36893. protected _forceIrradianceInFragment: boolean;
  36894. /**
  36895. * Force normal to face away from face.
  36896. */
  36897. protected _forceNormalForward: boolean;
  36898. /**
  36899. * Enables specular anti aliasing in the PBR shader.
  36900. * It will both interacts on the Geometry for analytical and IBL lighting.
  36901. * It also prefilter the roughness map based on the bump values.
  36902. */
  36903. protected _enableSpecularAntiAliasing: boolean;
  36904. /**
  36905. * Default configuration related to image processing available in the PBR Material.
  36906. */
  36907. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36908. /**
  36909. * Keep track of the image processing observer to allow dispose and replace.
  36910. */
  36911. private _imageProcessingObserver;
  36912. /**
  36913. * Attaches a new image processing configuration to the PBR Material.
  36914. * @param configuration
  36915. */
  36916. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36917. /**
  36918. * Stores the available render targets.
  36919. */
  36920. private _renderTargets;
  36921. /**
  36922. * Sets the global ambient color for the material used in lighting calculations.
  36923. */
  36924. private _globalAmbientColor;
  36925. /**
  36926. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  36927. */
  36928. private _useLogarithmicDepth;
  36929. /**
  36930. * If set to true, no lighting calculations will be applied.
  36931. */
  36932. private _unlit;
  36933. /**
  36934. * Instantiates a new PBRMaterial instance.
  36935. *
  36936. * @param name The material name
  36937. * @param scene The scene the material will be use in.
  36938. */
  36939. constructor(name: string, scene: Scene);
  36940. /**
  36941. * Gets the name of the material class.
  36942. */
  36943. getClassName(): string;
  36944. /**
  36945. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36946. */
  36947. /**
  36948. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36949. */
  36950. useLogarithmicDepth: boolean;
  36951. /**
  36952. * Gets the current transparency mode.
  36953. */
  36954. /**
  36955. * Sets the transparency mode of the material.
  36956. *
  36957. * | Value | Type | Description |
  36958. * | ----- | ----------------------------------- | ----------- |
  36959. * | 0 | OPAQUE | |
  36960. * | 1 | ALPHATEST | |
  36961. * | 2 | ALPHABLEND | |
  36962. * | 3 | ALPHATESTANDBLEND | |
  36963. *
  36964. */
  36965. transparencyMode: Nullable<number>;
  36966. /**
  36967. * Returns true if alpha blending should be disabled.
  36968. */
  36969. private readonly _disableAlphaBlending;
  36970. /**
  36971. * Specifies whether or not this material should be rendered in alpha blend mode.
  36972. */
  36973. needAlphaBlending(): boolean;
  36974. /**
  36975. * Specifies if the mesh will require alpha blending.
  36976. * @param mesh - BJS mesh.
  36977. */
  36978. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  36979. /**
  36980. * Specifies whether or not this material should be rendered in alpha test mode.
  36981. */
  36982. needAlphaTesting(): boolean;
  36983. /**
  36984. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  36985. */
  36986. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  36987. /**
  36988. * Gets the texture used for the alpha test.
  36989. */
  36990. getAlphaTestTexture(): BaseTexture;
  36991. /**
  36992. * Stores the reflectivity values based on metallic roughness workflow.
  36993. */
  36994. private static _scaledReflectivity;
  36995. /**
  36996. * Specifies that the submesh is ready to be used.
  36997. * @param mesh - BJS mesh.
  36998. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  36999. * @param useInstances - Specifies that instances should be used.
  37000. * @returns - boolean indicating that the submesh is ready or not.
  37001. */
  37002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37003. /**
  37004. * Specifies if the material uses metallic roughness workflow.
  37005. * @returns boolean specifiying if the material uses metallic roughness workflow.
  37006. */
  37007. isMetallicWorkflow(): boolean;
  37008. private _prepareEffect;
  37009. private _prepareDefines;
  37010. /**
  37011. * Force shader compilation
  37012. */
  37013. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  37014. clipPlane: boolean;
  37015. }>): void;
  37016. /**
  37017. * Initializes the uniform buffer layout for the shader.
  37018. */
  37019. buildUniformLayout(): void;
  37020. /**
  37021. * Unbinds the textures.
  37022. */
  37023. unbind(): void;
  37024. /**
  37025. * Binds the submesh data.
  37026. * @param world - The world matrix.
  37027. * @param mesh - The BJS mesh.
  37028. * @param subMesh - A submesh of the BJS mesh.
  37029. */
  37030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37031. /**
  37032. * Returns the animatable textures.
  37033. * @returns - Array of animatable textures.
  37034. */
  37035. getAnimatables(): IAnimatable[];
  37036. /**
  37037. * Returns the texture used for reflections.
  37038. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  37039. */
  37040. private _getReflectionTexture;
  37041. /**
  37042. * Returns the texture used for refraction or null if none is used.
  37043. * @returns - Refection texture if present. If no refraction texture and refraction
  37044. * is linked with transparency, returns environment texture. Otherwise, returns null.
  37045. */
  37046. private _getRefractionTexture;
  37047. /**
  37048. * Disposes the resources of the material.
  37049. * @param forceDisposeEffect - Forces the disposal of effects.
  37050. * @param forceDisposeTextures - Forces the disposal of all textures.
  37051. */
  37052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37053. }
  37054. }
  37055. declare module BABYLON {
  37056. /**
  37057. * The Physically based simple base material of BJS.
  37058. *
  37059. * This enables better naming and convention enforcements on top of the pbrMaterial.
  37060. * It is used as the base class for both the specGloss and metalRough conventions.
  37061. */
  37062. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  37063. /**
  37064. * Number of Simultaneous lights allowed on the material.
  37065. */
  37066. maxSimultaneousLights: number;
  37067. /**
  37068. * If sets to true, disables all the lights affecting the material.
  37069. */
  37070. disableLighting: boolean;
  37071. /**
  37072. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  37073. */
  37074. environmentTexture: BaseTexture;
  37075. /**
  37076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37077. */
  37078. invertNormalMapX: boolean;
  37079. /**
  37080. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37081. */
  37082. invertNormalMapY: boolean;
  37083. /**
  37084. * Normal map used in the model.
  37085. */
  37086. normalTexture: BaseTexture;
  37087. /**
  37088. * Emissivie color used to self-illuminate the model.
  37089. */
  37090. emissiveColor: Color3;
  37091. /**
  37092. * Emissivie texture used to self-illuminate the model.
  37093. */
  37094. emissiveTexture: BaseTexture;
  37095. /**
  37096. * Occlusion Channel Strenght.
  37097. */
  37098. occlusionStrength: number;
  37099. /**
  37100. * Occlusion Texture of the material (adding extra occlusion effects).
  37101. */
  37102. occlusionTexture: BaseTexture;
  37103. /**
  37104. * Defines the alpha limits in alpha test mode.
  37105. */
  37106. alphaCutOff: number;
  37107. /**
  37108. * Gets the current double sided mode.
  37109. */
  37110. /**
  37111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37112. */
  37113. doubleSided: boolean;
  37114. lightmapTexture: BaseTexture;
  37115. useLightmapAsShadowmap: boolean;
  37116. /**
  37117. * Return the active textures of the material.
  37118. */
  37119. getActiveTextures(): BaseTexture[];
  37120. hasTexture(texture: BaseTexture): boolean;
  37121. /**
  37122. * Instantiates a new PBRMaterial instance.
  37123. *
  37124. * @param name The material name
  37125. * @param scene The scene the material will be use in.
  37126. */
  37127. constructor(name: string, scene: Scene);
  37128. getClassName(): string;
  37129. }
  37130. }
  37131. declare module BABYLON {
  37132. /**
  37133. * The Physically based material of BJS.
  37134. *
  37135. * This offers the main features of a standard PBR material.
  37136. * For more information, please refer to the documentation :
  37137. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  37138. */
  37139. class PBRMaterial extends PBRBaseMaterial {
  37140. /**
  37141. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  37142. */
  37143. static readonly PBRMATERIAL_OPAQUE: number;
  37144. /**
  37145. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  37146. */
  37147. static readonly PBRMATERIAL_ALPHATEST: number;
  37148. /**
  37149. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  37150. */
  37151. static readonly PBRMATERIAL_ALPHABLEND: number;
  37152. /**
  37153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  37154. * They are also discarded below the alpha cutoff threshold to improve performances.
  37155. */
  37156. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  37157. /**
  37158. * Defines the default value of how much AO map is occluding the analytical lights
  37159. * (point spot...).
  37160. */
  37161. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  37162. /**
  37163. * Intensity of the direct lights e.g. the four lights available in your scene.
  37164. * This impacts both the direct diffuse and specular highlights.
  37165. */
  37166. directIntensity: number;
  37167. /**
  37168. * Intensity of the emissive part of the material.
  37169. * This helps controlling the emissive effect without modifying the emissive color.
  37170. */
  37171. emissiveIntensity: number;
  37172. /**
  37173. * Intensity of the environment e.g. how much the environment will light the object
  37174. * either through harmonics for rough material or through the refelction for shiny ones.
  37175. */
  37176. environmentIntensity: number;
  37177. /**
  37178. * This is a special control allowing the reduction of the specular highlights coming from the
  37179. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  37180. */
  37181. specularIntensity: number;
  37182. /**
  37183. * Debug Control allowing disabling the bump map on this material.
  37184. */
  37185. disableBumpMap: boolean;
  37186. /**
  37187. * AKA Diffuse Texture in standard nomenclature.
  37188. */
  37189. albedoTexture: BaseTexture;
  37190. /**
  37191. * AKA Occlusion Texture in other nomenclature.
  37192. */
  37193. ambientTexture: BaseTexture;
  37194. /**
  37195. * AKA Occlusion Texture Intensity in other nomenclature.
  37196. */
  37197. ambientTextureStrength: number;
  37198. /**
  37199. * Defines how much the AO map is occluding the analytical lights (point spot...).
  37200. * 1 means it completely occludes it
  37201. * 0 mean it has no impact
  37202. */
  37203. ambientTextureImpactOnAnalyticalLights: number;
  37204. /**
  37205. * Stores the alpha values in a texture.
  37206. */
  37207. opacityTexture: BaseTexture;
  37208. /**
  37209. * Stores the reflection values in a texture.
  37210. */
  37211. reflectionTexture: Nullable<BaseTexture>;
  37212. /**
  37213. * Stores the emissive values in a texture.
  37214. */
  37215. emissiveTexture: BaseTexture;
  37216. /**
  37217. * AKA Specular texture in other nomenclature.
  37218. */
  37219. reflectivityTexture: BaseTexture;
  37220. /**
  37221. * Used to switch from specular/glossiness to metallic/roughness workflow.
  37222. */
  37223. metallicTexture: BaseTexture;
  37224. /**
  37225. * Specifies the metallic scalar of the metallic/roughness workflow.
  37226. * Can also be used to scale the metalness values of the metallic texture.
  37227. */
  37228. metallic: Nullable<number>;
  37229. /**
  37230. * Specifies the roughness scalar of the metallic/roughness workflow.
  37231. * Can also be used to scale the roughness values of the metallic texture.
  37232. */
  37233. roughness: Nullable<number>;
  37234. /**
  37235. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  37236. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  37237. */
  37238. microSurfaceTexture: BaseTexture;
  37239. /**
  37240. * Stores surface normal data used to displace a mesh in a texture.
  37241. */
  37242. bumpTexture: BaseTexture;
  37243. /**
  37244. * Stores the pre-calculated light information of a mesh in a texture.
  37245. */
  37246. lightmapTexture: BaseTexture;
  37247. /**
  37248. * Stores the refracted light information in a texture.
  37249. */
  37250. refractionTexture: BaseTexture;
  37251. /**
  37252. * The color of a material in ambient lighting.
  37253. */
  37254. ambientColor: Color3;
  37255. /**
  37256. * AKA Diffuse Color in other nomenclature.
  37257. */
  37258. albedoColor: Color3;
  37259. /**
  37260. * AKA Specular Color in other nomenclature.
  37261. */
  37262. reflectivityColor: Color3;
  37263. /**
  37264. * The color reflected from the material.
  37265. */
  37266. reflectionColor: Color3;
  37267. /**
  37268. * The color emitted from the material.
  37269. */
  37270. emissiveColor: Color3;
  37271. /**
  37272. * AKA Glossiness in other nomenclature.
  37273. */
  37274. microSurface: number;
  37275. /**
  37276. * source material index of refraction (IOR)' / 'destination material IOR.
  37277. */
  37278. indexOfRefraction: number;
  37279. /**
  37280. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  37281. */
  37282. invertRefractionY: boolean;
  37283. /**
  37284. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  37285. * Materials half opaque for instance using refraction could benefit from this control.
  37286. */
  37287. linkRefractionWithTransparency: boolean;
  37288. useLightmapAsShadowmap: boolean;
  37289. /**
  37290. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  37291. */
  37292. useAlphaFromAlbedoTexture: boolean;
  37293. /**
  37294. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  37295. */
  37296. forceAlphaTest: boolean;
  37297. /**
  37298. * Defines the alpha limits in alpha test mode.
  37299. */
  37300. alphaCutOff: number;
  37301. /**
  37302. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  37303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37304. */
  37305. useSpecularOverAlpha: boolean;
  37306. /**
  37307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  37308. */
  37309. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  37310. /**
  37311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  37312. */
  37313. useRoughnessFromMetallicTextureAlpha: boolean;
  37314. /**
  37315. * Specifies if the metallic texture contains the roughness information in its green channel.
  37316. */
  37317. useRoughnessFromMetallicTextureGreen: boolean;
  37318. /**
  37319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  37320. */
  37321. useMetallnessFromMetallicTextureBlue: boolean;
  37322. /**
  37323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  37324. */
  37325. useAmbientOcclusionFromMetallicTextureRed: boolean;
  37326. /**
  37327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  37328. */
  37329. useAmbientInGrayScale: boolean;
  37330. /**
  37331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  37332. * The material will try to infer what glossiness each pixel should be.
  37333. */
  37334. useAutoMicroSurfaceFromReflectivityMap: boolean;
  37335. /**
  37336. * BJS is using an harcoded light falloff based on a manually sets up range.
  37337. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  37338. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  37339. */
  37340. /**
  37341. * BJS is using an harcoded light falloff based on a manually sets up range.
  37342. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  37343. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  37344. */
  37345. usePhysicalLightFalloff: boolean;
  37346. /**
  37347. * In order to support the falloff compatibility with gltf, a special mode has been added
  37348. * to reproduce the gltf light falloff.
  37349. */
  37350. /**
  37351. * In order to support the falloff compatibility with gltf, a special mode has been added
  37352. * to reproduce the gltf light falloff.
  37353. */
  37354. useGLTFLightFalloff: boolean;
  37355. /**
  37356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37358. */
  37359. useRadianceOverAlpha: boolean;
  37360. /**
  37361. * Allows using an object space normal map (instead of tangent space).
  37362. */
  37363. useObjectSpaceNormalMap: boolean;
  37364. /**
  37365. * Allows using the bump map in parallax mode.
  37366. */
  37367. useParallax: boolean;
  37368. /**
  37369. * Allows using the bump map in parallax occlusion mode.
  37370. */
  37371. useParallaxOcclusion: boolean;
  37372. /**
  37373. * Controls the scale bias of the parallax mode.
  37374. */
  37375. parallaxScaleBias: number;
  37376. /**
  37377. * If sets to true, disables all the lights affecting the material.
  37378. */
  37379. disableLighting: boolean;
  37380. /**
  37381. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  37382. */
  37383. forceIrradianceInFragment: boolean;
  37384. /**
  37385. * Number of Simultaneous lights allowed on the material.
  37386. */
  37387. maxSimultaneousLights: number;
  37388. /**
  37389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37390. */
  37391. invertNormalMapX: boolean;
  37392. /**
  37393. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37394. */
  37395. invertNormalMapY: boolean;
  37396. /**
  37397. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37398. */
  37399. twoSidedLighting: boolean;
  37400. /**
  37401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  37403. */
  37404. useAlphaFresnel: boolean;
  37405. /**
  37406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  37408. */
  37409. useLinearAlphaFresnel: boolean;
  37410. /**
  37411. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37412. * And/Or occlude the blended part.
  37413. */
  37414. environmentBRDFTexture: Nullable<BaseTexture>;
  37415. /**
  37416. * Force normal to face away from face.
  37417. */
  37418. forceNormalForward: boolean;
  37419. /**
  37420. * Enables specular anti aliasing in the PBR shader.
  37421. * It will both interacts on the Geometry for analytical and IBL lighting.
  37422. * It also prefilter the roughness map based on the bump values.
  37423. */
  37424. enableSpecularAntiAliasing: boolean;
  37425. /**
  37426. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  37427. * makes the reflect vector face the model (under horizon).
  37428. */
  37429. useHorizonOcclusion: boolean;
  37430. /**
  37431. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  37432. * too much the area relying on ambient texture to define their ambient occlusion.
  37433. */
  37434. useRadianceOcclusion: boolean;
  37435. /**
  37436. * If set to true, no lighting calculations will be applied.
  37437. */
  37438. unlit: boolean;
  37439. /**
  37440. * Gets the image processing configuration used either in this material.
  37441. */
  37442. /**
  37443. * Sets the Default image processing configuration used either in the this material.
  37444. *
  37445. * If sets to null, the scene one is in use.
  37446. */
  37447. imageProcessingConfiguration: ImageProcessingConfiguration;
  37448. /**
  37449. * Gets wether the color curves effect is enabled.
  37450. */
  37451. /**
  37452. * Sets wether the color curves effect is enabled.
  37453. */
  37454. cameraColorCurvesEnabled: boolean;
  37455. /**
  37456. * Gets wether the color grading effect is enabled.
  37457. */
  37458. /**
  37459. * Gets wether the color grading effect is enabled.
  37460. */
  37461. cameraColorGradingEnabled: boolean;
  37462. /**
  37463. * Gets wether tonemapping is enabled or not.
  37464. */
  37465. /**
  37466. * Sets wether tonemapping is enabled or not
  37467. */
  37468. cameraToneMappingEnabled: boolean;
  37469. /**
  37470. * The camera exposure used on this material.
  37471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37472. * This corresponds to a photographic exposure.
  37473. */
  37474. /**
  37475. * The camera exposure used on this material.
  37476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37477. * This corresponds to a photographic exposure.
  37478. */
  37479. cameraExposure: number;
  37480. /**
  37481. * Gets The camera contrast used on this material.
  37482. */
  37483. /**
  37484. * Sets The camera contrast used on this material.
  37485. */
  37486. cameraContrast: number;
  37487. /**
  37488. * Gets the Color Grading 2D Lookup Texture.
  37489. */
  37490. /**
  37491. * Sets the Color Grading 2D Lookup Texture.
  37492. */
  37493. cameraColorGradingTexture: Nullable<BaseTexture>;
  37494. /**
  37495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37497. * 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;
  37498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37499. */
  37500. /**
  37501. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37502. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37503. * 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;
  37504. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37505. */
  37506. cameraColorCurves: Nullable<ColorCurves>;
  37507. /**
  37508. * Instantiates a new PBRMaterial instance.
  37509. *
  37510. * @param name The material name
  37511. * @param scene The scene the material will be use in.
  37512. */
  37513. constructor(name: string, scene: Scene);
  37514. /**
  37515. * Returns the name of this material class.
  37516. */
  37517. getClassName(): string;
  37518. /**
  37519. * Returns an array of the actively used textures.
  37520. * @returns - Array of BaseTextures
  37521. */
  37522. getActiveTextures(): BaseTexture[];
  37523. /**
  37524. * Checks to see if a texture is used in the material.
  37525. * @param texture - Base texture to use.
  37526. * @returns - Boolean specifying if a texture is used in the material.
  37527. */
  37528. hasTexture(texture: BaseTexture): boolean;
  37529. /**
  37530. * Makes a duplicate of the current material.
  37531. * @param name - name to use for the new material.
  37532. */
  37533. clone(name: string): PBRMaterial;
  37534. /**
  37535. * Serializes this PBR Material.
  37536. * @returns - An object with the serialized material.
  37537. */
  37538. serialize(): any;
  37539. /**
  37540. * Parses a PBR Material from a serialized object.
  37541. * @param source - Serialized object.
  37542. * @param scene - BJS scene instance.
  37543. * @param rootUrl - url for the scene object
  37544. * @returns - PBRMaterial
  37545. */
  37546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  37547. }
  37548. }
  37549. declare module BABYLON {
  37550. /**
  37551. * The PBR material of BJS following the metal roughness convention.
  37552. *
  37553. * This fits to the PBR convention in the GLTF definition:
  37554. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  37555. */
  37556. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  37557. /**
  37558. * The base color has two different interpretations depending on the value of metalness.
  37559. * When the material is a metal, the base color is the specific measured reflectance value
  37560. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  37561. * of the material.
  37562. */
  37563. baseColor: Color3;
  37564. /**
  37565. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  37566. * well as opacity information in the alpha channel.
  37567. */
  37568. baseTexture: BaseTexture;
  37569. /**
  37570. * Specifies the metallic scalar value of the material.
  37571. * Can also be used to scale the metalness values of the metallic texture.
  37572. */
  37573. metallic: number;
  37574. /**
  37575. * Specifies the roughness scalar value of the material.
  37576. * Can also be used to scale the roughness values of the metallic texture.
  37577. */
  37578. roughness: number;
  37579. /**
  37580. * Texture containing both the metallic value in the B channel and the
  37581. * roughness value in the G channel to keep better precision.
  37582. */
  37583. metallicRoughnessTexture: BaseTexture;
  37584. /**
  37585. * Instantiates a new PBRMetalRoughnessMaterial instance.
  37586. *
  37587. * @param name The material name
  37588. * @param scene The scene the material will be use in.
  37589. */
  37590. constructor(name: string, scene: Scene);
  37591. /**
  37592. * Return the currrent class name of the material.
  37593. */
  37594. getClassName(): string;
  37595. /**
  37596. * Return the active textures of the material.
  37597. */
  37598. getActiveTextures(): BaseTexture[];
  37599. /**
  37600. * Checks to see if a texture is used in the material.
  37601. * @param texture - Base texture to use.
  37602. * @returns - Boolean specifying if a texture is used in the material.
  37603. */
  37604. hasTexture(texture: BaseTexture): boolean;
  37605. /**
  37606. * Makes a duplicate of the current material.
  37607. * @param name - name to use for the new material.
  37608. */
  37609. clone(name: string): PBRMetallicRoughnessMaterial;
  37610. /**
  37611. * Serialize the material to a parsable JSON object.
  37612. */
  37613. serialize(): any;
  37614. /**
  37615. * Parses a JSON object correponding to the serialize function.
  37616. */
  37617. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  37618. }
  37619. }
  37620. declare module BABYLON {
  37621. /**
  37622. * The PBR material of BJS following the specular glossiness convention.
  37623. *
  37624. * This fits to the PBR convention in the GLTF definition:
  37625. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  37626. */
  37627. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  37628. /**
  37629. * Specifies the diffuse color of the material.
  37630. */
  37631. diffuseColor: Color3;
  37632. /**
  37633. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  37634. * channel.
  37635. */
  37636. diffuseTexture: BaseTexture;
  37637. /**
  37638. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  37639. */
  37640. specularColor: Color3;
  37641. /**
  37642. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  37643. */
  37644. glossiness: number;
  37645. /**
  37646. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  37647. */
  37648. specularGlossinessTexture: BaseTexture;
  37649. /**
  37650. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  37651. *
  37652. * @param name The material name
  37653. * @param scene The scene the material will be use in.
  37654. */
  37655. constructor(name: string, scene: Scene);
  37656. /**
  37657. * Return the currrent class name of the material.
  37658. */
  37659. getClassName(): string;
  37660. /**
  37661. * Return the active textures of the material.
  37662. */
  37663. getActiveTextures(): BaseTexture[];
  37664. /**
  37665. * Checks to see if a texture is used in the material.
  37666. * @param texture - Base texture to use.
  37667. * @returns - Boolean specifying if a texture is used in the material.
  37668. */
  37669. hasTexture(texture: BaseTexture): boolean;
  37670. /**
  37671. * Makes a duplicate of the current material.
  37672. * @param name - name to use for the new material.
  37673. */
  37674. clone(name: string): PBRSpecularGlossinessMaterial;
  37675. /**
  37676. * Serialize the material to a parsable JSON object.
  37677. */
  37678. serialize(): any;
  37679. /**
  37680. * Parses a JSON object correponding to the serialize function.
  37681. */
  37682. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  37683. }
  37684. }
  37685. declare module BABYLON {
  37686. class BaseTexture {
  37687. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37688. name: string;
  37689. private _hasAlpha;
  37690. hasAlpha: boolean;
  37691. getAlphaFromRGB: boolean;
  37692. level: number;
  37693. coordinatesIndex: number;
  37694. private _coordinatesMode;
  37695. /**
  37696. * How a texture is mapped.
  37697. *
  37698. * | Value | Type | Description |
  37699. * | ----- | ----------------------------------- | ----------- |
  37700. * | 0 | EXPLICIT_MODE | |
  37701. * | 1 | SPHERICAL_MODE | |
  37702. * | 2 | PLANAR_MODE | |
  37703. * | 3 | CUBIC_MODE | |
  37704. * | 4 | PROJECTION_MODE | |
  37705. * | 5 | SKYBOX_MODE | |
  37706. * | 6 | INVCUBIC_MODE | |
  37707. * | 7 | EQUIRECTANGULAR_MODE | |
  37708. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37709. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37710. */
  37711. coordinatesMode: number;
  37712. /**
  37713. * | Value | Type | Description |
  37714. * | ----- | ------------------ | ----------- |
  37715. * | 0 | CLAMP_ADDRESSMODE | |
  37716. * | 1 | WRAP_ADDRESSMODE | |
  37717. * | 2 | MIRROR_ADDRESSMODE | |
  37718. */
  37719. wrapU: number;
  37720. /**
  37721. * | Value | Type | Description |
  37722. * | ----- | ------------------ | ----------- |
  37723. * | 0 | CLAMP_ADDRESSMODE | |
  37724. * | 1 | WRAP_ADDRESSMODE | |
  37725. * | 2 | MIRROR_ADDRESSMODE | |
  37726. */
  37727. wrapV: number;
  37728. /**
  37729. * | Value | Type | Description |
  37730. * | ----- | ------------------ | ----------- |
  37731. * | 0 | CLAMP_ADDRESSMODE | |
  37732. * | 1 | WRAP_ADDRESSMODE | |
  37733. * | 2 | MIRROR_ADDRESSMODE | |
  37734. */
  37735. wrapR: number;
  37736. anisotropicFilteringLevel: number;
  37737. isCube: boolean;
  37738. is3D: boolean;
  37739. gammaSpace: boolean;
  37740. /**
  37741. * Gets whether or not the texture contains RGBD data.
  37742. */
  37743. readonly isRGBD: boolean;
  37744. invertZ: boolean;
  37745. lodLevelInAlpha: boolean;
  37746. lodGenerationOffset: number;
  37747. lodGenerationScale: number;
  37748. isRenderTarget: boolean;
  37749. readonly uid: string;
  37750. toString(): string;
  37751. getClassName(): string;
  37752. animations: Animation[];
  37753. /**
  37754. * An event triggered when the texture is disposed.
  37755. */
  37756. onDisposeObservable: Observable<BaseTexture>;
  37757. private _onDisposeObserver;
  37758. onDispose: () => void;
  37759. delayLoadState: number;
  37760. private _scene;
  37761. /** @hidden */
  37762. _texture: Nullable<InternalTexture>;
  37763. private _uid;
  37764. readonly isBlocking: boolean;
  37765. constructor(scene: Nullable<Scene>);
  37766. getScene(): Nullable<Scene>;
  37767. getTextureMatrix(): Matrix;
  37768. getReflectionTextureMatrix(): Matrix;
  37769. getInternalTexture(): Nullable<InternalTexture>;
  37770. isReadyOrNotBlocking(): boolean;
  37771. isReady(): boolean;
  37772. private _cachedSize;
  37773. getSize(): ISize;
  37774. getBaseSize(): ISize;
  37775. scale(ratio: number): void;
  37776. readonly canRescale: boolean;
  37777. /** @hidden */
  37778. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  37779. /** @hidden */
  37780. _rebuild(): void;
  37781. delayLoad(): void;
  37782. clone(): Nullable<BaseTexture>;
  37783. readonly textureType: number;
  37784. readonly textureFormat: number;
  37785. /**
  37786. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37787. * This will returns an RGBA array buffer containing either in values (0-255) or
  37788. * float values (0-1) depending of the underlying buffer type.
  37789. * @param faceIndex The face of the texture to read (in case of cube texture)
  37790. * @param level The LOD level of the texture to read (in case of Mip Maps)
  37791. * @returns The Array buffer containing the pixels data.
  37792. */
  37793. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  37794. releaseInternalTexture(): void;
  37795. sphericalPolynomial: Nullable<SphericalPolynomial>;
  37796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  37797. readonly _lodTextureMid: Nullable<BaseTexture>;
  37798. readonly _lodTextureLow: Nullable<BaseTexture>;
  37799. dispose(): void;
  37800. serialize(): any;
  37801. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37802. }
  37803. }
  37804. declare module BABYLON {
  37805. /**
  37806. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  37807. * It can help converting any input color in a desired output one. This can then be used to create effects
  37808. * from sepia, black and white to sixties or futuristic rendering...
  37809. *
  37810. * The only supported format is currently 3dl.
  37811. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  37812. */
  37813. class ColorGradingTexture extends BaseTexture {
  37814. /**
  37815. * The current texture matrix. (will always be identity in color grading texture)
  37816. */
  37817. private _textureMatrix;
  37818. /**
  37819. * The texture URL.
  37820. */
  37821. url: string;
  37822. /**
  37823. * Empty line regex stored for GC.
  37824. */
  37825. private static _noneEmptyLineRegex;
  37826. private _engine;
  37827. /**
  37828. * Instantiates a ColorGradingTexture from the following parameters.
  37829. *
  37830. * @param url The location of the color gradind data (currently only supporting 3dl)
  37831. * @param scene The scene the texture will be used in
  37832. */
  37833. constructor(url: string, scene: Scene);
  37834. /**
  37835. * Returns the texture matrix used in most of the material.
  37836. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  37837. */
  37838. getTextureMatrix(): Matrix;
  37839. /**
  37840. * Occurs when the file being loaded is a .3dl LUT file.
  37841. */
  37842. private load3dlTexture;
  37843. /**
  37844. * Starts the loading process of the texture.
  37845. */
  37846. private loadTexture;
  37847. /**
  37848. * Clones the color gradind texture.
  37849. */
  37850. clone(): ColorGradingTexture;
  37851. /**
  37852. * Called during delayed load for textures.
  37853. */
  37854. delayLoad(): void;
  37855. /**
  37856. * Parses a color grading texture serialized by Babylon.
  37857. * @param parsedTexture The texture information being parsedTexture
  37858. * @param scene The scene to load the texture in
  37859. * @param rootUrl The root url of the data assets to load
  37860. * @return A color gradind texture
  37861. */
  37862. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  37863. /**
  37864. * Serializes the LUT texture to json format.
  37865. */
  37866. serialize(): any;
  37867. }
  37868. }
  37869. declare module BABYLON {
  37870. class CubeTexture extends BaseTexture {
  37871. url: string;
  37872. /**
  37873. * Gets or sets the center of the bounding box associated with the cube texture
  37874. * It must define where the camera used to render the texture was set
  37875. */
  37876. boundingBoxPosition: Vector3;
  37877. private _boundingBoxSize;
  37878. /**
  37879. * Gets or sets the size of the bounding box associated with the cube texture
  37880. * When defined, the cubemap will switch to local mode
  37881. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37882. * @example https://www.babylonjs-playground.com/#RNASML
  37883. */
  37884. boundingBoxSize: Vector3;
  37885. protected _rotationY: number;
  37886. /**
  37887. * Sets texture matrix rotation angle around Y axis in radians.
  37888. */
  37889. /**
  37890. * Gets texture matrix rotation angle around Y axis radians.
  37891. */
  37892. rotationY: number;
  37893. private _noMipmap;
  37894. private _files;
  37895. private _extensions;
  37896. private _textureMatrix;
  37897. private _format;
  37898. private _createPolynomials;
  37899. /** @hidden */
  37900. readonly _prefiltered: boolean;
  37901. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  37902. /**
  37903. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  37904. * @param url defines the url of the prefiltered texture
  37905. * @param scene defines the scene the texture is attached to
  37906. * @param forcedExtension defines the extension of the file if different from the url
  37907. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37908. * @return the prefiltered texture
  37909. */
  37910. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  37911. /**
  37912. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  37913. * as prefiltered data.
  37914. * @param rootUrl defines the url of the texture or the root name of the six images
  37915. * @param scene defines the scene the texture is attached to
  37916. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  37917. * @param noMipmap defines if mipmaps should be created or not
  37918. * @param files defines the six files to load for the different faces
  37919. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  37920. * @param onError defines a callback triggered in case of error during load
  37921. * @param format defines the internal format to use for the texture once loaded
  37922. * @param prefiltered defines whether or not the texture is created from prefiltered data
  37923. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  37924. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37927. * @return the cube texture
  37928. */
  37929. 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);
  37930. delayLoad(): void;
  37931. getReflectionTextureMatrix(): Matrix;
  37932. setReflectionTextureMatrix(value: Matrix): void;
  37933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  37934. clone(): CubeTexture;
  37935. }
  37936. }
  37937. declare module BABYLON {
  37938. /**
  37939. * A class extending {BABYLON.Texture} allowing drawing on a texture
  37940. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37941. */
  37942. class DynamicTexture extends Texture {
  37943. private _generateMipMaps;
  37944. private _canvas;
  37945. private _context;
  37946. private _engine;
  37947. /**
  37948. * Creates a {BABYLON.DynamicTexture}
  37949. * @param name defines the name of the texture
  37950. * @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
  37951. * @param scene defines the scene where you want the texture
  37952. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37953. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37954. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  37955. */
  37956. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37957. /**
  37958. * Gets the current state of canRescale
  37959. */
  37960. readonly canRescale: boolean;
  37961. private _recreate;
  37962. /**
  37963. * Scales the texture
  37964. * @param ratio the scale factor to apply to both width and height
  37965. */
  37966. scale(ratio: number): void;
  37967. /**
  37968. * Resizes the texture
  37969. * @param width the new width
  37970. * @param height the new height
  37971. */
  37972. scaleTo(width: number, height: number): void;
  37973. /**
  37974. * Gets the context of the canvas used by the texture
  37975. * @returns the canvas context of the dynamic texture
  37976. */
  37977. getContext(): CanvasRenderingContext2D;
  37978. /**
  37979. * Clears the texture
  37980. */
  37981. clear(): void;
  37982. /**
  37983. * Updates the texture
  37984. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37985. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37986. */
  37987. update(invertY?: boolean, premulAlpha?: boolean): void;
  37988. /**
  37989. * Draws text onto the texture
  37990. * @param text defines the text to be drawn
  37991. * @param x defines the placement of the text from the left
  37992. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37993. * @param font defines the font to be used with font-style, font-size, font-name
  37994. * @param color defines the color used for the text
  37995. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37996. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37997. * @param update defines whether texture is immediately update (default is true)
  37998. */
  37999. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38000. /**
  38001. * Clones the texture
  38002. * @returns the clone of the texture.
  38003. */
  38004. clone(): DynamicTexture;
  38005. /**
  38006. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38007. * @returns a serialized dynamic texture object
  38008. */
  38009. serialize(): any;
  38010. /** @hidden */
  38011. _rebuild(): void;
  38012. }
  38013. }
  38014. declare module BABYLON {
  38015. /**
  38016. * This represents a texture coming from an HDR input.
  38017. *
  38018. * The only supported format is currently panorama picture stored in RGBE format.
  38019. * Example of such files can be found on HDRLib: http://hdrlib.com/
  38020. */
  38021. class HDRCubeTexture extends BaseTexture {
  38022. private static _facesMapping;
  38023. private _generateHarmonics;
  38024. private _noMipmap;
  38025. private _textureMatrix;
  38026. private _size;
  38027. private _onLoad;
  38028. private _onError;
  38029. /**
  38030. * The texture URL.
  38031. */
  38032. url: string;
  38033. /**
  38034. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  38035. */
  38036. coordinatesMode: number;
  38037. protected _isBlocking: boolean;
  38038. /**
  38039. * Sets wether or not the texture is blocking during loading.
  38040. */
  38041. /**
  38042. * Gets wether or not the texture is blocking during loading.
  38043. */
  38044. isBlocking: boolean;
  38045. protected _rotationY: number;
  38046. /**
  38047. * Sets texture matrix rotation angle around Y axis in radians.
  38048. */
  38049. /**
  38050. * Gets texture matrix rotation angle around Y axis radians.
  38051. */
  38052. rotationY: number;
  38053. /**
  38054. * Gets or sets the center of the bounding box associated with the cube texture
  38055. * It must define where the camera used to render the texture was set
  38056. */
  38057. boundingBoxPosition: Vector3;
  38058. private _boundingBoxSize;
  38059. /**
  38060. * Gets or sets the size of the bounding box associated with the cube texture
  38061. * When defined, the cubemap will switch to local mode
  38062. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38063. * @example https://www.babylonjs-playground.com/#RNASML
  38064. */
  38065. boundingBoxSize: Vector3;
  38066. /**
  38067. * Instantiates an HDRTexture from the following parameters.
  38068. *
  38069. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  38070. * @param scene The scene the texture will be used in
  38071. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  38072. * @param noMipmap Forces to not generate the mipmap if true
  38073. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  38074. * @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)
  38075. * @param reserved Reserved flag for internal use.
  38076. */
  38077. 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>);
  38078. /**
  38079. * Occurs when the file is raw .hdr file.
  38080. */
  38081. private loadTexture;
  38082. clone(): HDRCubeTexture;
  38083. delayLoad(): void;
  38084. getReflectionTextureMatrix(): Matrix;
  38085. setReflectionTextureMatrix(value: Matrix): void;
  38086. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  38087. serialize(): any;
  38088. }
  38089. }
  38090. declare module BABYLON {
  38091. /**
  38092. * Class used to store data associated with WebGL texture data for the engine
  38093. * This class should not be used directly
  38094. */
  38095. class InternalTexture implements IInternalTextureTracker {
  38096. /**
  38097. * The source of the texture data is unknown
  38098. */
  38099. static DATASOURCE_UNKNOWN: number;
  38100. /**
  38101. * Texture data comes from an URL
  38102. */
  38103. static DATASOURCE_URL: number;
  38104. /**
  38105. * Texture data is only used for temporary storage
  38106. */
  38107. static DATASOURCE_TEMP: number;
  38108. /**
  38109. * Texture data comes from raw data (ArrayBuffer)
  38110. */
  38111. static DATASOURCE_RAW: number;
  38112. /**
  38113. * Texture content is dynamic (video or dynamic texture)
  38114. */
  38115. static DATASOURCE_DYNAMIC: number;
  38116. /**
  38117. * Texture content is generated by rendering to it
  38118. */
  38119. static DATASOURCE_RENDERTARGET: number;
  38120. /**
  38121. * Texture content is part of a multi render target process
  38122. */
  38123. static DATASOURCE_MULTIRENDERTARGET: number;
  38124. /**
  38125. * Texture data comes from a cube data file
  38126. */
  38127. static DATASOURCE_CUBE: number;
  38128. /**
  38129. * Texture data comes from a raw cube data
  38130. */
  38131. static DATASOURCE_CUBERAW: number;
  38132. /**
  38133. * Texture data come from a prefiltered cube data file
  38134. */
  38135. static DATASOURCE_CUBEPREFILTERED: number;
  38136. /**
  38137. * Texture content is raw 3D data
  38138. */
  38139. static DATASOURCE_RAW3D: number;
  38140. /**
  38141. * Texture content is a depth texture
  38142. */
  38143. static DATASOURCE_DEPTHTEXTURE: number;
  38144. /**
  38145. * Texture data comes from a raw cube data encoded with RGBD
  38146. */
  38147. static DATASOURCE_CUBERAW_RGBD: number;
  38148. /**
  38149. * Defines if the texture is ready
  38150. */
  38151. isReady: boolean;
  38152. /**
  38153. * Defines if the texture is a cube texture
  38154. */
  38155. isCube: boolean;
  38156. /**
  38157. * Defines if the texture contains 3D data
  38158. */
  38159. is3D: boolean;
  38160. /**
  38161. * Gets the URL used to load this texture
  38162. */
  38163. url: string;
  38164. /**
  38165. * Gets the sampling mode of the texture
  38166. */
  38167. samplingMode: number;
  38168. /**
  38169. * Gets a boolean indicating if the texture needs mipmaps generation
  38170. */
  38171. generateMipMaps: boolean;
  38172. /**
  38173. * Gets the number of samples used by the texture (WebGL2+ only)
  38174. */
  38175. samples: number;
  38176. /**
  38177. * Gets the type of the texture
  38178. */
  38179. type: number;
  38180. /**
  38181. * Gets the format of the texture
  38182. */
  38183. format: number;
  38184. /**
  38185. * Observable called when the texture is loaded
  38186. */
  38187. onLoadedObservable: Observable<InternalTexture>;
  38188. /**
  38189. * Gets the width of the texture
  38190. */
  38191. width: number;
  38192. /**
  38193. * Gets the height of the texture
  38194. */
  38195. height: number;
  38196. /**
  38197. * Gets the depth of the texture
  38198. */
  38199. depth: number;
  38200. /**
  38201. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38202. */
  38203. baseWidth: number;
  38204. /**
  38205. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38206. */
  38207. baseHeight: number;
  38208. /**
  38209. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38210. */
  38211. baseDepth: number;
  38212. /**
  38213. * Gets a boolean indicating if the texture is inverted on Y axis
  38214. */
  38215. invertY: boolean;
  38216. /**
  38217. * Gets or set the previous tracker in the list
  38218. */
  38219. previous: Nullable<IInternalTextureTracker>;
  38220. /**
  38221. * Gets or set the next tracker in the list
  38222. */
  38223. next: Nullable<IInternalTextureTracker>;
  38224. /** @hidden */
  38225. _initialSlot: number;
  38226. /** @hidden */
  38227. _designatedSlot: number;
  38228. /** @hidden */
  38229. _dataSource: number;
  38230. /** @hidden */
  38231. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  38232. /** @hidden */
  38233. _bufferView: Nullable<ArrayBufferView>;
  38234. /** @hidden */
  38235. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38236. /** @hidden */
  38237. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38238. /** @hidden */
  38239. _size: number;
  38240. /** @hidden */
  38241. _extension: string;
  38242. /** @hidden */
  38243. _files: Nullable<string[]>;
  38244. /** @hidden */
  38245. _workingCanvas: HTMLCanvasElement;
  38246. /** @hidden */
  38247. _workingContext: CanvasRenderingContext2D;
  38248. /** @hidden */
  38249. _framebuffer: Nullable<WebGLFramebuffer>;
  38250. /** @hidden */
  38251. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38252. /** @hidden */
  38253. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38254. /** @hidden */
  38255. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38256. /** @hidden */
  38257. _attachments: Nullable<number[]>;
  38258. /** @hidden */
  38259. _cachedCoordinatesMode: Nullable<number>;
  38260. /** @hidden */
  38261. _cachedWrapU: Nullable<number>;
  38262. /** @hidden */
  38263. _cachedWrapV: Nullable<number>;
  38264. /** @hidden */
  38265. _cachedWrapR: Nullable<number>;
  38266. /** @hidden */
  38267. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38268. /** @hidden */
  38269. _isDisabled: boolean;
  38270. /** @hidden */
  38271. _compression: Nullable<string>;
  38272. /** @hidden */
  38273. _generateStencilBuffer: boolean;
  38274. /** @hidden */
  38275. _generateDepthBuffer: boolean;
  38276. /** @hidden */
  38277. _comparisonFunction: number;
  38278. /** @hidden */
  38279. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38280. /** @hidden */
  38281. _lodGenerationScale: number;
  38282. /** @hidden */
  38283. _lodGenerationOffset: number;
  38284. /** @hidden */
  38285. _lodTextureHigh: BaseTexture;
  38286. /** @hidden */
  38287. _lodTextureMid: BaseTexture;
  38288. /** @hidden */
  38289. _lodTextureLow: BaseTexture;
  38290. /** @hidden */
  38291. _isRGBD: boolean;
  38292. /** @hidden */
  38293. _webGLTexture: Nullable<WebGLTexture>;
  38294. /** @hidden */
  38295. _references: number;
  38296. private _engine;
  38297. /**
  38298. * Gets the Engine the texture belongs to.
  38299. * @returns The babylon engine
  38300. */
  38301. getEngine(): Engine;
  38302. /**
  38303. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  38304. */
  38305. readonly dataSource: number;
  38306. /**
  38307. * Creates a new InternalTexture
  38308. * @param engine defines the engine to use
  38309. * @param dataSource defines the type of data that will be used
  38310. */
  38311. constructor(engine: Engine, dataSource: number);
  38312. /**
  38313. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  38314. */
  38315. incrementReferences(): void;
  38316. /**
  38317. * Change the size of the texture (not the size of the content)
  38318. * @param width defines the new width
  38319. * @param height defines the new height
  38320. * @param depth defines the new depth (1 by default)
  38321. */
  38322. updateSize(width: int, height: int, depth?: int): void;
  38323. /** @hidden */
  38324. _rebuild(): void;
  38325. /** @hidden */
  38326. _swapAndDie(target: InternalTexture): void;
  38327. /**
  38328. * Dispose the current allocated resources
  38329. */
  38330. dispose(): void;
  38331. }
  38332. }
  38333. declare module BABYLON {
  38334. /**
  38335. * This represents the required contract to create a new type of texture loader.
  38336. */
  38337. interface IInternalTextureLoader {
  38338. /**
  38339. * Defines wether the loader supports cascade loading the different faces.
  38340. */
  38341. supportCascades: boolean;
  38342. /**
  38343. * This returns if the loader support the current file information.
  38344. * @param extension defines the file extension of the file being loaded
  38345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  38346. * @param fallback defines the fallback internal texture if any
  38347. * @param isBase64 defines whether the texture is encoded as a base64
  38348. * @param isBuffer defines whether the texture data are stored as a buffer
  38349. * @returns true if the loader can load the specified file
  38350. */
  38351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  38352. /**
  38353. * Transform the url before loading if required.
  38354. * @param rootUrl the url of the texture
  38355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  38356. * @returns the transformed texture
  38357. */
  38358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  38359. /**
  38360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  38361. * @param rootUrl the url of the texture
  38362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  38363. * @returns the fallback texture
  38364. */
  38365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  38366. /**
  38367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  38368. * @param data contains the texture data
  38369. * @param texture defines the BabylonJS internal texture
  38370. * @param createPolynomials will be true if polynomials have been requested
  38371. * @param onLoad defines the callback to trigger once the texture is ready
  38372. * @param onError defines the callback to trigger in case of error
  38373. */
  38374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  38375. /**
  38376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  38377. * @param data contains the texture data
  38378. * @param texture defines the BabylonJS internal texture
  38379. * @param callback defines the method to call once ready to upload
  38380. */
  38381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  38382. }
  38383. }
  38384. declare module BABYLON {
  38385. /**
  38386. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  38387. */
  38388. interface IInternalTextureTracker {
  38389. /**
  38390. * Gets or set the previous tracker in the list
  38391. */
  38392. previous: Nullable<IInternalTextureTracker>;
  38393. /**
  38394. * Gets or set the next tracker in the list
  38395. */
  38396. next: Nullable<IInternalTextureTracker>;
  38397. }
  38398. /**
  38399. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  38400. */
  38401. class DummyInternalTextureTracker {
  38402. /**
  38403. * Gets or set the previous tracker in the list
  38404. */
  38405. previous: Nullable<IInternalTextureTracker>;
  38406. /**
  38407. * Gets or set the next tracker in the list
  38408. */
  38409. next: Nullable<IInternalTextureTracker>;
  38410. }
  38411. }
  38412. declare module BABYLON {
  38413. class MirrorTexture extends RenderTargetTexture {
  38414. private scene;
  38415. mirrorPlane: Plane;
  38416. private _transformMatrix;
  38417. private _mirrorMatrix;
  38418. private _savedViewMatrix;
  38419. private _blurX;
  38420. private _blurY;
  38421. private _adaptiveBlurKernel;
  38422. private _blurKernelX;
  38423. private _blurKernelY;
  38424. private _blurRatio;
  38425. blurRatio: number;
  38426. adaptiveBlurKernel: number;
  38427. blurKernel: number;
  38428. blurKernelX: number;
  38429. blurKernelY: number;
  38430. private _autoComputeBlurKernel;
  38431. protected _onRatioRescale(): void;
  38432. private _updateGammaSpace;
  38433. private _imageProcessingConfigChangeObserver;
  38434. constructor(name: string, size: number | {
  38435. width: number;
  38436. height: number;
  38437. } | {
  38438. ratio: number;
  38439. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  38440. private _preparePostProcesses;
  38441. clone(): MirrorTexture;
  38442. serialize(): any;
  38443. dispose(): void;
  38444. }
  38445. }
  38446. declare module BABYLON {
  38447. interface IMultiRenderTargetOptions {
  38448. generateMipMaps?: boolean;
  38449. types?: number[];
  38450. samplingModes?: number[];
  38451. generateDepthBuffer?: boolean;
  38452. generateStencilBuffer?: boolean;
  38453. generateDepthTexture?: boolean;
  38454. textureCount?: number;
  38455. doNotChangeAspectRatio?: boolean;
  38456. defaultType?: number;
  38457. }
  38458. class MultiRenderTarget extends RenderTargetTexture {
  38459. private _internalTextures;
  38460. private _textures;
  38461. readonly isSupported: boolean;
  38462. private _multiRenderTargetOptions;
  38463. readonly textures: Texture[];
  38464. readonly depthTexture: Texture;
  38465. wrapU: number;
  38466. wrapV: number;
  38467. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  38468. /** @hidden */
  38469. _rebuild(): void;
  38470. private _createInternalTextures;
  38471. private _createTextures;
  38472. samples: number;
  38473. resize(size: any): void;
  38474. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38475. dispose(): void;
  38476. releaseInternalTextures(): void;
  38477. }
  38478. }
  38479. declare module BABYLON {
  38480. /**
  38481. * Raw cube texture where the raw buffers are passed in
  38482. */
  38483. class RawCubeTexture extends CubeTexture {
  38484. /**
  38485. * Creates a cube texture where the raw buffers are passed in.
  38486. * @param scene defines the scene the texture is attached to
  38487. * @param data defines the array of data to use to create each face
  38488. * @param size defines the size of the textures
  38489. * @param format defines the format of the data
  38490. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  38491. * @param generateMipMaps defines if the engine should generate the mip levels
  38492. * @param invertY defines if data must be stored with Y axis inverted
  38493. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  38494. * @param compression defines the compression used (null by default)
  38495. */
  38496. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  38497. /**
  38498. * Updates the raw cube texture.
  38499. * @param data defines the data to store
  38500. * @param format defines the data format
  38501. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  38502. * @param invertY defines if data must be stored with Y axis inverted
  38503. * @param compression defines the compression used (null by default)
  38504. * @param level defines which level of the texture to update
  38505. */
  38506. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  38507. /**
  38508. * Updates a raw cube texture with RGBD encoded data.
  38509. * @param data defines the array of data [mipmap][face] to use to create each face
  38510. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  38511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  38512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  38513. * @returns a promsie that resolves when the operation is complete
  38514. */
  38515. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  38516. /**
  38517. * Clones the raw cube texture.
  38518. * @return a new cube texture
  38519. */
  38520. clone(): CubeTexture;
  38521. /** @hidden */
  38522. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  38523. }
  38524. }
  38525. declare module BABYLON {
  38526. class RawTexture extends Texture {
  38527. format: number;
  38528. private _engine;
  38529. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  38530. update(data: ArrayBufferView): void;
  38531. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38532. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38533. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38534. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38535. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38536. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38537. }
  38538. }
  38539. declare module BABYLON {
  38540. /**
  38541. * Class used to store 3D textures containing user data
  38542. */
  38543. class RawTexture3D extends Texture {
  38544. /** Gets or sets the texture format to use */
  38545. format: number;
  38546. private _engine;
  38547. /**
  38548. * Create a new RawTexture3D
  38549. * @param data defines the data of the texture
  38550. * @param width defines the width of the texture
  38551. * @param height defines the height of the texture
  38552. * @param depth defines the depth of the texture
  38553. * @param format defines the texture format to use
  38554. * @param scene defines the hosting scene
  38555. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  38556. * @param invertY defines if texture must be stored with Y axis inverted
  38557. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  38558. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  38559. */
  38560. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  38561. /** Gets or sets the texture format to use */
  38562. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  38563. /**
  38564. * Update the texture with new data
  38565. * @param data defines the data to store in the texture
  38566. */
  38567. update(data: ArrayBufferView): void;
  38568. }
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * Creates a refraction texture used by refraction channel of the standard material.
  38573. * @param name the texture name
  38574. * @param size size of the underlying texture
  38575. * @param scene root scene
  38576. */
  38577. class RefractionTexture extends RenderTargetTexture {
  38578. refractionPlane: Plane;
  38579. depth: number;
  38580. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  38581. clone(): RefractionTexture;
  38582. serialize(): any;
  38583. }
  38584. }
  38585. declare module BABYLON {
  38586. class RenderTargetTexture extends Texture {
  38587. isCube: boolean;
  38588. static _REFRESHRATE_RENDER_ONCE: number;
  38589. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38590. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38591. static readonly REFRESHRATE_RENDER_ONCE: number;
  38592. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38593. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38594. /**
  38595. * Use this predicate to dynamically define the list of mesh you want to render.
  38596. * If set, the renderList property will be overwritten.
  38597. */
  38598. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38599. private _renderList;
  38600. /**
  38601. * Use this list to define the list of mesh you want to render.
  38602. */
  38603. renderList: Nullable<Array<AbstractMesh>>;
  38604. private _hookArray;
  38605. renderParticles: boolean;
  38606. renderSprites: boolean;
  38607. coordinatesMode: number;
  38608. activeCamera: Nullable<Camera>;
  38609. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38610. useCameraPostProcesses: boolean;
  38611. ignoreCameraViewport: boolean;
  38612. private _postProcessManager;
  38613. private _postProcesses;
  38614. private _resizeObserver;
  38615. /**
  38616. * An event triggered when the texture is unbind.
  38617. */
  38618. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38619. /**
  38620. * An event triggered when the texture is unbind.
  38621. */
  38622. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38623. private _onAfterUnbindObserver;
  38624. onAfterUnbind: () => void;
  38625. /**
  38626. * An event triggered before rendering the texture
  38627. */
  38628. onBeforeRenderObservable: Observable<number>;
  38629. private _onBeforeRenderObserver;
  38630. onBeforeRender: (faceIndex: number) => void;
  38631. /**
  38632. * An event triggered after rendering the texture
  38633. */
  38634. onAfterRenderObservable: Observable<number>;
  38635. private _onAfterRenderObserver;
  38636. onAfterRender: (faceIndex: number) => void;
  38637. /**
  38638. * An event triggered after the texture clear
  38639. */
  38640. onClearObservable: Observable<Engine>;
  38641. private _onClearObserver;
  38642. onClear: (Engine: Engine) => void;
  38643. clearColor: Color4;
  38644. protected _size: number | {
  38645. width: number;
  38646. height: number;
  38647. };
  38648. protected _initialSizeParameter: number | {
  38649. width: number;
  38650. height: number;
  38651. } | {
  38652. ratio: number;
  38653. };
  38654. protected _sizeRatio: Nullable<number>;
  38655. /** @hidden */
  38656. _generateMipMaps: boolean;
  38657. protected _renderingManager: RenderingManager;
  38658. /** @hidden */
  38659. _waitingRenderList: string[];
  38660. protected _doNotChangeAspectRatio: boolean;
  38661. protected _currentRefreshId: number;
  38662. protected _refreshRate: number;
  38663. protected _textureMatrix: Matrix;
  38664. protected _samples: number;
  38665. protected _renderTargetOptions: RenderTargetCreationOptions;
  38666. readonly renderTargetOptions: RenderTargetCreationOptions;
  38667. protected _engine: Engine;
  38668. protected _onRatioRescale(): void;
  38669. /**
  38670. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38671. * It must define where the camera used to render the texture is set
  38672. */
  38673. boundingBoxPosition: Vector3;
  38674. private _boundingBoxSize;
  38675. /**
  38676. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38677. * When defined, the cubemap will switch to local mode
  38678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38679. * @example https://www.babylonjs-playground.com/#RNASML
  38680. */
  38681. boundingBoxSize: Vector3;
  38682. /**
  38683. * In case the RTT has been created with a depth texture, get the associated
  38684. * depth texture.
  38685. * Otherwise, return null.
  38686. */
  38687. depthStencilTexture: Nullable<InternalTexture>;
  38688. /**
  38689. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  38690. * or used a shadow, depth texture...
  38691. * @param name The friendly name of the texture
  38692. * @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)
  38693. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38694. * @param generateMipMaps True if mip maps need to be generated after render.
  38695. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38696. * @param type The type of the buffer in the RTT (int, half float, float...)
  38697. * @param isCube True if a cube texture needs to be created
  38698. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38699. * @param generateDepthBuffer True to generate a depth buffer
  38700. * @param generateStencilBuffer True to generate a stencil buffer
  38701. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38702. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38703. */
  38704. constructor(name: string, size: number | {
  38705. width: number;
  38706. height: number;
  38707. } | {
  38708. ratio: number;
  38709. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  38710. /**
  38711. * Creates a depth stencil texture.
  38712. * This is only available in WebGL 2 or with the depth texture extension available.
  38713. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38714. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38715. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38716. */
  38717. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  38718. private _processSizeParameter;
  38719. samples: number;
  38720. resetRefreshCounter(): void;
  38721. refreshRate: number;
  38722. addPostProcess(postProcess: PostProcess): void;
  38723. clearPostProcesses(dispose?: boolean): void;
  38724. removePostProcess(postProcess: PostProcess): void;
  38725. /** @hidden */
  38726. _shouldRender(): boolean;
  38727. getRenderSize(): number;
  38728. getRenderWidth(): number;
  38729. getRenderHeight(): number;
  38730. readonly canRescale: boolean;
  38731. scale(ratio: number): void;
  38732. getReflectionTextureMatrix(): Matrix;
  38733. resize(size: number | {
  38734. width: number;
  38735. height: number;
  38736. } | {
  38737. ratio: number;
  38738. }): void;
  38739. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38740. private _bestReflectionRenderTargetDimension;
  38741. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38742. private renderToTarget;
  38743. /**
  38744. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38745. * This allowed control for front to back rendering or reversly depending of the special needs.
  38746. *
  38747. * @param renderingGroupId The rendering group id corresponding to its index
  38748. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38749. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38750. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38751. */
  38752. 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;
  38753. /**
  38754. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38755. *
  38756. * @param renderingGroupId The rendering group id corresponding to its index
  38757. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38758. */
  38759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38760. clone(): RenderTargetTexture;
  38761. serialize(): any;
  38762. disposeFramebufferObjects(): void;
  38763. dispose(): void;
  38764. /** @hidden */
  38765. _rebuild(): void;
  38766. /**
  38767. * Clear the info related to rendering groups preventing retention point in material dispose.
  38768. */
  38769. freeRenderingGroups(): void;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. class Texture extends BaseTexture {
  38774. static NEAREST_SAMPLINGMODE: number;
  38775. static NEAREST_NEAREST_MIPLINEAR: number;
  38776. static BILINEAR_SAMPLINGMODE: number;
  38777. static LINEAR_LINEAR_MIPNEAREST: number;
  38778. static TRILINEAR_SAMPLINGMODE: number;
  38779. static LINEAR_LINEAR_MIPLINEAR: number;
  38780. static NEAREST_NEAREST_MIPNEAREST: number;
  38781. static NEAREST_LINEAR_MIPNEAREST: number;
  38782. static NEAREST_LINEAR_MIPLINEAR: number;
  38783. static NEAREST_LINEAR: number;
  38784. static NEAREST_NEAREST: number;
  38785. static LINEAR_NEAREST_MIPNEAREST: number;
  38786. static LINEAR_NEAREST_MIPLINEAR: number;
  38787. static LINEAR_LINEAR: number;
  38788. static LINEAR_NEAREST: number;
  38789. static EXPLICIT_MODE: number;
  38790. static SPHERICAL_MODE: number;
  38791. static PLANAR_MODE: number;
  38792. static CUBIC_MODE: number;
  38793. static PROJECTION_MODE: number;
  38794. static SKYBOX_MODE: number;
  38795. static INVCUBIC_MODE: number;
  38796. static EQUIRECTANGULAR_MODE: number;
  38797. static FIXED_EQUIRECTANGULAR_MODE: number;
  38798. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38799. static readonly CLAMP_ADDRESSMODE: number;
  38800. static readonly WRAP_ADDRESSMODE: number;
  38801. static readonly MIRROR_ADDRESSMODE: number;
  38802. /**
  38803. * 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
  38804. */
  38805. static UseSerializedUrlIfAny: boolean;
  38806. url: Nullable<string>;
  38807. uOffset: number;
  38808. vOffset: number;
  38809. uScale: number;
  38810. vScale: number;
  38811. uAng: number;
  38812. vAng: number;
  38813. wAng: number;
  38814. /**
  38815. * Defines the center of rotation (U)
  38816. */
  38817. uRotationCenter: number;
  38818. /**
  38819. * Defines the center of rotation (V)
  38820. */
  38821. vRotationCenter: number;
  38822. /**
  38823. * Defines the center of rotation (W)
  38824. */
  38825. wRotationCenter: number;
  38826. readonly noMipmap: boolean;
  38827. private _noMipmap;
  38828. /** @hidden */
  38829. _invertY: boolean;
  38830. private _rowGenerationMatrix;
  38831. private _cachedTextureMatrix;
  38832. private _projectionModeMatrix;
  38833. private _t0;
  38834. private _t1;
  38835. private _t2;
  38836. private _cachedUOffset;
  38837. private _cachedVOffset;
  38838. private _cachedUScale;
  38839. private _cachedVScale;
  38840. private _cachedUAng;
  38841. private _cachedVAng;
  38842. private _cachedWAng;
  38843. private _cachedProjectionMatrixId;
  38844. private _cachedCoordinatesMode;
  38845. /** @hidden */
  38846. _samplingMode: number;
  38847. /** @hidden */
  38848. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  38849. private _deleteBuffer;
  38850. protected _format: Nullable<number>;
  38851. private _delayedOnLoad;
  38852. private _delayedOnError;
  38853. protected _onLoadObservable: Nullable<Observable<Texture>>;
  38854. protected _isBlocking: boolean;
  38855. isBlocking: boolean;
  38856. readonly samplingMode: number;
  38857. 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);
  38858. /**
  38859. * Update the url (and optional buffer) of this texture if url was null during construction.
  38860. * @param url the url of the texture
  38861. * @param buffer the buffer of the texture (defaults to null)
  38862. */
  38863. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  38864. delayLoad(): void;
  38865. /**
  38866. * Default is Trilinear mode.
  38867. *
  38868. * | Value | Type | Description |
  38869. * | ----- | ------------------ | ----------- |
  38870. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38871. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38872. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38873. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38874. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38875. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38876. * | 7 | NEAREST_LINEAR | |
  38877. * | 8 | NEAREST_NEAREST | |
  38878. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38879. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38880. * | 11 | LINEAR_LINEAR | |
  38881. * | 12 | LINEAR_NEAREST | |
  38882. *
  38883. * > _mag_: magnification filter (close to the viewer)
  38884. * > _min_: minification filter (far from the viewer)
  38885. * > _mip_: filter used between mip map levels
  38886. *
  38887. */
  38888. updateSamplingMode(samplingMode: number): void;
  38889. private _prepareRowForTextureGeneration;
  38890. getTextureMatrix(): Matrix;
  38891. getReflectionTextureMatrix(): Matrix;
  38892. clone(): Texture;
  38893. readonly onLoadObservable: Observable<Texture>;
  38894. serialize(): any;
  38895. getClassName(): string;
  38896. dispose(): void;
  38897. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  38898. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  38899. 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;
  38900. }
  38901. }
  38902. declare module BABYLON {
  38903. /**
  38904. * Settings for finer control over video usage
  38905. */
  38906. interface VideoTextureSettings {
  38907. /**
  38908. * Applies `autoplay` to video, if specified
  38909. */
  38910. autoPlay?: boolean;
  38911. /**
  38912. * Applies `loop` to video, if specified
  38913. */
  38914. loop?: boolean;
  38915. /**
  38916. * Automatically updates internal texture from video at every frame in the render loop
  38917. */
  38918. autoUpdateTexture: boolean;
  38919. /**
  38920. * Image src displayed during the video loading or until the user interacts with the video.
  38921. */
  38922. poster?: string;
  38923. }
  38924. class VideoTexture extends Texture {
  38925. /**
  38926. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38927. */
  38928. readonly autoUpdateTexture: boolean;
  38929. /**
  38930. * The video instance used by the texture internally
  38931. */
  38932. readonly video: HTMLVideoElement;
  38933. private _onUserActionRequestedObservable;
  38934. readonly onUserActionRequestedObservable: Observable<Texture>;
  38935. private _generateMipMaps;
  38936. private _engine;
  38937. private _stillImageCaptured;
  38938. private _poster;
  38939. /**
  38940. * Creates a video texture.
  38941. * Sample : https://doc.babylonjs.com/how_to/video_texture
  38942. * @param {string | null} name optional name, will detect from video source, if not defined
  38943. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  38944. * @param {BABYLON.Scene} scene is obviously the current scene.
  38945. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38946. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  38947. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38948. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  38949. */
  38950. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38951. private _getName;
  38952. private _getVideo;
  38953. private _createInternalTexture;
  38954. private reset;
  38955. /**
  38956. * @hidden Internal method to initiate `update`.
  38957. */
  38958. _rebuild(): void;
  38959. /**
  38960. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38961. */
  38962. update(): void;
  38963. /**
  38964. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38965. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38966. */
  38967. updateTexture(isVisible: boolean): void;
  38968. protected _updateInternalTexture: (e?: Event | undefined) => void;
  38969. /**
  38970. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38971. * @param url New url.
  38972. */
  38973. updateURL(url: string): void;
  38974. dispose(): void;
  38975. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38976. minWidth: number;
  38977. maxWidth: number;
  38978. minHeight: number;
  38979. maxHeight: number;
  38980. deviceId: string;
  38981. }): void;
  38982. }
  38983. }
  38984. declare module BABYLON {
  38985. /**
  38986. * This represents a set of one or more post processes in Babylon.
  38987. * A post process can be used to apply a shader to a texture after it is rendered.
  38988. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38989. */
  38990. class PostProcessRenderEffect {
  38991. private _postProcesses;
  38992. private _getPostProcesses;
  38993. private _singleInstance;
  38994. private _cameras;
  38995. private _indicesForCamera;
  38996. /**
  38997. * Name of the effect
  38998. * @hidden
  38999. */
  39000. _name: string;
  39001. /**
  39002. * Instantiates a post process render effect.
  39003. * A post process can be used to apply a shader to a texture after it is rendered.
  39004. * @param engine The engine the effect is tied to
  39005. * @param name The name of the effect
  39006. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  39007. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  39008. */
  39009. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  39010. /**
  39011. * Checks if all the post processes in the effect are supported.
  39012. */
  39013. readonly isSupported: boolean;
  39014. /**
  39015. * Updates the current state of the effect
  39016. * @hidden
  39017. */
  39018. _update(): void;
  39019. /**
  39020. * Attaches the effect on cameras
  39021. * @param cameras The camera to attach to.
  39022. * @hidden
  39023. */
  39024. _attachCameras(cameras: Camera): void;
  39025. /**
  39026. * Attaches the effect on cameras
  39027. * @param cameras The camera to attach to.
  39028. * @hidden
  39029. */
  39030. _attachCameras(cameras: Camera[]): void;
  39031. /**
  39032. * Detatches the effect on cameras
  39033. * @param cameras The camera to detatch from.
  39034. * @hidden
  39035. */
  39036. _detachCameras(cameras: Camera): void;
  39037. /**
  39038. * Detatches the effect on cameras
  39039. * @param cameras The camera to detatch from.
  39040. * @hidden
  39041. */
  39042. _detachCameras(cameras: Camera[]): void;
  39043. /**
  39044. * Enables the effect on given cameras
  39045. * @param cameras The camera to enable.
  39046. * @hidden
  39047. */
  39048. _enable(cameras: Camera): void;
  39049. /**
  39050. * Enables the effect on given cameras
  39051. * @param cameras The camera to enable.
  39052. * @hidden
  39053. */
  39054. _enable(cameras: Nullable<Camera[]>): void;
  39055. /**
  39056. * Disables the effect on the given cameras
  39057. * @param cameras The camera to disable.
  39058. * @hidden
  39059. */
  39060. _disable(cameras: Camera): void;
  39061. /**
  39062. * Disables the effect on the given cameras
  39063. * @param cameras The camera to disable.
  39064. * @hidden
  39065. */
  39066. _disable(cameras: Nullable<Camera[]>): void;
  39067. /**
  39068. * Gets a list of the post processes contained in the effect.
  39069. * @param camera The camera to get the post processes on.
  39070. * @returns The list of the post processes in the effect.
  39071. */
  39072. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. class PostProcessRenderPipeline {
  39077. private engine;
  39078. private _renderEffects;
  39079. private _renderEffectsForIsolatedPass;
  39080. protected _cameras: Camera[];
  39081. /** @hidden */
  39082. _name: string;
  39083. constructor(engine: Engine, name: string);
  39084. getClassName(): string;
  39085. readonly isSupported: boolean;
  39086. addEffect(renderEffect: PostProcessRenderEffect): void;
  39087. /** @hidden */
  39088. _rebuild(): void;
  39089. /** @hidden */
  39090. _enableEffect(renderEffectName: string, cameras: Camera): void;
  39091. /** @hidden */
  39092. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  39093. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39094. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39095. /** @hidden */
  39096. _attachCameras(cameras: Camera, unique: boolean): void;
  39097. /** @hidden */
  39098. _attachCameras(cameras: Camera[], unique: boolean): void;
  39099. /** @hidden */
  39100. _detachCameras(cameras: Camera): void;
  39101. /** @hidden */
  39102. _detachCameras(cameras: Nullable<Camera[]>): void;
  39103. /** @hidden */
  39104. _update(): void;
  39105. /** @hidden */
  39106. _reset(): void;
  39107. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  39108. dispose(): void;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. class PostProcessRenderPipelineManager {
  39113. private _renderPipelines;
  39114. constructor();
  39115. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  39116. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  39117. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  39118. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  39119. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  39120. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39121. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39122. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39123. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39124. update(): void;
  39125. /** @hidden */
  39126. _rebuild(): void;
  39127. dispose(): void;
  39128. }
  39129. }
  39130. declare module BABYLON {
  39131. interface Scene {
  39132. /** @hidden (Backing field) */
  39133. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39134. /**
  39135. * Gets the postprocess render pipeline manager
  39136. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  39137. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39138. */
  39139. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39140. }
  39141. /**
  39142. * Defines the Render Pipeline scene component responsible to rendering pipelines
  39143. */
  39144. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  39145. /**
  39146. * The component name helpfull to identify the component in the list of scene components.
  39147. */
  39148. readonly name: string;
  39149. /**
  39150. * The scene the component belongs to.
  39151. */
  39152. scene: Scene;
  39153. /**
  39154. * Creates a new instance of the component for the given scene
  39155. * @param scene Defines the scene to register the component in
  39156. */
  39157. constructor(scene: Scene);
  39158. /**
  39159. * Registers the component in a given scene
  39160. */
  39161. register(): void;
  39162. /**
  39163. * Rebuilds the elements related to this component in case of
  39164. * context lost for instance.
  39165. */
  39166. rebuild(): void;
  39167. /**
  39168. * Disposes the component and the associated ressources
  39169. */
  39170. dispose(): void;
  39171. private _gatherRenderTargets;
  39172. private _rebuildGeometry;
  39173. }
  39174. }
  39175. declare module BABYLON {
  39176. /**
  39177. * Helper class dealing with the extraction of spherical polynomial dataArray
  39178. * from a cube map.
  39179. */
  39180. class CubeMapToSphericalPolynomialTools {
  39181. private static FileFaces;
  39182. /**
  39183. * Converts a texture to the according Spherical Polynomial data.
  39184. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39185. *
  39186. * @param texture The texture to extract the information from.
  39187. * @return The Spherical Polynomial data.
  39188. */
  39189. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  39190. /**
  39191. * Converts a cubemap to the according Spherical Polynomial data.
  39192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39193. *
  39194. * @param cubeInfo The Cube map to extract the information from.
  39195. * @return The Spherical Polynomial data.
  39196. */
  39197. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  39198. }
  39199. }
  39200. declare module BABYLON {
  39201. /**
  39202. * Header information of HDR texture files.
  39203. */
  39204. interface HDRInfo {
  39205. /**
  39206. * The height of the texture in pixels.
  39207. */
  39208. height: number;
  39209. /**
  39210. * The width of the texture in pixels.
  39211. */
  39212. width: number;
  39213. /**
  39214. * The index of the beginning of the data in the binary file.
  39215. */
  39216. dataPosition: number;
  39217. }
  39218. /**
  39219. * This groups tools to convert HDR texture to native colors array.
  39220. */
  39221. class HDRTools {
  39222. private static Ldexp;
  39223. private static Rgbe2float;
  39224. private static readStringLine;
  39225. /**
  39226. * Reads header information from an RGBE texture stored in a native array.
  39227. * More information on this format are available here:
  39228. * https://en.wikipedia.org/wiki/RGBE_image_format
  39229. *
  39230. * @param uint8array The binary file stored in native array.
  39231. * @return The header information.
  39232. */
  39233. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  39234. /**
  39235. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  39236. * This RGBE texture needs to store the information as a panorama.
  39237. *
  39238. * More information on this format are available here:
  39239. * https://en.wikipedia.org/wiki/RGBE_image_format
  39240. *
  39241. * @param buffer The binary file stored in an array buffer.
  39242. * @param size The expected size of the extracted cubemap.
  39243. * @return The Cube Map information.
  39244. */
  39245. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  39246. /**
  39247. * Returns the pixels data extracted from an RGBE texture.
  39248. * This pixels will be stored left to right up to down in the R G B order in one array.
  39249. *
  39250. * More information on this format are available here:
  39251. * https://en.wikipedia.org/wiki/RGBE_image_format
  39252. *
  39253. * @param uint8array The binary file stored in an array buffer.
  39254. * @param hdrInfo The header information of the file.
  39255. * @return The pixels data in RGB right to left up to down order.
  39256. */
  39257. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  39258. private static RGBE_ReadPixels_RLE;
  39259. }
  39260. }
  39261. declare module BABYLON {
  39262. /**
  39263. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  39264. */
  39265. interface CubeMapInfo {
  39266. /**
  39267. * The pixel array for the front face.
  39268. * This is stored in format, left to right, up to down format.
  39269. */
  39270. front: Nullable<ArrayBufferView>;
  39271. /**
  39272. * The pixel array for the back face.
  39273. * This is stored in format, left to right, up to down format.
  39274. */
  39275. back: Nullable<ArrayBufferView>;
  39276. /**
  39277. * The pixel array for the left face.
  39278. * This is stored in format, left to right, up to down format.
  39279. */
  39280. left: Nullable<ArrayBufferView>;
  39281. /**
  39282. * The pixel array for the right face.
  39283. * This is stored in format, left to right, up to down format.
  39284. */
  39285. right: Nullable<ArrayBufferView>;
  39286. /**
  39287. * The pixel array for the up face.
  39288. * This is stored in format, left to right, up to down format.
  39289. */
  39290. up: Nullable<ArrayBufferView>;
  39291. /**
  39292. * The pixel array for the down face.
  39293. * This is stored in format, left to right, up to down format.
  39294. */
  39295. down: Nullable<ArrayBufferView>;
  39296. /**
  39297. * The size of the cubemap stored.
  39298. *
  39299. * Each faces will be size * size pixels.
  39300. */
  39301. size: number;
  39302. /**
  39303. * The format of the texture.
  39304. *
  39305. * RGBA, RGB.
  39306. */
  39307. format: number;
  39308. /**
  39309. * The type of the texture data.
  39310. *
  39311. * UNSIGNED_INT, FLOAT.
  39312. */
  39313. type: number;
  39314. /**
  39315. * Specifies whether the texture is in gamma space.
  39316. */
  39317. gammaSpace: boolean;
  39318. }
  39319. /**
  39320. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  39321. */
  39322. class PanoramaToCubeMapTools {
  39323. private static FACE_FRONT;
  39324. private static FACE_BACK;
  39325. private static FACE_RIGHT;
  39326. private static FACE_LEFT;
  39327. private static FACE_DOWN;
  39328. private static FACE_UP;
  39329. /**
  39330. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  39331. *
  39332. * @param float32Array The source data.
  39333. * @param inputWidth The width of the input panorama.
  39334. * @param inputhHeight The height of the input panorama.
  39335. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  39336. * @return The cubemap data
  39337. */
  39338. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  39339. private static CreateCubemapTexture;
  39340. private static CalcProjectionSpherical;
  39341. }
  39342. }
  39343. declare module BABYLON {
  39344. }
  39345. declare module BABYLON {
  39346. }
  39347. declare module BABYLON {
  39348. }
  39349. declare module BABYLON {
  39350. }
  39351. declare module BABYLON {
  39352. class CustomProceduralTexture extends ProceduralTexture {
  39353. private _animate;
  39354. private _time;
  39355. private _config;
  39356. private _texturePath;
  39357. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39358. private loadJson;
  39359. isReady(): boolean;
  39360. render(useCameraPostProcess?: boolean): void;
  39361. updateTextures(): void;
  39362. updateShaderUniforms(): void;
  39363. animate: boolean;
  39364. }
  39365. }
  39366. declare module BABYLON {
  39367. /**
  39368. * Class used to generate noise procedural textures
  39369. */
  39370. class NoiseProceduralTexture extends ProceduralTexture {
  39371. private _time;
  39372. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  39373. brightness: number;
  39374. /** Defines the number of octaves to process */
  39375. octaves: number;
  39376. /** Defines the level of persistence (0.8 by default) */
  39377. persistence: number;
  39378. /** Gets or sets animation speed factor (default is 1) */
  39379. animationSpeedFactor: number;
  39380. /**
  39381. * Creates a new NoiseProceduralTexture
  39382. * @param name defines the name fo the texture
  39383. * @param size defines the size of the texture (default is 256)
  39384. * @param scene defines the hosting scene
  39385. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  39386. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  39387. */
  39388. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39389. private _updateShaderUniforms;
  39390. protected _getDefines(): string;
  39391. /** Generate the current state of the procedural texture */
  39392. render(useCameraPostProcess?: boolean): void;
  39393. /**
  39394. * Serializes this noise procedural texture
  39395. * @returns a serialized noise procedural texture object
  39396. */
  39397. serialize(): any;
  39398. /**
  39399. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  39400. * @param parsedTexture defines parsed texture data
  39401. * @param scene defines the current scene
  39402. * @param rootUrl defines the root URL containing noise procedural texture information
  39403. * @returns a parsed NoiseProceduralTexture
  39404. */
  39405. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39406. }
  39407. }
  39408. declare module BABYLON {
  39409. class ProceduralTexture extends Texture {
  39410. isCube: boolean;
  39411. private _size;
  39412. /** @hidden */
  39413. _generateMipMaps: boolean;
  39414. isEnabled: boolean;
  39415. private _currentRefreshId;
  39416. private _refreshRate;
  39417. onGenerated: () => void;
  39418. private _vertexBuffers;
  39419. private _indexBuffer;
  39420. private _effect;
  39421. private _uniforms;
  39422. private _samplers;
  39423. private _fragment;
  39424. /** @hidden */
  39425. _textures: {
  39426. [key: string]: Texture;
  39427. };
  39428. private _floats;
  39429. private _ints;
  39430. private _floatsArrays;
  39431. private _colors3;
  39432. private _colors4;
  39433. private _vectors2;
  39434. private _vectors3;
  39435. private _matrices;
  39436. private _fallbackTexture;
  39437. private _fallbackTextureUsed;
  39438. private _engine;
  39439. private _cachedDefines;
  39440. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39441. private _createIndexBuffer;
  39442. /** @hidden */
  39443. _rebuild(): void;
  39444. reset(): void;
  39445. protected _getDefines(): string;
  39446. isReady(): boolean;
  39447. resetRefreshCounter(): void;
  39448. setFragment(fragment: any): void;
  39449. refreshRate: number;
  39450. /** @hidden */
  39451. _shouldRender(): boolean;
  39452. getRenderSize(): number;
  39453. resize(size: number, generateMipMaps: boolean): void;
  39454. private _checkUniform;
  39455. setTexture(name: string, texture: Texture): ProceduralTexture;
  39456. setFloat(name: string, value: number): ProceduralTexture;
  39457. /**
  39458. * Set the value of an uniform to an integer value
  39459. * @param name defines the name of the uniform
  39460. * @param value defines the value to set
  39461. * @returns the current procedural texture
  39462. */
  39463. setInt(name: string, value: number): ProceduralTexture;
  39464. setFloats(name: string, value: number[]): ProceduralTexture;
  39465. setColor3(name: string, value: Color3): ProceduralTexture;
  39466. setColor4(name: string, value: Color4): ProceduralTexture;
  39467. setVector2(name: string, value: Vector2): ProceduralTexture;
  39468. setVector3(name: string, value: Vector3): ProceduralTexture;
  39469. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39470. render(useCameraPostProcess?: boolean): void;
  39471. clone(): ProceduralTexture;
  39472. dispose(): void;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. interface AbstractScene {
  39477. /**
  39478. * The list of procedural textures added to the scene
  39479. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  39480. */
  39481. proceduralTextures: Array<ProceduralTexture>;
  39482. }
  39483. /**
  39484. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  39485. * in a given scene.
  39486. */
  39487. class ProceduralTextureSceneComponent implements ISceneComponent {
  39488. /**
  39489. * The component name helpfull to identify the component in the list of scene components.
  39490. */
  39491. readonly name: string;
  39492. /**
  39493. * The scene the component belongs to.
  39494. */
  39495. scene: Scene;
  39496. /**
  39497. * Creates a new instance of the component for the given scene
  39498. * @param scene Defines the scene to register the component in
  39499. */
  39500. constructor(scene: Scene);
  39501. /**
  39502. * Registers the component in a given scene
  39503. */
  39504. register(): void;
  39505. /**
  39506. * Rebuilds the elements related to this component in case of
  39507. * context lost for instance.
  39508. */
  39509. rebuild(): void;
  39510. /**
  39511. * Disposes the component and the associated ressources.
  39512. */
  39513. dispose(): void;
  39514. private _beforeClear;
  39515. }
  39516. }
  39517. declare module BABYLON {
  39518. /**
  39519. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  39520. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39521. */
  39522. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39523. private _scene;
  39524. private _camerasToBeAttached;
  39525. /**
  39526. * ID of the sharpen post process,
  39527. */
  39528. private readonly SharpenPostProcessId;
  39529. /**
  39530. * ID of the image processing post process;
  39531. */
  39532. readonly ImageProcessingPostProcessId: string;
  39533. /**
  39534. * ID of the Fast Approximate Anti-Aliasing post process;
  39535. */
  39536. readonly FxaaPostProcessId: string;
  39537. /**
  39538. * ID of the chromatic aberration post process,
  39539. */
  39540. private readonly ChromaticAberrationPostProcessId;
  39541. /**
  39542. * ID of the grain post process
  39543. */
  39544. private readonly GrainPostProcessId;
  39545. /**
  39546. * Sharpen post process which will apply a sharpen convolution to enhance edges
  39547. */
  39548. sharpen: SharpenPostProcess;
  39549. private _sharpenEffect;
  39550. private bloom;
  39551. /**
  39552. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  39553. */
  39554. depthOfField: DepthOfFieldEffect;
  39555. /**
  39556. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  39557. */
  39558. fxaa: FxaaPostProcess;
  39559. /**
  39560. * Image post processing pass used to perform operations such as tone mapping or color grading.
  39561. */
  39562. imageProcessing: ImageProcessingPostProcess;
  39563. /**
  39564. * Chromatic aberration post process which will shift rgb colors in the image
  39565. */
  39566. chromaticAberration: ChromaticAberrationPostProcess;
  39567. private _chromaticAberrationEffect;
  39568. /**
  39569. * Grain post process which add noise to the image
  39570. */
  39571. grain: GrainPostProcess;
  39572. private _grainEffect;
  39573. /**
  39574. * Glow post process which adds a glow to emmisive areas of the image
  39575. */
  39576. private _glowLayer;
  39577. /**
  39578. * Animations which can be used to tweak settings over a period of time
  39579. */
  39580. animations: Animation[];
  39581. private _imageProcessingConfigurationObserver;
  39582. private _sharpenEnabled;
  39583. private _bloomEnabled;
  39584. private _depthOfFieldEnabled;
  39585. private _depthOfFieldBlurLevel;
  39586. private _fxaaEnabled;
  39587. private _imageProcessingEnabled;
  39588. private _defaultPipelineTextureType;
  39589. private _bloomScale;
  39590. private _chromaticAberrationEnabled;
  39591. private _grainEnabled;
  39592. private _buildAllowed;
  39593. /**
  39594. * Enable or disable the sharpen process from the pipeline
  39595. */
  39596. sharpenEnabled: boolean;
  39597. private _resizeObserver;
  39598. private _hardwareScaleLevel;
  39599. private _bloomKernel;
  39600. /**
  39601. * Specifies the size of the bloom blur kernel, relative to the final output size
  39602. */
  39603. bloomKernel: number;
  39604. /**
  39605. * Specifies the weight of the bloom in the final rendering
  39606. */
  39607. private _bloomWeight;
  39608. /**
  39609. * Specifies the luma threshold for the area that will be blurred by the bloom
  39610. */
  39611. private _bloomThreshold;
  39612. private _hdr;
  39613. /**
  39614. * The strength of the bloom.
  39615. */
  39616. bloomWeight: number;
  39617. /**
  39618. * The strength of the bloom.
  39619. */
  39620. bloomThreshold: number;
  39621. /**
  39622. * The scale of the bloom, lower value will provide better performance.
  39623. */
  39624. bloomScale: number;
  39625. /**
  39626. * Enable or disable the bloom from the pipeline
  39627. */
  39628. bloomEnabled: boolean;
  39629. private _rebuildBloom;
  39630. /**
  39631. * If the depth of field is enabled.
  39632. */
  39633. depthOfFieldEnabled: boolean;
  39634. /**
  39635. * Blur level of the depth of field effect. (Higher blur will effect performance)
  39636. */
  39637. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  39638. /**
  39639. * If the anti aliasing is enabled.
  39640. */
  39641. fxaaEnabled: boolean;
  39642. private _samples;
  39643. /**
  39644. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  39645. */
  39646. samples: number;
  39647. /**
  39648. * If image processing is enabled.
  39649. */
  39650. imageProcessingEnabled: boolean;
  39651. /**
  39652. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  39653. */
  39654. glowLayerEnabled: boolean;
  39655. /**
  39656. * Enable or disable the chromaticAberration process from the pipeline
  39657. */
  39658. chromaticAberrationEnabled: boolean;
  39659. /**
  39660. * Enable or disable the grain process from the pipeline
  39661. */
  39662. grainEnabled: boolean;
  39663. /**
  39664. * @constructor
  39665. * @param {string} name - The rendering pipeline name (default: "")
  39666. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  39667. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  39668. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  39669. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  39670. */
  39671. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  39672. /**
  39673. * Force the compilation of the entire pipeline.
  39674. */
  39675. prepare(): void;
  39676. private _hasCleared;
  39677. private _prevPostProcess;
  39678. private _prevPrevPostProcess;
  39679. private _setAutoClearAndTextureSharing;
  39680. private _buildPipeline;
  39681. private _disposePostProcesses;
  39682. /**
  39683. * Adds a camera to the pipeline
  39684. * @param camera the camera to be added
  39685. */
  39686. addCamera(camera: Camera): void;
  39687. /**
  39688. * Removes a camera from the pipeline
  39689. * @param camera the camera to remove
  39690. */
  39691. removeCamera(camera: Camera): void;
  39692. /**
  39693. * Dispose of the pipeline and stop all post processes
  39694. */
  39695. dispose(): void;
  39696. /**
  39697. * Serialize the rendering pipeline (Used when exporting)
  39698. * @returns the serialized object
  39699. */
  39700. serialize(): any;
  39701. /**
  39702. * Parse the serialized pipeline
  39703. * @param source Source pipeline.
  39704. * @param scene The scene to load the pipeline to.
  39705. * @param rootUrl The URL of the serialized pipeline.
  39706. * @returns An instantiated pipeline from the serialized object.
  39707. */
  39708. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  39709. }
  39710. }
  39711. declare module BABYLON {
  39712. class LensRenderingPipeline extends PostProcessRenderPipeline {
  39713. /**
  39714. * The chromatic aberration PostProcess id in the pipeline
  39715. */
  39716. LensChromaticAberrationEffect: string;
  39717. /**
  39718. * The highlights enhancing PostProcess id in the pipeline
  39719. */
  39720. HighlightsEnhancingEffect: string;
  39721. /**
  39722. * The depth-of-field PostProcess id in the pipeline
  39723. */
  39724. LensDepthOfFieldEffect: string;
  39725. private _scene;
  39726. private _depthTexture;
  39727. private _grainTexture;
  39728. private _chromaticAberrationPostProcess;
  39729. private _highlightsPostProcess;
  39730. private _depthOfFieldPostProcess;
  39731. private _edgeBlur;
  39732. private _grainAmount;
  39733. private _chromaticAberration;
  39734. private _distortion;
  39735. private _highlightsGain;
  39736. private _highlightsThreshold;
  39737. private _dofDistance;
  39738. private _dofAperture;
  39739. private _dofDarken;
  39740. private _dofPentagon;
  39741. private _blurNoise;
  39742. /**
  39743. * @constructor
  39744. *
  39745. * Effect parameters are as follow:
  39746. * {
  39747. * chromatic_aberration: number; // from 0 to x (1 for realism)
  39748. * edge_blur: number; // from 0 to x (1 for realism)
  39749. * distortion: number; // from 0 to x (1 for realism)
  39750. * grain_amount: number; // from 0 to 1
  39751. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  39752. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  39753. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  39754. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  39755. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  39756. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  39757. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  39758. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  39759. * }
  39760. * Note: if an effect parameter is unset, effect is disabled
  39761. *
  39762. * @param {string} name - The rendering pipeline name
  39763. * @param {object} parameters - An object containing all parameters (see above)
  39764. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39765. * @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)
  39766. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39767. */
  39768. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  39769. setEdgeBlur(amount: number): void;
  39770. disableEdgeBlur(): void;
  39771. setGrainAmount(amount: number): void;
  39772. disableGrain(): void;
  39773. setChromaticAberration(amount: number): void;
  39774. disableChromaticAberration(): void;
  39775. setEdgeDistortion(amount: number): void;
  39776. disableEdgeDistortion(): void;
  39777. setFocusDistance(amount: number): void;
  39778. disableDepthOfField(): void;
  39779. setAperture(amount: number): void;
  39780. setDarkenOutOfFocus(amount: number): void;
  39781. enablePentagonBokeh(): void;
  39782. disablePentagonBokeh(): void;
  39783. enableNoiseBlur(): void;
  39784. disableNoiseBlur(): void;
  39785. setHighlightsGain(amount: number): void;
  39786. setHighlightsThreshold(amount: number): void;
  39787. disableHighlights(): void;
  39788. /**
  39789. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  39790. */
  39791. dispose(disableDepthRender?: boolean): void;
  39792. private _createChromaticAberrationPostProcess;
  39793. private _createHighlightsPostProcess;
  39794. private _createDepthOfFieldPostProcess;
  39795. private _createGrainTexture;
  39796. }
  39797. }
  39798. declare module BABYLON {
  39799. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  39800. /**
  39801. * The PassPostProcess id in the pipeline that contains the original scene color
  39802. */
  39803. SSAOOriginalSceneColorEffect: string;
  39804. /**
  39805. * The SSAO PostProcess id in the pipeline
  39806. */
  39807. SSAORenderEffect: string;
  39808. /**
  39809. * The horizontal blur PostProcess id in the pipeline
  39810. */
  39811. SSAOBlurHRenderEffect: string;
  39812. /**
  39813. * The vertical blur PostProcess id in the pipeline
  39814. */
  39815. SSAOBlurVRenderEffect: string;
  39816. /**
  39817. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39818. */
  39819. SSAOCombineRenderEffect: string;
  39820. /**
  39821. * The output strength of the SSAO post-process. Default value is 1.0.
  39822. */
  39823. totalStrength: number;
  39824. /**
  39825. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  39826. */
  39827. maxZ: number;
  39828. /**
  39829. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  39830. */
  39831. minZAspect: number;
  39832. private _samples;
  39833. /**
  39834. * Number of samples used for the SSAO calculations. Default value is 8
  39835. */
  39836. samples: number;
  39837. private _textureSamples;
  39838. /**
  39839. * Number of samples to use for antialiasing
  39840. */
  39841. textureSamples: number;
  39842. /**
  39843. * Ratio object used for SSAO ratio and blur ratio
  39844. */
  39845. private _ratio;
  39846. /**
  39847. * Dynamically generated sphere sampler.
  39848. */
  39849. private _sampleSphere;
  39850. /**
  39851. * Blur filter offsets
  39852. */
  39853. private _samplerOffsets;
  39854. /**
  39855. * Are we using bilateral blur ?
  39856. */
  39857. private _expensiveBlur;
  39858. expensiveBlur: boolean;
  39859. /**
  39860. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39861. */
  39862. radius: number;
  39863. /**
  39864. * The base color of the SSAO post-process
  39865. * The final result is "base + ssao" between [0, 1]
  39866. */
  39867. base: number;
  39868. /**
  39869. * Support test.
  39870. */
  39871. static readonly IsSupported: boolean;
  39872. private _scene;
  39873. private _depthTexture;
  39874. private _normalTexture;
  39875. private _randomTexture;
  39876. private _originalColorPostProcess;
  39877. private _ssaoPostProcess;
  39878. private _blurHPostProcess;
  39879. private _blurVPostProcess;
  39880. private _ssaoCombinePostProcess;
  39881. private _firstUpdate;
  39882. /**
  39883. * @constructor
  39884. * @param {string} name - The rendering pipeline name
  39885. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39886. * @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 }
  39887. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39888. */
  39889. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39890. /**
  39891. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39892. */
  39893. dispose(disableGeometryBufferRenderer?: boolean): void;
  39894. private _createBlurPostProcess;
  39895. /** @hidden */
  39896. _rebuild(): void;
  39897. private _bits;
  39898. private _radicalInverse_VdC;
  39899. private _hammersley;
  39900. private _hemisphereSample_uniform;
  39901. private _generateHemisphere;
  39902. private _createSSAOPostProcess;
  39903. private _createSSAOCombinePostProcess;
  39904. private _createRandomTexture;
  39905. /**
  39906. * Serialize the rendering pipeline (Used when exporting)
  39907. * @returns the serialized object
  39908. */
  39909. serialize(): any;
  39910. /**
  39911. * Parse the serialized pipeline
  39912. * @param source Source pipeline.
  39913. * @param scene The scene to load the pipeline to.
  39914. * @param rootUrl The URL of the serialized pipeline.
  39915. * @returns An instantiated pipeline from the serialized object.
  39916. */
  39917. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39918. }
  39919. }
  39920. declare module BABYLON {
  39921. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39922. /**
  39923. * The PassPostProcess id in the pipeline that contains the original scene color
  39924. */
  39925. SSAOOriginalSceneColorEffect: string;
  39926. /**
  39927. * The SSAO PostProcess id in the pipeline
  39928. */
  39929. SSAORenderEffect: string;
  39930. /**
  39931. * The horizontal blur PostProcess id in the pipeline
  39932. */
  39933. SSAOBlurHRenderEffect: string;
  39934. /**
  39935. * The vertical blur PostProcess id in the pipeline
  39936. */
  39937. SSAOBlurVRenderEffect: string;
  39938. /**
  39939. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39940. */
  39941. SSAOCombineRenderEffect: string;
  39942. /**
  39943. * The output strength of the SSAO post-process. Default value is 1.0.
  39944. */
  39945. totalStrength: number;
  39946. /**
  39947. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39948. */
  39949. radius: number;
  39950. /**
  39951. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39952. * Must not be equal to fallOff and superior to fallOff.
  39953. * Default value is 0.975
  39954. */
  39955. area: number;
  39956. /**
  39957. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39958. * Must not be equal to area and inferior to area.
  39959. * Default value is 0.0
  39960. */
  39961. fallOff: number;
  39962. /**
  39963. * The base color of the SSAO post-process
  39964. * The final result is "base + ssao" between [0, 1]
  39965. */
  39966. base: number;
  39967. private _scene;
  39968. private _depthTexture;
  39969. private _randomTexture;
  39970. private _originalColorPostProcess;
  39971. private _ssaoPostProcess;
  39972. private _blurHPostProcess;
  39973. private _blurVPostProcess;
  39974. private _ssaoCombinePostProcess;
  39975. private _firstUpdate;
  39976. /**
  39977. * @constructor
  39978. * @param {string} name - The rendering pipeline name
  39979. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39980. * @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 }
  39981. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39982. */
  39983. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39984. /**
  39985. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39986. */
  39987. dispose(disableDepthRender?: boolean): void;
  39988. private _createBlurPostProcess;
  39989. /** @hidden */
  39990. _rebuild(): void;
  39991. private _createSSAOPostProcess;
  39992. private _createSSAOCombinePostProcess;
  39993. private _createRandomTexture;
  39994. }
  39995. }
  39996. declare module BABYLON {
  39997. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39998. /**
  39999. * Public members
  40000. */
  40001. originalPostProcess: Nullable<PostProcess>;
  40002. downSampleX4PostProcess: Nullable<PostProcess>;
  40003. brightPassPostProcess: Nullable<PostProcess>;
  40004. blurHPostProcesses: PostProcess[];
  40005. blurVPostProcesses: PostProcess[];
  40006. textureAdderPostProcess: Nullable<PostProcess>;
  40007. volumetricLightPostProcess: Nullable<PostProcess>;
  40008. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  40009. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  40010. volumetricLightMergePostProces: Nullable<PostProcess>;
  40011. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  40012. luminancePostProcess: Nullable<PostProcess>;
  40013. luminanceDownSamplePostProcesses: PostProcess[];
  40014. hdrPostProcess: Nullable<PostProcess>;
  40015. textureAdderFinalPostProcess: Nullable<PostProcess>;
  40016. lensFlareFinalPostProcess: Nullable<PostProcess>;
  40017. hdrFinalPostProcess: Nullable<PostProcess>;
  40018. lensFlarePostProcess: Nullable<PostProcess>;
  40019. lensFlareComposePostProcess: Nullable<PostProcess>;
  40020. motionBlurPostProcess: Nullable<PostProcess>;
  40021. depthOfFieldPostProcess: Nullable<PostProcess>;
  40022. brightThreshold: number;
  40023. blurWidth: number;
  40024. horizontalBlur: boolean;
  40025. exposure: number;
  40026. lensTexture: Nullable<Texture>;
  40027. volumetricLightCoefficient: number;
  40028. volumetricLightPower: number;
  40029. volumetricLightBlurScale: number;
  40030. sourceLight: Nullable<SpotLight | DirectionalLight>;
  40031. hdrMinimumLuminance: number;
  40032. hdrDecreaseRate: number;
  40033. hdrIncreaseRate: number;
  40034. lensColorTexture: Nullable<Texture>;
  40035. lensFlareStrength: number;
  40036. lensFlareGhostDispersal: number;
  40037. lensFlareHaloWidth: number;
  40038. lensFlareDistortionStrength: number;
  40039. lensStarTexture: Nullable<Texture>;
  40040. lensFlareDirtTexture: Nullable<Texture>;
  40041. depthOfFieldDistance: number;
  40042. depthOfFieldBlurWidth: number;
  40043. motionStrength: number;
  40044. animations: Animation[];
  40045. /**
  40046. * Private members
  40047. */
  40048. private _scene;
  40049. private _currentDepthOfFieldSource;
  40050. private _basePostProcess;
  40051. private _hdrCurrentLuminance;
  40052. private _floatTextureType;
  40053. private _ratio;
  40054. private _bloomEnabled;
  40055. private _depthOfFieldEnabled;
  40056. private _vlsEnabled;
  40057. private _lensFlareEnabled;
  40058. private _hdrEnabled;
  40059. private _motionBlurEnabled;
  40060. private _motionBlurSamples;
  40061. private _volumetricLightStepsCount;
  40062. BloomEnabled: boolean;
  40063. DepthOfFieldEnabled: boolean;
  40064. LensFlareEnabled: boolean;
  40065. HDREnabled: boolean;
  40066. VLSEnabled: boolean;
  40067. MotionBlurEnabled: boolean;
  40068. volumetricLightStepsCount: number;
  40069. motionBlurSamples: number;
  40070. /**
  40071. * @constructor
  40072. * @param {string} name - The rendering pipeline name
  40073. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40074. * @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)
  40075. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  40076. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40077. */
  40078. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  40079. private _buildPipeline;
  40080. private _createDownSampleX4PostProcess;
  40081. private _createBrightPassPostProcess;
  40082. private _createBlurPostProcesses;
  40083. private _createTextureAdderPostProcess;
  40084. private _createVolumetricLightPostProcess;
  40085. private _createLuminancePostProcesses;
  40086. private _createHdrPostProcess;
  40087. private _createLensFlarePostProcess;
  40088. private _createDepthOfFieldPostProcess;
  40089. private _createMotionBlurPostProcess;
  40090. private _getDepthTexture;
  40091. private _disposePostProcesses;
  40092. /**
  40093. * Dispose of the pipeline and stop all post processes
  40094. */
  40095. dispose(): void;
  40096. /**
  40097. * Serialize the rendering pipeline (Used when exporting)
  40098. * @returns the serialized object
  40099. */
  40100. serialize(): any;
  40101. /**
  40102. * Parse the serialized pipeline
  40103. * @param source Source pipeline.
  40104. * @param scene The scene to load the pipeline to.
  40105. * @param rootUrl The URL of the serialized pipeline.
  40106. * @returns An instantiated pipeline from the serialized object.
  40107. */
  40108. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  40109. static LuminanceSteps: number;
  40110. }
  40111. }