babylon.d.ts 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. */
  8. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  9. /**
  10. * Base class of the scene acting as a container for the different elements composing a scene.
  11. * This class is dynamically extended by the different components of the scene increasing
  12. * flexibility and reducing coupling.
  13. */
  14. abstract class AbstractScene {
  15. /**
  16. * Stores the list of available parsers in the application.
  17. */
  18. private static _BabylonFileParsers;
  19. /**
  20. * Adds a parser in the list of availables ones.
  21. * @param name Defines the name of the parser
  22. * @param parser Defines the parser to add
  23. */
  24. static AddParser(name: string, parser: BabylonFileParser): void;
  25. /**
  26. * Parser json data and populate both a scene and its associated container object
  27. * @param jsonData Defines the data to parse
  28. * @param scene Defines the scene to parse the data for
  29. * @param container Defines the container attached to the parsing sequence
  30. * @param rootUrl Defines the root url of the data
  31. */
  32. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33. /** All of the cameras added to this scene
  34. * @see http://doc.babylonjs.com/babylon101/cameras
  35. */
  36. cameras: Camera[];
  37. /**
  38. * All of the lights added to this scene
  39. * @see http://doc.babylonjs.com/babylon101/lights
  40. */
  41. lights: Light[];
  42. /**
  43. * All of the (abstract) meshes added to this scene
  44. */
  45. meshes: AbstractMesh[];
  46. /**
  47. * The list of skeletons added to the scene
  48. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49. */
  50. skeletons: Skeleton[];
  51. /**
  52. * All of the particle systems added to this scene
  53. * @see http://doc.babylonjs.com/babylon101/particles
  54. */
  55. particleSystems: IParticleSystem[];
  56. /**
  57. * Gets a list of Animations associated with the scene
  58. */
  59. animations: Animation[];
  60. /**
  61. * All of the animation groups added to this scene
  62. * @see http://doc.babylonjs.com/how_to/group
  63. */
  64. animationGroups: AnimationGroup[];
  65. /**
  66. * All of the multi-materials added to this scene
  67. * @see http://doc.babylonjs.com/how_to/multi_materials
  68. */
  69. multiMaterials: MultiMaterial[];
  70. /**
  71. * All of the materials added to this scene
  72. * @see http://doc.babylonjs.com/babylon101/materials
  73. */
  74. materials: Material[];
  75. /**
  76. * The list of morph target managers added to the scene
  77. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  78. */
  79. morphTargetManagers: MorphTargetManager[];
  80. /**
  81. * The list of geometries used in the scene.
  82. */
  83. geometries: Geometry[];
  84. /**
  85. * All of the tranform nodes added to this scene
  86. * @see http://doc.babylonjs.com/how_to/transformnode
  87. */
  88. transformNodes: TransformNode[];
  89. /**
  90. * ActionManagers available on the scene.
  91. */
  92. actionManagers: ActionManager[];
  93. /**
  94. * Sounds to keep.
  95. */
  96. sounds: Sound[];
  97. /**
  98. * Textures to keep.
  99. */
  100. textures: BaseTexture[];
  101. }
  102. }
  103. declare module BABYLON {
  104. /**
  105. * Set of assets to keep when moving a scene into an asset container.
  106. */
  107. class KeepAssets extends AbstractScene {
  108. }
  109. /**
  110. * Container with a set of assets that can be added or removed from a scene.
  111. */
  112. class AssetContainer extends AbstractScene {
  113. /**
  114. * The scene the AssetContainer belongs to.
  115. */
  116. scene: Scene;
  117. /**
  118. * Instantiates an AssetContainer.
  119. * @param scene The scene the AssetContainer belongs to.
  120. */
  121. constructor(scene: Scene);
  122. /**
  123. * Adds all the assets from the container to the scene.
  124. */
  125. addAllToScene(): void;
  126. /**
  127. * Removes all the assets in the container from the scene
  128. */
  129. removeAllFromScene(): void;
  130. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  131. /**
  132. * Removes all the assets contained in the scene and adds them to the container.
  133. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  134. */
  135. moveAllFromScene(keepAssets?: KeepAssets): void;
  136. /**
  137. * 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.
  138. * @returns the root mesh
  139. */
  140. createRootMesh(): Mesh;
  141. }
  142. }
  143. interface Window {
  144. mozIndexedDB: IDBFactory;
  145. webkitIndexedDB: IDBFactory;
  146. msIndexedDB: IDBFactory;
  147. webkitURL: typeof URL;
  148. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  149. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150. WebGLRenderingContext: WebGLRenderingContext;
  151. MSGesture: MSGesture;
  152. CANNON: any;
  153. AudioContext: AudioContext;
  154. webkitAudioContext: AudioContext;
  155. PointerEvent: any;
  156. Math: Math;
  157. Uint8Array: Uint8ArrayConstructor;
  158. Float32Array: Float32ArrayConstructor;
  159. mozURL: typeof URL;
  160. msURL: typeof URL;
  161. VRFrameData: any;
  162. DracoDecoderModule: any;
  163. }
  164. interface WebGLRenderingContext {
  165. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  166. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  167. vertexAttribDivisor(index: number, divisor: number): void;
  168. createVertexArray(): any;
  169. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  170. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  171. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  172. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  173. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  174. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  175. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  176. createQuery(): WebGLQuery;
  177. deleteQuery(query: WebGLQuery): void;
  178. beginQuery(target: number, query: WebGLQuery): void;
  179. endQuery(target: number): void;
  180. getQueryParameter(query: WebGLQuery, pname: number): any;
  181. getQuery(target: number, pname: number): any;
  182. MAX_SAMPLES: number;
  183. RGBA8: number;
  184. READ_FRAMEBUFFER: number;
  185. DRAW_FRAMEBUFFER: number;
  186. UNIFORM_BUFFER: number;
  187. HALF_FLOAT_OES: number;
  188. RGBA16F: number;
  189. RGBA32F: number;
  190. R32F: number;
  191. RG32F: number;
  192. RGB32F: number;
  193. R16F: number;
  194. RG16F: number;
  195. RGB16F: number;
  196. RED: number;
  197. RG: number;
  198. R8: number;
  199. RG8: number;
  200. UNSIGNED_INT_24_8: number;
  201. DEPTH24_STENCIL8: number;
  202. drawBuffers(buffers: number[]): void;
  203. readBuffer(src: number): void;
  204. readonly COLOR_ATTACHMENT0: number;
  205. readonly COLOR_ATTACHMENT1: number;
  206. readonly COLOR_ATTACHMENT2: number;
  207. readonly COLOR_ATTACHMENT3: number;
  208. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  209. ANY_SAMPLES_PASSED: number;
  210. QUERY_RESULT_AVAILABLE: number;
  211. QUERY_RESULT: number;
  212. }
  213. interface Document {
  214. mozCancelFullScreen(): void;
  215. msCancelFullScreen(): void;
  216. mozFullScreen: boolean;
  217. msIsFullScreen: boolean;
  218. fullscreen: boolean;
  219. mozPointerLockElement: HTMLElement;
  220. msPointerLockElement: HTMLElement;
  221. webkitPointerLockElement: HTMLElement;
  222. }
  223. interface HTMLCanvasElement {
  224. msRequestPointerLock?(): void;
  225. mozRequestPointerLock?(): void;
  226. webkitRequestPointerLock?(): void;
  227. }
  228. interface CanvasRenderingContext2D {
  229. msImageSmoothingEnabled: boolean;
  230. }
  231. interface WebGLBuffer {
  232. references: number;
  233. capacity: number;
  234. is32Bits: boolean;
  235. }
  236. interface WebGLProgram {
  237. transformFeedback?: WebGLTransformFeedback | null;
  238. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  239. }
  240. interface MouseEvent {
  241. mozMovementX: number;
  242. mozMovementY: number;
  243. webkitMovementX: number;
  244. webkitMovementY: number;
  245. msMovementX: number;
  246. msMovementY: number;
  247. }
  248. interface Navigator {
  249. mozGetVRDevices: (any: any) => any;
  250. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  251. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  252. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  253. webkitGetGamepads(): Gamepad[];
  254. msGetGamepads(): Gamepad[];
  255. webkitGamepads(): Gamepad[];
  256. }
  257. interface HTMLVideoElement {
  258. mozSrcObject: any;
  259. }
  260. interface Screen {
  261. orientation: string;
  262. mozOrientation: string;
  263. }
  264. interface Math {
  265. fround(x: number): number;
  266. imul(a: number, b: number): number;
  267. }
  268. interface EXT_disjoint_timer_query {
  269. QUERY_COUNTER_BITS_EXT: number;
  270. TIME_ELAPSED_EXT: number;
  271. TIMESTAMP_EXT: number;
  272. GPU_DISJOINT_EXT: number;
  273. QUERY_RESULT_EXT: number;
  274. QUERY_RESULT_AVAILABLE_EXT: number;
  275. queryCounterEXT(query: WebGLQuery, target: number): void;
  276. createQueryEXT(): WebGLQuery;
  277. beginQueryEXT(target: number, query: WebGLQuery): void;
  278. endQueryEXT(target: number): void;
  279. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  280. deleteQueryEXT(query: WebGLQuery): void;
  281. }
  282. interface WebGLUniformLocation {
  283. _currentState: any;
  284. }
  285. declare module BABYLON {
  286. /**
  287. * Node is the basic class for all scene objects (Mesh, Light Camera).
  288. */
  289. class Node implements IBehaviorAware<Node> {
  290. /**
  291. * Gets or sets the name of the node
  292. */
  293. name: string;
  294. /**
  295. * Gets or sets the id of the node
  296. */
  297. id: string;
  298. /**
  299. * Gets or sets the unique id of the node
  300. */
  301. uniqueId: number;
  302. /**
  303. * Gets or sets a string used to store user defined state for the node
  304. */
  305. state: string;
  306. /**
  307. * Gets or sets an object used to store user defined information for the node
  308. */
  309. metadata: any;
  310. /**
  311. * Gets or sets a boolean used to define if the node must be serialized
  312. */
  313. doNotSerialize: boolean;
  314. /** @hidden */
  315. _isDisposed: boolean;
  316. /**
  317. * Gets a list of Animations associated with the node
  318. */
  319. animations: Animation[];
  320. private _ranges;
  321. /**
  322. * Callback raised when the node is ready to be used
  323. */
  324. onReady: (node: Node) => void;
  325. private _isEnabled;
  326. private _isReady;
  327. /** @hidden */
  328. _currentRenderId: number;
  329. private _parentRenderId;
  330. protected _childRenderId: number;
  331. /** @hidden */
  332. _waitingParentId: Nullable<string>;
  333. private _scene;
  334. /** @hidden */
  335. _cache: any;
  336. private _parentNode;
  337. private _children;
  338. /**
  339. * Gets a boolean indicating if the node has been disposed
  340. * @returns true if the node was disposed
  341. */
  342. isDisposed(): boolean;
  343. /**
  344. * Gets or sets the parent of the node
  345. */
  346. parent: Nullable<Node>;
  347. private _animationPropertiesOverride;
  348. /**
  349. * Gets or sets the animation properties override
  350. */
  351. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  352. /**
  353. * Gets a string idenfifying the name of the class
  354. * @returns "Node" string
  355. */
  356. getClassName(): string;
  357. /**
  358. * An event triggered when the mesh is disposed
  359. */
  360. onDisposeObservable: Observable<Node>;
  361. private _onDisposeObserver;
  362. /**
  363. * Sets a callback that will be raised when the node will be disposed
  364. */
  365. onDispose: () => void;
  366. /**
  367. * Creates a new Node
  368. * @param {string} name - the name and id to be given to this node
  369. * @param {BABYLON.Scene} the scene this node will be added to
  370. */
  371. constructor(name: string, scene?: Nullable<Scene>);
  372. /**
  373. * Gets the scene of the node
  374. * @returns a {BABYLON.Scene}
  375. */
  376. getScene(): Scene;
  377. /**
  378. * Gets the engine of the node
  379. * @returns a {BABYLON.Engine}
  380. */
  381. getEngine(): Engine;
  382. private _behaviors;
  383. /**
  384. * Attach a behavior to the node
  385. * @see http://doc.babylonjs.com/features/behaviour
  386. * @param behavior defines the behavior to attach
  387. * @returns the current Node
  388. */
  389. addBehavior(behavior: Behavior<Node>): Node;
  390. /**
  391. * Remove an attached behavior
  392. * @see http://doc.babylonjs.com/features/behaviour
  393. * @param behavior defines the behavior to attach
  394. * @returns the current Node
  395. */
  396. removeBehavior(behavior: Behavior<Node>): Node;
  397. /**
  398. * Gets the list of attached behaviors
  399. * @see http://doc.babylonjs.com/features/behaviour
  400. */
  401. readonly behaviors: Behavior<Node>[];
  402. /**
  403. * Gets an attached behavior by name
  404. * @param name defines the name of the behavior to look for
  405. * @see http://doc.babylonjs.com/features/behaviour
  406. * @returns null if behavior was not found else the requested behavior
  407. */
  408. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  409. /**
  410. * Returns the world matrix of the node
  411. * @returns a matrix containing the node's world matrix
  412. */
  413. getWorldMatrix(): Matrix;
  414. /** @hidden */
  415. _getWorldMatrixDeterminant(): number;
  416. /** @hidden */
  417. _initCache(): void;
  418. /** @hidden */
  419. updateCache(force?: boolean): void;
  420. /** @hidden */
  421. _updateCache(ignoreParentClass?: boolean): void;
  422. /** @hidden */
  423. _isSynchronized(): boolean;
  424. /** @hidden */
  425. _markSyncedWithParent(): void;
  426. /** @hidden */
  427. isSynchronizedWithParent(): boolean;
  428. /** @hidden */
  429. isSynchronized(updateCache?: boolean): boolean;
  430. /** @hidden */
  431. hasNewParent(update?: boolean): boolean;
  432. /**
  433. * Is this node ready to be used/rendered
  434. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  435. * @return true if the node is ready
  436. */
  437. isReady(completeCheck?: boolean): boolean;
  438. /**
  439. * Is this node enabled?
  440. * 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
  441. * @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
  442. * @return whether this node (and its parent) is enabled
  443. */
  444. isEnabled(checkAncestors?: boolean): boolean;
  445. /**
  446. * Set the enabled state of this node
  447. * @param value defines the new enabled state
  448. */
  449. setEnabled(value: boolean): void;
  450. /**
  451. * Is this node a descendant of the given node?
  452. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  453. * @param ancestor defines the parent node to inspect
  454. * @returns a boolean indicating if this node is a descendant of the given node
  455. */
  456. isDescendantOf(ancestor: Node): boolean;
  457. /** @hidden */
  458. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  459. /**
  460. * Will return all nodes that have this node as ascendant
  461. * @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
  462. * @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
  463. * @return all children nodes of all types
  464. */
  465. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  466. /**
  467. * Get all child-meshes of this node
  468. * @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
  469. * @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
  470. * @returns an array of {BABYLON.AbstractMesh}
  471. */
  472. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  473. /**
  474. * Get all child-transformNodes of this node
  475. * @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
  476. * @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
  477. * @returns an array of {BABYLON.TransformNode}
  478. */
  479. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  480. /**
  481. * Get all direct children of this node
  482. * @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
  483. * @returns an array of {BABYLON.Node}
  484. */
  485. getChildren(predicate?: (node: Node) => boolean): Node[];
  486. /** @hidden */
  487. _setReady(state: boolean): void;
  488. /**
  489. * Get an animation by name
  490. * @param name defines the name of the animation to look for
  491. * @returns null if not found else the requested animation
  492. */
  493. getAnimationByName(name: string): Nullable<Animation>;
  494. /**
  495. * Creates an animation range for this node
  496. * @param name defines the name of the range
  497. * @param from defines the starting key
  498. * @param to defines the end key
  499. */
  500. createAnimationRange(name: string, from: number, to: number): void;
  501. /**
  502. * Delete a specific animation range
  503. * @param name defines the name of the range to delete
  504. * @param deleteFrames defines if animation frames from the range must be deleted as well
  505. */
  506. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  507. /**
  508. * Get an animation range by name
  509. * @param name defines the name of the animation range to look for
  510. * @returns null if not found else the requested animation range
  511. */
  512. getAnimationRange(name: string): Nullable<AnimationRange>;
  513. /**
  514. * Will start the animation sequence
  515. * @param name defines the range frames for animation sequence
  516. * @param loop defines if the animation should loop (false by default)
  517. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  518. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  519. * @returns the object created for this animation. If range does not exist, it will return null
  520. */
  521. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  522. /**
  523. * Serialize animation ranges into a JSON compatible object
  524. * @returns serialization object
  525. */
  526. serializeAnimationRanges(): any;
  527. /**
  528. * Computes the world matrix of the node
  529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  530. * @returns the world matrix
  531. */
  532. computeWorldMatrix(force?: boolean): Matrix;
  533. /**
  534. * Releases resources associated with this node.
  535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  537. */
  538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  539. /**
  540. * Parse animation range data from a serialization object and store them into a given node
  541. * @param node defines where to store the animation ranges
  542. * @param parsedNode defines the serialization object to read data from
  543. * @param scene defines the hosting scene
  544. */
  545. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  546. }
  547. }
  548. declare module BABYLON {
  549. /**
  550. * Define an interface for all classes that will hold resources
  551. */
  552. interface IDisposable {
  553. /**
  554. * Releases all held resources
  555. */
  556. dispose(): void;
  557. }
  558. /**
  559. * Interface used to let developers provide their own mesh selection mechanism
  560. */
  561. interface IActiveMeshCandidateProvider {
  562. /**
  563. * Return the list of active meshes
  564. * @param scene defines the current scene
  565. * @returns the list of active meshes
  566. */
  567. getMeshes(scene: Scene): AbstractMesh[];
  568. /**
  569. * Indicates if the meshes have been checked to make sure they are isEnabled()
  570. */
  571. readonly checksIsEnabled: boolean;
  572. }
  573. /**
  574. * This class is used by the onRenderingGroupObservable
  575. */
  576. class RenderingGroupInfo {
  577. /**
  578. * The Scene that being rendered
  579. */
  580. scene: Scene;
  581. /**
  582. * The camera currently used for the rendering pass
  583. */
  584. camera: Nullable<Camera>;
  585. /**
  586. * The ID of the renderingGroup being processed
  587. */
  588. renderingGroupId: number;
  589. /**
  590. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  591. */
  592. renderStage: number;
  593. /**
  594. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  595. * This stage will be fired no matter what
  596. */
  597. static STAGE_PRECLEAR: number;
  598. /**
  599. * Called before opaque object are rendered.
  600. * This stage will be fired only if there's 3D Opaque content to render
  601. */
  602. static STAGE_PREOPAQUE: number;
  603. /**
  604. * Called after the opaque objects are rendered and before the transparent ones
  605. * This stage will be fired only if there's 3D transparent content to render
  606. */
  607. static STAGE_PRETRANSPARENT: number;
  608. /**
  609. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  610. * This stage will be fired no matter what
  611. */
  612. static STAGE_POSTTRANSPARENT: number;
  613. }
  614. /**
  615. * Represents a scene to be rendered by the engine.
  616. * @see http://doc.babylonjs.com/features/scene
  617. */
  618. class Scene extends AbstractScene implements IAnimatable {
  619. private static _FOGMODE_NONE;
  620. private static _FOGMODE_EXP;
  621. private static _FOGMODE_EXP2;
  622. private static _FOGMODE_LINEAR;
  623. private static _uniqueIdCounter;
  624. /**
  625. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  627. */
  628. static MinDeltaTime: number;
  629. /**
  630. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  632. */
  633. static MaxDeltaTime: number;
  634. /** The fog is deactivated */
  635. static readonly FOGMODE_NONE: number;
  636. /** The fog density is following an exponential function */
  637. static readonly FOGMODE_EXP: number;
  638. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  639. static readonly FOGMODE_EXP2: number;
  640. /** The fog density is following a linear function. */
  641. static readonly FOGMODE_LINEAR: number;
  642. /**
  643. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  644. */
  645. autoClear: boolean;
  646. /**
  647. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  648. */
  649. autoClearDepthAndStencil: boolean;
  650. /**
  651. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  652. */
  653. clearColor: Color4;
  654. /**
  655. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  656. */
  657. ambientColor: Color3;
  658. /** @hidden */
  659. _environmentBRDFTexture: BaseTexture;
  660. /** @hidden */
  661. protected _environmentTexture: BaseTexture;
  662. /**
  663. * Texture used in all pbr material as the reflection texture.
  664. * As in the majority of the scene they are the same (exception for multi room and so on),
  665. * this is easier to reference from here than from all the materials.
  666. */
  667. /**
  668. * Texture used in all pbr material as the reflection texture.
  669. * As in the majority of the scene they are the same (exception for multi room and so on),
  670. * this is easier to set here than in all the materials.
  671. */
  672. environmentTexture: BaseTexture;
  673. /** @hidden */
  674. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  675. /**
  676. * Default image processing configuration used either in the rendering
  677. * Forward main pass or through the imageProcessingPostProcess if present.
  678. * As in the majority of the scene they are the same (exception for multi camera),
  679. * this is easier to reference from here than from all the materials and post process.
  680. *
  681. * No setter as we it is a shared configuration, you can set the values instead.
  682. */
  683. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  684. private _forceWireframe;
  685. /**
  686. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  687. */
  688. forceWireframe: boolean;
  689. private _forcePointsCloud;
  690. /**
  691. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  692. */
  693. forcePointsCloud: boolean;
  694. /**
  695. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  696. */
  697. forceShowBoundingBoxes: boolean;
  698. /**
  699. * Gets or sets the active clipplane
  700. */
  701. clipPlane: Nullable<Plane>;
  702. /**
  703. * Gets or sets a boolean indicating if animations are enabled
  704. */
  705. animationsEnabled: boolean;
  706. private _animationPropertiesOverride;
  707. /**
  708. * Gets or sets the animation properties override
  709. */
  710. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  711. /**
  712. * Gets or sets a boolean indicating if a constant deltatime has to be used
  713. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  714. */
  715. useConstantAnimationDeltaTime: boolean;
  716. /**
  717. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  718. * Please note that it requires to run a ray cast through the scene on every frame
  719. */
  720. constantlyUpdateMeshUnderPointer: boolean;
  721. /**
  722. * Defines the HTML cursor to use when hovering over interactive elements
  723. */
  724. hoverCursor: string;
  725. /**
  726. * Defines the HTML default cursor to use (empty by default)
  727. */
  728. defaultCursor: string;
  729. /**
  730. * This is used to call preventDefault() on pointer down
  731. * in order to block unwanted artifacts like system double clicks
  732. */
  733. preventDefaultOnPointerDown: boolean;
  734. /**
  735. * Gets or sets user defined metadata
  736. */
  737. metadata: any;
  738. /**
  739. * Gets the name of the plugin used to load this scene (null by default)
  740. */
  741. loadingPluginName: string;
  742. /**
  743. * Use this array to add regular expressions used to disable offline support for specific urls
  744. */
  745. disableOfflineSupportExceptionRules: RegExp[];
  746. private _spritePredicate;
  747. /**
  748. * An event triggered when the scene is disposed.
  749. */
  750. onDisposeObservable: Observable<Scene>;
  751. private _onDisposeObserver;
  752. /** Sets a function to be executed when this scene is disposed. */
  753. onDispose: () => void;
  754. /**
  755. * An event triggered before rendering the scene (right after animations and physics)
  756. */
  757. onBeforeRenderObservable: Observable<Scene>;
  758. private _onBeforeRenderObserver;
  759. /** Sets a function to be executed before rendering this scene */
  760. beforeRender: Nullable<() => void>;
  761. /**
  762. * An event triggered after rendering the scene
  763. */
  764. onAfterRenderObservable: Observable<Scene>;
  765. private _onAfterRenderObserver;
  766. /** Sets a function to be executed after rendering this scene */
  767. afterRender: Nullable<() => void>;
  768. /**
  769. * An event triggered before animating the scene
  770. */
  771. onBeforeAnimationsObservable: Observable<Scene>;
  772. /**
  773. * An event triggered after animations processing
  774. */
  775. onAfterAnimationsObservable: Observable<Scene>;
  776. /**
  777. * An event triggered before draw calls are ready to be sent
  778. */
  779. onBeforeDrawPhaseObservable: Observable<Scene>;
  780. /**
  781. * An event triggered after draw calls have been sent
  782. */
  783. onAfterDrawPhaseObservable: Observable<Scene>;
  784. /**
  785. * An event triggered when physic simulation is about to be run
  786. */
  787. onBeforePhysicsObservable: Observable<Scene>;
  788. /**
  789. * An event triggered when physic simulation has been done
  790. */
  791. onAfterPhysicsObservable: Observable<Scene>;
  792. /**
  793. * An event triggered when the scene is ready
  794. */
  795. onReadyObservable: Observable<Scene>;
  796. /**
  797. * An event triggered before rendering a camera
  798. */
  799. onBeforeCameraRenderObservable: Observable<Camera>;
  800. private _onBeforeCameraRenderObserver;
  801. /** Sets a function to be executed before rendering a camera*/
  802. beforeCameraRender: () => void;
  803. /**
  804. * An event triggered after rendering a camera
  805. */
  806. onAfterCameraRenderObservable: Observable<Camera>;
  807. private _onAfterCameraRenderObserver;
  808. /** Sets a function to be executed after rendering a camera*/
  809. afterCameraRender: () => void;
  810. /**
  811. * An event triggered when active meshes evaluation is about to start
  812. */
  813. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when active meshes evaluation is done
  816. */
  817. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when particles rendering is about to start
  820. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  821. */
  822. onBeforeParticlesRenderingObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when particles rendering is done
  825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  826. */
  827. onAfterParticlesRenderingObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when sprites rendering is about to start
  830. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  831. */
  832. onBeforeSpritesRenderingObservable: Observable<Scene>;
  833. /**
  834. * An event triggered when sprites rendering is done
  835. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  836. */
  837. onAfterSpritesRenderingObservable: Observable<Scene>;
  838. /**
  839. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  840. */
  841. onDataLoadedObservable: Observable<Scene>;
  842. /**
  843. * An event triggered when a camera is created
  844. */
  845. onNewCameraAddedObservable: Observable<Camera>;
  846. /**
  847. * An event triggered when a camera is removed
  848. */
  849. onCameraRemovedObservable: Observable<Camera>;
  850. /**
  851. * An event triggered when a light is created
  852. */
  853. onNewLightAddedObservable: Observable<Light>;
  854. /**
  855. * An event triggered when a light is removed
  856. */
  857. onLightRemovedObservable: Observable<Light>;
  858. /**
  859. * An event triggered when a geometry is created
  860. */
  861. onNewGeometryAddedObservable: Observable<Geometry>;
  862. /**
  863. * An event triggered when a geometry is removed
  864. */
  865. onGeometryRemovedObservable: Observable<Geometry>;
  866. /**
  867. * An event triggered when a transform node is created
  868. */
  869. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  870. /**
  871. * An event triggered when a transform node is removed
  872. */
  873. onTransformNodeRemovedObservable: Observable<TransformNode>;
  874. /**
  875. * An event triggered when a mesh is created
  876. */
  877. onNewMeshAddedObservable: Observable<AbstractMesh>;
  878. /**
  879. * An event triggered when a mesh is removed
  880. */
  881. onMeshRemovedObservable: Observable<AbstractMesh>;
  882. /**
  883. * An event triggered when render targets are about to be rendered
  884. * Can happen multiple times per frame.
  885. */
  886. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  887. /**
  888. * An event triggered when render targets were rendered.
  889. * Can happen multiple times per frame.
  890. */
  891. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  892. /**
  893. * An event triggered before calculating deterministic simulation step
  894. */
  895. onBeforeStepObservable: Observable<Scene>;
  896. /**
  897. * An event triggered after calculating deterministic simulation step
  898. */
  899. onAfterStepObservable: Observable<Scene>;
  900. /**
  901. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  902. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  903. * 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)
  904. */
  905. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  906. private _registeredForLateAnimationBindings;
  907. /**
  908. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  909. */
  910. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  911. /**
  912. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  913. */
  914. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  915. /**
  916. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  917. */
  918. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  919. private _onPointerMove;
  920. private _onPointerDown;
  921. private _onPointerUp;
  922. /** Deprecated. Use onPointerObservable instead */
  923. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  924. /** Deprecated. Use onPointerObservable instead */
  925. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  926. /** Deprecated. Use onPointerObservable instead */
  927. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  928. /** Deprecated. Use onPointerObservable instead */
  929. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  930. private _gamepadManager;
  931. /**
  932. * Gets the gamepad manager associated with the scene
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  934. */
  935. readonly gamepadManager: GamepadManager;
  936. /**
  937. * 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).
  938. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  939. */
  940. onPrePointerObservable: Observable<PointerInfoPre>;
  941. /**
  942. * Observable event triggered each time an input event is received from the rendering canvas
  943. */
  944. onPointerObservable: Observable<PointerInfo>;
  945. /**
  946. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  947. */
  948. readonly unTranslatedPointer: Vector2;
  949. /** The distance in pixel that you have to move to prevent some events */
  950. static DragMovementThreshold: number;
  951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  952. static LongPressDelay: number;
  953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  954. static DoubleClickDelay: number;
  955. /** If you need to check double click without raising a single click at first click, enable this flag */
  956. static ExclusiveDoubleClickMode: boolean;
  957. private _initClickEvent;
  958. private _initActionManager;
  959. private _delayedSimpleClick;
  960. private _delayedSimpleClickTimeout;
  961. private _previousDelayedSimpleClickTimeout;
  962. private _meshPickProceed;
  963. private _previousButtonPressed;
  964. private _currentPickResult;
  965. private _previousPickResult;
  966. private _totalPointersPressed;
  967. private _doubleClickOccured;
  968. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  969. cameraToUseForPointers: Nullable<Camera>;
  970. private _pointerX;
  971. private _pointerY;
  972. private _unTranslatedPointerX;
  973. private _unTranslatedPointerY;
  974. private _startingPointerPosition;
  975. private _previousStartingPointerPosition;
  976. private _startingPointerTime;
  977. private _previousStartingPointerTime;
  978. private _pointerCaptures;
  979. private _timeAccumulator;
  980. private _currentStepId;
  981. private _currentInternalStep;
  982. /** @hidden */
  983. _mirroredCameraPosition: Nullable<Vector3>;
  984. /**
  985. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  986. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  987. */
  988. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  989. /**
  990. * Observable event triggered each time an keyboard event is received from the hosting window
  991. */
  992. onKeyboardObservable: Observable<KeyboardInfo>;
  993. private _onKeyDown;
  994. private _onKeyUp;
  995. private _onCanvasFocusObserver;
  996. private _onCanvasBlurObserver;
  997. private _useRightHandedSystem;
  998. /**
  999. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1000. */
  1001. useRightHandedSystem: boolean;
  1002. /**
  1003. * Sets the step Id used by deterministic lock step
  1004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1005. * @param newStepId defines the step Id
  1006. */
  1007. setStepId(newStepId: number): void;
  1008. /**
  1009. * Gets the step Id used by deterministic lock step
  1010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1011. * @returns the step Id
  1012. */
  1013. getStepId(): number;
  1014. /**
  1015. * Gets the internal step used by deterministic lock step
  1016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1017. * @returns the internal step
  1018. */
  1019. getInternalStep(): number;
  1020. private _fogEnabled;
  1021. /**
  1022. * Gets or sets a boolean indicating if fog is enabled on this scene
  1023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1024. */
  1025. fogEnabled: boolean;
  1026. private _fogMode;
  1027. /**
  1028. * Gets or sets the fog mode to use
  1029. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1030. */
  1031. fogMode: number;
  1032. /**
  1033. * Gets or sets the fog color to use
  1034. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1035. */
  1036. fogColor: Color3;
  1037. /**
  1038. * Gets or sets the fog density to use
  1039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1040. */
  1041. fogDensity: number;
  1042. /**
  1043. * Gets or sets the fog start distance to use
  1044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1045. */
  1046. fogStart: number;
  1047. /**
  1048. * Gets or sets the fog end distance to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogEnd: number;
  1052. private _shadowsEnabled;
  1053. /**
  1054. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1055. */
  1056. shadowsEnabled: boolean;
  1057. private _lightsEnabled;
  1058. /**
  1059. * Gets or sets a boolean indicating if lights are enabled on this scene
  1060. */
  1061. lightsEnabled: boolean;
  1062. /** All of the active cameras added to this scene. */
  1063. activeCameras: Camera[];
  1064. /** The current active camera */
  1065. activeCamera: Nullable<Camera>;
  1066. private _defaultMaterial;
  1067. /** The default material used on meshes when no material is affected */
  1068. /** The default material used on meshes when no material is affected */
  1069. defaultMaterial: Material;
  1070. private _texturesEnabled;
  1071. /**
  1072. * Gets or sets a boolean indicating if textures are enabled on this scene
  1073. */
  1074. texturesEnabled: boolean;
  1075. /**
  1076. * Gets or sets a boolean indicating if particles are enabled on this scene
  1077. */
  1078. particlesEnabled: boolean;
  1079. /**
  1080. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1081. */
  1082. spritesEnabled: boolean;
  1083. /**
  1084. * All of the sprite managers added to this scene
  1085. * @see http://doc.babylonjs.com/babylon101/sprites
  1086. */
  1087. spriteManagers: SpriteManager[];
  1088. private _skeletonsEnabled;
  1089. /**
  1090. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1091. */
  1092. skeletonsEnabled: boolean;
  1093. /**
  1094. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1095. */
  1096. lensFlaresEnabled: boolean;
  1097. /**
  1098. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1100. */
  1101. collisionsEnabled: boolean;
  1102. private _workerCollisions;
  1103. /** @hidden */
  1104. collisionCoordinator: ICollisionCoordinator;
  1105. /**
  1106. * Defines the gravity applied to this scene (used only for collisions)
  1107. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1108. */
  1109. gravity: Vector3;
  1110. /**
  1111. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1112. */
  1113. postProcessesEnabled: boolean;
  1114. /**
  1115. * The list of postprocesses added to the scene
  1116. */
  1117. postProcesses: PostProcess[];
  1118. /**
  1119. * Gets the current postprocess manager
  1120. */
  1121. postProcessManager: PostProcessManager;
  1122. private _postProcessRenderPipelineManager;
  1123. /**
  1124. * Gets the postprocess render pipeline manager
  1125. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1126. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1127. */
  1128. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1129. /**
  1130. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1131. */
  1132. renderTargetsEnabled: boolean;
  1133. /**
  1134. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1135. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1136. */
  1137. dumpNextRenderTargets: boolean;
  1138. /**
  1139. * The list of user defined render targets added to the scene
  1140. */
  1141. customRenderTargets: RenderTargetTexture[];
  1142. /**
  1143. * Defines if texture loading must be delayed
  1144. * If true, textures will only be loaded when they need to be rendered
  1145. */
  1146. useDelayedTextureLoading: boolean;
  1147. /**
  1148. * Gets the list of meshes imported to the scene through SceneLoader
  1149. */
  1150. importedMeshesFiles: String[];
  1151. /**
  1152. * Gets or sets a boolean indicating if probes are enabled on this scene
  1153. */
  1154. probesEnabled: boolean;
  1155. /**
  1156. * The list of reflection probes added to the scene
  1157. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1158. */
  1159. reflectionProbes: ReflectionProbe[];
  1160. /**
  1161. * @hidden
  1162. */
  1163. database: Database;
  1164. /**
  1165. * Gets or sets the action manager associated with the scene
  1166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1167. */
  1168. actionManager: ActionManager;
  1169. private _meshesForIntersections;
  1170. /**
  1171. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1172. */
  1173. proceduralTexturesEnabled: boolean;
  1174. /**
  1175. * The list of procedural textures added to the scene
  1176. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1177. */
  1178. proceduralTextures: ProceduralTexture[];
  1179. private _mainSoundTrack;
  1180. /**
  1181. * The list of sound tracks added to the scene
  1182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1183. */
  1184. soundTracks: SoundTrack[];
  1185. private _audioEnabled;
  1186. private _headphone;
  1187. /**
  1188. * Gets the main soundtrack associated with the scene
  1189. */
  1190. readonly mainSoundTrack: SoundTrack;
  1191. /**
  1192. * Gets or sets the VRExperienceHelper attached to the scene
  1193. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1194. * @ignorenaming
  1195. */
  1196. VRHelper: VRExperienceHelper;
  1197. /**
  1198. * Gets or sets the simplification queue attached to the scene
  1199. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1200. */
  1201. simplificationQueue: SimplificationQueue;
  1202. private _engine;
  1203. private _totalVertices;
  1204. /** @hidden */
  1205. _activeIndices: PerfCounter;
  1206. /** @hidden */
  1207. _activeParticles: PerfCounter;
  1208. /** @hidden */
  1209. _activeBones: PerfCounter;
  1210. private _animationRatio;
  1211. private _animationTimeLast;
  1212. private _animationTime;
  1213. /**
  1214. * Gets or sets a general scale for animation speed
  1215. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1216. */
  1217. animationTimeScale: number;
  1218. /** @hidden */
  1219. _cachedMaterial: Nullable<Material>;
  1220. /** @hidden */
  1221. _cachedEffect: Nullable<Effect>;
  1222. /** @hidden */
  1223. _cachedVisibility: Nullable<number>;
  1224. private _renderId;
  1225. private _executeWhenReadyTimeoutId;
  1226. private _intermediateRendering;
  1227. private _viewUpdateFlag;
  1228. private _projectionUpdateFlag;
  1229. private _alternateViewUpdateFlag;
  1230. private _alternateProjectionUpdateFlag;
  1231. /** @hidden */
  1232. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1233. private _activeRequests;
  1234. private _pendingData;
  1235. private _isDisposed;
  1236. /**
  1237. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1238. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1239. */
  1240. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1241. private _activeMeshes;
  1242. private _processedMaterials;
  1243. private _renderTargets;
  1244. /** @hidden */
  1245. _activeParticleSystems: SmartArray<IParticleSystem>;
  1246. private _activeSkeletons;
  1247. private _softwareSkinnedMeshes;
  1248. private _renderingManager;
  1249. private _physicsEngine;
  1250. /** @hidden */
  1251. _activeAnimatables: Animatable[];
  1252. private _transformMatrix;
  1253. private _sceneUbo;
  1254. private _alternateSceneUbo;
  1255. private _pickWithRayInverseMatrix;
  1256. private _boundingBoxRenderer;
  1257. private _outlineRenderer;
  1258. private _viewMatrix;
  1259. private _projectionMatrix;
  1260. private _alternateViewMatrix;
  1261. private _alternateProjectionMatrix;
  1262. private _alternateTransformMatrix;
  1263. private _useAlternateCameraConfiguration;
  1264. private _alternateRendering;
  1265. /** @hidden */
  1266. _forcedViewPosition: Nullable<Vector3>;
  1267. /** @hidden */
  1268. readonly _isAlternateRenderingEnabled: boolean;
  1269. private _frustumPlanes;
  1270. /**
  1271. * Gets the list of frustum planes (built from the active camera)
  1272. */
  1273. readonly frustumPlanes: Plane[];
  1274. /**
  1275. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1276. * This is useful if there are more lights that the maximum simulteanous authorized
  1277. */
  1278. requireLightSorting: boolean;
  1279. private _selectionOctree;
  1280. private _pointerOverMesh;
  1281. private _pointerOverSprite;
  1282. private _debugLayer;
  1283. private _depthRenderer;
  1284. private _geometryBufferRenderer;
  1285. /**
  1286. * Gets the current geometry buffer associated to the scene.
  1287. */
  1288. /**
  1289. * Sets the current geometry buffer for the scene.
  1290. */
  1291. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1292. private _pickedDownMesh;
  1293. private _pickedUpMesh;
  1294. private _pickedDownSprite;
  1295. private _externalData;
  1296. private _uid;
  1297. /**
  1298. * Backing store of defined scene components.
  1299. */
  1300. _components: ISceneComponent[];
  1301. /**
  1302. * List of components to register on the next registration step.
  1303. */
  1304. private _transientComponents;
  1305. /**
  1306. * Registers the transient components if needed.
  1307. */
  1308. private _registerTransientComponents();
  1309. /**
  1310. * Add a component to the scene.
  1311. * Note that the ccomponent could be registered on th next frame if this is called after
  1312. * the register component stage.
  1313. * @param component Defines the component to add to the scene
  1314. */
  1315. _addComponent(component: ISceneComponent): void;
  1316. /**
  1317. * Gets a component from the scene.
  1318. * @param name defines the name of the component to retrieve
  1319. * @returns the component or null if not present
  1320. */
  1321. _getComponent(name: string): Nullable<ISceneComponent>;
  1322. /**
  1323. * Defines the actions happening during the per mesh ready checks.
  1324. */
  1325. _isReadyForMeshStage: Stage<MeshStageAction>;
  1326. /**
  1327. * Defines the actions happening during the per camera render target step.
  1328. */
  1329. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1330. /**
  1331. * Defines the actions happening just before the active camera is drawing.
  1332. */
  1333. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1334. /**
  1335. * Defines the actions happening just before a rendering group is drawing.
  1336. */
  1337. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1338. /**
  1339. * Defines the actions happening just after a rendering group has been drawn.
  1340. */
  1341. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1342. /**
  1343. * Defines the actions happening just after the active camera has been drawn.
  1344. */
  1345. _afterCameraDrawStage: Stage<CameraStageAction>;
  1346. /**
  1347. * Creates a new Scene
  1348. * @param engine defines the engine to use to render this scene
  1349. */
  1350. constructor(engine: Engine);
  1351. /**
  1352. * Gets the debug layer (aka Inspector) associated with the scene
  1353. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1354. */
  1355. readonly debugLayer: DebugLayer;
  1356. /**
  1357. * Gets a boolean indicating if collisions are processed on a web worker
  1358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1359. */
  1360. workerCollisions: boolean;
  1361. /**
  1362. * Gets the octree used to boost mesh selection (picking)
  1363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1364. */
  1365. readonly selectionOctree: Octree<AbstractMesh>;
  1366. /**
  1367. * Gets the mesh that is currently under the pointer
  1368. */
  1369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1370. /**
  1371. * Gets the current on-screen X position of the pointer
  1372. */
  1373. readonly pointerX: number;
  1374. /**
  1375. * Gets the current on-screen Y position of the pointer
  1376. */
  1377. readonly pointerY: number;
  1378. /**
  1379. * Gets the cached material (ie. the latest rendered one)
  1380. * @returns the cached material
  1381. */
  1382. getCachedMaterial(): Nullable<Material>;
  1383. /**
  1384. * Gets the cached effect (ie. the latest rendered one)
  1385. * @returns the cached effect
  1386. */
  1387. getCachedEffect(): Nullable<Effect>;
  1388. /**
  1389. * Gets the cached visibility state (ie. the latest rendered one)
  1390. * @returns the cached visibility state
  1391. */
  1392. getCachedVisibility(): Nullable<number>;
  1393. /**
  1394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1395. * @param material defines the current material
  1396. * @param effect defines the current effect
  1397. * @param visibility defines the current visibility state
  1398. * @returns true if one parameter is not cached
  1399. */
  1400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1401. /**
  1402. * Gets the bounding box renderer associated with the scene
  1403. * @returns a BoundingBoxRenderer
  1404. */
  1405. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1406. /**
  1407. * Gets the outline renderer associated with the scene
  1408. * @returns a OutlineRenderer
  1409. */
  1410. getOutlineRenderer(): OutlineRenderer;
  1411. /**
  1412. * Gets the engine associated with the scene
  1413. * @returns an Engine
  1414. */
  1415. getEngine(): Engine;
  1416. /**
  1417. * Gets the total number of vertices rendered per frame
  1418. * @returns the total number of vertices rendered per frame
  1419. */
  1420. getTotalVertices(): number;
  1421. /**
  1422. * Gets the performance counter for total vertices
  1423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1424. */
  1425. readonly totalVerticesPerfCounter: PerfCounter;
  1426. /**
  1427. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1428. * @returns the total number of active indices rendered per frame
  1429. */
  1430. getActiveIndices(): number;
  1431. /**
  1432. * Gets the performance counter for active indices
  1433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1434. */
  1435. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1436. /**
  1437. * Gets the total number of active particles rendered per frame
  1438. * @returns the total number of active particles rendered per frame
  1439. */
  1440. getActiveParticles(): number;
  1441. /**
  1442. * Gets the performance counter for active particles
  1443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1444. */
  1445. readonly activeParticlesPerfCounter: PerfCounter;
  1446. /**
  1447. * Gets the total number of active bones rendered per frame
  1448. * @returns the total number of active bones rendered per frame
  1449. */
  1450. getActiveBones(): number;
  1451. /**
  1452. * Gets the performance counter for active bones
  1453. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1454. */
  1455. readonly activeBonesPerfCounter: PerfCounter;
  1456. /** @hidden */
  1457. getInterFramePerfCounter(): number;
  1458. /** @hidden */
  1459. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1460. /** @hidden */
  1461. getLastFrameDuration(): number;
  1462. /** @hidden */
  1463. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1464. /** @hidden */
  1465. getEvaluateActiveMeshesDuration(): number;
  1466. /** @hidden */
  1467. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1468. /**
  1469. * Gets the array of active meshes
  1470. * @returns an array of AbstractMesh
  1471. */
  1472. getActiveMeshes(): SmartArray<AbstractMesh>;
  1473. /** @hidden */
  1474. getRenderTargetsDuration(): number;
  1475. /** @hidden */
  1476. getRenderDuration(): number;
  1477. /** @hidden */
  1478. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1479. /** @hidden */
  1480. getParticlesDuration(): number;
  1481. /** @hidden */
  1482. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1483. /** @hidden */
  1484. getSpritesDuration(): number;
  1485. /** @hidden */
  1486. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1487. /**
  1488. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1489. * @returns a number
  1490. */
  1491. getAnimationRatio(): number;
  1492. /**
  1493. * Gets an unique Id for the current frame
  1494. * @returns a number
  1495. */
  1496. getRenderId(): number;
  1497. /** Call this function if you want to manually increment the render Id*/
  1498. incrementRenderId(): void;
  1499. private _updatePointerPosition(evt);
  1500. private _createUbo();
  1501. private _createAlternateUbo();
  1502. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1503. private _setRayOnPointerInfo(pointerInfo);
  1504. /**
  1505. * Use this method to simulate a pointer move on a mesh
  1506. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1507. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1508. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1509. * @returns the current scene
  1510. */
  1511. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1512. private _processPointerMove(pickResult, evt);
  1513. private _checkPrePointerObservable(pickResult, evt, type);
  1514. /**
  1515. * Use this method to simulate a pointer down on a mesh
  1516. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1517. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1518. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1519. * @returns the current scene
  1520. */
  1521. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1522. private _processPointerDown(pickResult, evt);
  1523. /**
  1524. * Use this method to simulate a pointer up on a mesh
  1525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1528. * @returns the current scene
  1529. */
  1530. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1531. private _processPointerUp(pickResult, evt, clickInfo);
  1532. /**
  1533. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1534. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1535. * @returns true if the pointer was captured
  1536. */
  1537. isPointerCaptured(pointerId?: number): boolean;
  1538. /**
  1539. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1540. * @param attachUp defines if you want to attach events to pointerup
  1541. * @param attachDown defines if you want to attach events to pointerdown
  1542. * @param attachMove defines if you want to attach events to pointermove
  1543. */
  1544. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1545. /** Detaches all event handlers*/
  1546. detachControl(): void;
  1547. /**
  1548. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1549. * Delay loaded resources are not taking in account
  1550. * @return true if all required resources are ready
  1551. */
  1552. isReady(): boolean;
  1553. /** Resets all cached information relative to material (including effect and visibility) */
  1554. resetCachedMaterial(): void;
  1555. /**
  1556. * Registers a function to be called before every frame render
  1557. * @param func defines the function to register
  1558. */
  1559. registerBeforeRender(func: () => void): void;
  1560. /**
  1561. * Unregisters a function called before every frame render
  1562. * @param func defines the function to unregister
  1563. */
  1564. unregisterBeforeRender(func: () => void): void;
  1565. /**
  1566. * Registers a function to be called after every frame render
  1567. * @param func defines the function to register
  1568. */
  1569. registerAfterRender(func: () => void): void;
  1570. /**
  1571. * Unregisters a function called after every frame render
  1572. * @param func defines the function to unregister
  1573. */
  1574. unregisterAfterRender(func: () => void): void;
  1575. private _executeOnceBeforeRender(func);
  1576. /**
  1577. * The provided function will run before render once and will be disposed afterwards.
  1578. * A timeout delay can be provided so that the function will be executed in N ms.
  1579. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1580. * @param func The function to be executed.
  1581. * @param timeout optional delay in ms
  1582. */
  1583. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1584. /** @hidden */
  1585. _addPendingData(data: any): void;
  1586. /** @hidden */
  1587. _removePendingData(data: any): void;
  1588. /**
  1589. * Returns the number of items waiting to be loaded
  1590. * @returns the number of items waiting to be loaded
  1591. */
  1592. getWaitingItemsCount(): number;
  1593. /**
  1594. * Returns a boolean indicating if the scene is still loading data
  1595. */
  1596. readonly isLoading: boolean;
  1597. /**
  1598. * Registers a function to be executed when the scene is ready
  1599. * @param {Function} func - the function to be executed
  1600. */
  1601. executeWhenReady(func: () => void): void;
  1602. /**
  1603. * Returns a promise that resolves when the scene is ready
  1604. * @returns A promise that resolves when the scene is ready
  1605. */
  1606. whenReadyAsync(): Promise<void>;
  1607. /** @hidden */
  1608. _checkIsReady(): void;
  1609. /**
  1610. * Will start the animation sequence of a given target
  1611. * @param target defines the target
  1612. * @param from defines from which frame should animation start
  1613. * @param to defines until which frame should animation run.
  1614. * @param weight defines the weight to apply to the animation (1.0 by default)
  1615. * @param loop defines if the animation loops
  1616. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1617. * @param onAnimationEnd defines the function to be executed when the animation ends
  1618. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1619. * @returns the animatable object created for this animation
  1620. */
  1621. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1622. /**
  1623. * Will start the animation sequence of a given target
  1624. * @param target defines the target
  1625. * @param from defines from which frame should animation start
  1626. * @param to defines until which frame should animation run.
  1627. * @param loop defines if the animation loops
  1628. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1629. * @param onAnimationEnd defines the function to be executed when the animation ends
  1630. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1631. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1632. * @returns the animatable object created for this animation
  1633. */
  1634. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1635. /**
  1636. * Begin a new animation on a given node
  1637. * @param target defines the target where the animation will take place
  1638. * @param animations defines the list of animations to start
  1639. * @param from defines the initial value
  1640. * @param to defines the final value
  1641. * @param loop defines if you want animation to loop (off by default)
  1642. * @param speedRatio defines the speed ratio to apply to all animations
  1643. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1644. * @returns the list of created animatables
  1645. */
  1646. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1647. /**
  1648. * Begin a new animation on a given node and its hierarchy
  1649. * @param target defines the root node where the animation will take place
  1650. * @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.
  1651. * @param animations defines the list of animations to start
  1652. * @param from defines the initial value
  1653. * @param to defines the final value
  1654. * @param loop defines if you want animation to loop (off by default)
  1655. * @param speedRatio defines the speed ratio to apply to all animations
  1656. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1657. * @returns the list of animatables created for all nodes
  1658. */
  1659. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1660. /**
  1661. * Gets the animatable associated with a specific target
  1662. * @param target defines the target of the animatable
  1663. * @returns the required animatable if found
  1664. */
  1665. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1666. /**
  1667. * Gets all animatables associated with a given target
  1668. * @param target defines the target to look animatables for
  1669. * @returns an array of Animatables
  1670. */
  1671. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1672. /**
  1673. * Gets all animatable attached to the scene
  1674. */
  1675. readonly animatables: Animatable[];
  1676. /**
  1677. * Will stop the animation of the given target
  1678. * @param target - the target
  1679. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1680. */
  1681. stopAnimation(target: any, animationName?: string): void;
  1682. /**
  1683. * Stops and removes all animations that have been applied to the scene
  1684. */
  1685. stopAllAnimations(): void;
  1686. private _animate();
  1687. /** @hidden */
  1688. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1689. private _processLateAnimationBindingsForMatrices(holder);
  1690. private _processLateAnimationBindingsForQuaternions(holder);
  1691. private _processLateAnimationBindings();
  1692. /** @hidden */
  1693. _switchToAlternateCameraConfiguration(active: boolean): void;
  1694. /**
  1695. * Gets the current view matrix
  1696. * @returns a Matrix
  1697. */
  1698. getViewMatrix(): Matrix;
  1699. /**
  1700. * Gets the current projection matrix
  1701. * @returns a Matrix
  1702. */
  1703. getProjectionMatrix(): Matrix;
  1704. /**
  1705. * Gets the current transform matrix
  1706. * @returns a Matrix made of View * Projection
  1707. */
  1708. getTransformMatrix(): Matrix;
  1709. /**
  1710. * Sets the current transform matrix
  1711. * @param view defines the View matrix to use
  1712. * @param projection defines the Projection matrix to use
  1713. */
  1714. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1715. /** @hidden */
  1716. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1717. /**
  1718. * Gets the uniform buffer used to store scene data
  1719. * @returns a UniformBuffer
  1720. */
  1721. getSceneUniformBuffer(): UniformBuffer;
  1722. /**
  1723. * Gets an unique (relatively to the current scene) Id
  1724. * @returns an unique number for the scene
  1725. */
  1726. getUniqueId(): number;
  1727. /**
  1728. * Add a mesh to the list of scene's meshes
  1729. * @param newMesh defines the mesh to add
  1730. * @param recursive if all child meshes should also be added to the scene
  1731. */
  1732. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1733. /**
  1734. * Remove a mesh for the list of scene's meshes
  1735. * @param toRemove defines the mesh to remove
  1736. * @param recursive if all child meshes should also be removed from the scene
  1737. * @returns the index where the mesh was in the mesh list
  1738. */
  1739. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1740. /**
  1741. * Add a transform node to the list of scene's transform nodes
  1742. * @param newTransformNode defines the transform node to add
  1743. */
  1744. addTransformNode(newTransformNode: TransformNode): void;
  1745. /**
  1746. * Remove a transform node for the list of scene's transform nodes
  1747. * @param toRemove defines the transform node to remove
  1748. * @returns the index where the transform node was in the transform node list
  1749. */
  1750. removeTransformNode(toRemove: TransformNode): number;
  1751. /**
  1752. * Remove a skeleton for the list of scene's skeletons
  1753. * @param toRemove defines the skeleton to remove
  1754. * @returns the index where the skeleton was in the skeleton list
  1755. */
  1756. removeSkeleton(toRemove: Skeleton): number;
  1757. /**
  1758. * Remove a morph target for the list of scene's morph targets
  1759. * @param toRemove defines the morph target to remove
  1760. * @returns the index where the morph target was in the morph target list
  1761. */
  1762. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1763. /**
  1764. * Remove a light for the list of scene's lights
  1765. * @param toRemove defines the light to remove
  1766. * @returns the index where the light was in the light list
  1767. */
  1768. removeLight(toRemove: Light): number;
  1769. /**
  1770. * Remove a camera for the list of scene's cameras
  1771. * @param toRemove defines the camera to remove
  1772. * @returns the index where the camera was in the camera list
  1773. */
  1774. removeCamera(toRemove: Camera): number;
  1775. /**
  1776. * Remove a particle system for the list of scene's particle systems
  1777. * @param toRemove defines the particle system to remove
  1778. * @returns the index where the particle system was in the particle system list
  1779. */
  1780. removeParticleSystem(toRemove: IParticleSystem): number;
  1781. /**
  1782. * Remove a animation for the list of scene's animations
  1783. * @param toRemove defines the animation to remove
  1784. * @returns the index where the animation was in the animation list
  1785. */
  1786. removeAnimation(toRemove: Animation): number;
  1787. /**
  1788. * Removes the given animation group from this scene.
  1789. * @param toRemove The animation group to remove
  1790. * @returns The index of the removed animation group
  1791. */
  1792. removeAnimationGroup(toRemove: AnimationGroup): number;
  1793. /**
  1794. * Removes the given multi-material from this scene.
  1795. * @param toRemove The multi-material to remove
  1796. * @returns The index of the removed multi-material
  1797. */
  1798. removeMultiMaterial(toRemove: MultiMaterial): number;
  1799. /**
  1800. * Removes the given material from this scene.
  1801. * @param toRemove The material to remove
  1802. * @returns The index of the removed material
  1803. */
  1804. removeMaterial(toRemove: Material): number;
  1805. /**
  1806. * Removes the given action manager from this scene.
  1807. * @param toRemove The action manager to remove
  1808. * @returns The index of the removed action manager
  1809. */
  1810. removeActionManager(toRemove: ActionManager): number;
  1811. /**
  1812. * Removes the given texture from this scene.
  1813. * @param toRemove The texture to remove
  1814. * @returns The index of the removed texture
  1815. */
  1816. removeTexture(toRemove: BaseTexture): number;
  1817. /**
  1818. * Adds the given light to this scene
  1819. * @param newLight The light to add
  1820. */
  1821. addLight(newLight: Light): void;
  1822. /**
  1823. * Sorts the list list based on light priorities
  1824. */
  1825. sortLightsByPriority(): void;
  1826. /**
  1827. * Adds the given camera to this scene
  1828. * @param newCamera The camera to add
  1829. */
  1830. addCamera(newCamera: Camera): void;
  1831. /**
  1832. * Adds the given skeleton to this scene
  1833. * @param newSkeleton The skeleton to add
  1834. */
  1835. addSkeleton(newSkeleton: Skeleton): void;
  1836. /**
  1837. * Adds the given particle system to this scene
  1838. * @param newParticleSystem The particle system to add
  1839. */
  1840. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1841. /**
  1842. * Adds the given animation to this scene
  1843. * @param newAnimation The animation to add
  1844. */
  1845. addAnimation(newAnimation: Animation): void;
  1846. /**
  1847. * Adds the given animation group to this scene.
  1848. * @param newAnimationGroup The animation group to add
  1849. */
  1850. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1851. /**
  1852. * Adds the given multi-material to this scene
  1853. * @param newMultiMaterial The multi-material to add
  1854. */
  1855. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1856. /**
  1857. * Adds the given material to this scene
  1858. * @param newMaterial The material to add
  1859. */
  1860. addMaterial(newMaterial: Material): void;
  1861. /**
  1862. * Adds the given morph target to this scene
  1863. * @param newMorphTargetManager The morph target to add
  1864. */
  1865. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1866. /**
  1867. * Adds the given geometry to this scene
  1868. * @param newGeometry The geometry to add
  1869. */
  1870. addGeometry(newGeometry: Geometry): void;
  1871. /**
  1872. * Adds the given action manager to this scene
  1873. * @param newActionManager The action manager to add
  1874. */
  1875. addActionManager(newActionManager: ActionManager): void;
  1876. /**
  1877. * Adds the given texture to this scene.
  1878. * @param newTexture The texture to add
  1879. */
  1880. addTexture(newTexture: BaseTexture): void;
  1881. /**
  1882. * Switch active camera
  1883. * @param newCamera defines the new active camera
  1884. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1885. */
  1886. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1887. /**
  1888. * sets the active camera of the scene using its ID
  1889. * @param id defines the camera's ID
  1890. * @return the new active camera or null if none found.
  1891. */
  1892. setActiveCameraByID(id: string): Nullable<Camera>;
  1893. /**
  1894. * sets the active camera of the scene using its name
  1895. * @param name defines the camera's name
  1896. * @returns the new active camera or null if none found.
  1897. */
  1898. setActiveCameraByName(name: string): Nullable<Camera>;
  1899. /**
  1900. * get an animation group using its name
  1901. * @param name defines the material's name
  1902. * @return the animation group or null if none found.
  1903. */
  1904. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1905. /**
  1906. * get a material using its id
  1907. * @param id defines the material's ID
  1908. * @return the material or null if none found.
  1909. */
  1910. getMaterialByID(id: string): Nullable<Material>;
  1911. /**
  1912. * Gets a material using its name
  1913. * @param name defines the material's name
  1914. * @return the material or null if none found.
  1915. */
  1916. getMaterialByName(name: string): Nullable<Material>;
  1917. /**
  1918. * Gets a camera using its id
  1919. * @param id defines the id to look for
  1920. * @returns the camera or null if not found
  1921. */
  1922. getCameraByID(id: string): Nullable<Camera>;
  1923. /**
  1924. * Gets a camera using its unique id
  1925. * @param uniqueId defines the unique id to look for
  1926. * @returns the camera or null if not found
  1927. */
  1928. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1929. /**
  1930. * Gets a camera using its name
  1931. * @param name defines the camera's name
  1932. * @return the camera or null if none found.
  1933. */
  1934. getCameraByName(name: string): Nullable<Camera>;
  1935. /**
  1936. * Gets a bone using its id
  1937. * @param id defines the bone's id
  1938. * @return the bone or null if not found
  1939. */
  1940. getBoneByID(id: string): Nullable<Bone>;
  1941. /**
  1942. * Gets a bone using its id
  1943. * @param name defines the bone's name
  1944. * @return the bone or null if not found
  1945. */
  1946. getBoneByName(name: string): Nullable<Bone>;
  1947. /**
  1948. * Gets a light node using its name
  1949. * @param name defines the the light's name
  1950. * @return the light or null if none found.
  1951. */
  1952. getLightByName(name: string): Nullable<Light>;
  1953. /**
  1954. * Gets a light node using its id
  1955. * @param id defines the light's id
  1956. * @return the light or null if none found.
  1957. */
  1958. getLightByID(id: string): Nullable<Light>;
  1959. /**
  1960. * Gets a light node using its scene-generated unique ID
  1961. * @param uniqueId defines the light's unique id
  1962. * @return the light or null if none found.
  1963. */
  1964. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1965. /**
  1966. * Gets a particle system by id
  1967. * @param id defines the particle system id
  1968. * @return the corresponding system or null if none found
  1969. */
  1970. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1971. /**
  1972. * Gets a geometry using its ID
  1973. * @param id defines the geometry's id
  1974. * @return the geometry or null if none found.
  1975. */
  1976. getGeometryByID(id: string): Nullable<Geometry>;
  1977. /**
  1978. * Add a new geometry to this scene
  1979. * @param geometry defines the geometry to be added to the scene.
  1980. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  1981. * @return a boolean defining if the geometry was added or not
  1982. */
  1983. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1984. /**
  1985. * Removes an existing geometry
  1986. * @param geometry defines the geometry to be removed from the scene
  1987. * @return a boolean defining if the geometry was removed or not
  1988. */
  1989. removeGeometry(geometry: Geometry): boolean;
  1990. /**
  1991. * Gets the list of geometries attached to the scene
  1992. * @returns an array of Geometry
  1993. */
  1994. getGeometries(): Geometry[];
  1995. /**
  1996. * Gets the first added mesh found of a given ID
  1997. * @param id defines the id to search for
  1998. * @return the mesh found or null if not found at all
  1999. */
  2000. getMeshByID(id: string): Nullable<AbstractMesh>;
  2001. /**
  2002. * Gets a list of meshes using their id
  2003. * @param id defines the id to search for
  2004. * @returns a list of meshes
  2005. */
  2006. getMeshesByID(id: string): Array<AbstractMesh>;
  2007. /**
  2008. * Gets the first added transform node found of a given ID
  2009. * @param id defines the id to search for
  2010. * @return the found transform node or null if not found at all.
  2011. */
  2012. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2013. /**
  2014. * Gets a list of transform nodes using their id
  2015. * @param id defines the id to search for
  2016. * @returns a list of transform nodes
  2017. */
  2018. getTransformNodesByID(id: string): Array<TransformNode>;
  2019. /**
  2020. * Gets a mesh with its auto-generated unique id
  2021. * @param uniqueId defines the unique id to search for
  2022. * @return the found mesh or null if not found at all.
  2023. */
  2024. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2025. /**
  2026. * Gets a the last added mesh using a given id
  2027. * @param id defines the id to search for
  2028. * @return the found mesh or null if not found at all.
  2029. */
  2030. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2031. /**
  2032. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2033. * @param id defines the id to search for
  2034. * @return the found node or null if not found at all
  2035. */
  2036. getLastEntryByID(id: string): Nullable<Node>;
  2037. /**
  2038. * Gets a node (Mesh, Camera, Light) using a given id
  2039. * @param id defines the id to search for
  2040. * @return the found node or null if not found at all
  2041. */
  2042. getNodeByID(id: string): Nullable<Node>;
  2043. /**
  2044. * Gets a node (Mesh, Camera, Light) using a given name
  2045. * @param name defines the name to search for
  2046. * @return the found node or null if not found at all.
  2047. */
  2048. getNodeByName(name: string): Nullable<Node>;
  2049. /**
  2050. * Gets a mesh using a given name
  2051. * @param name defines the name to search for
  2052. * @return the found mesh or null if not found at all.
  2053. */
  2054. getMeshByName(name: string): Nullable<AbstractMesh>;
  2055. /**
  2056. * Gets a transform node using a given name
  2057. * @param name defines the name to search for
  2058. * @return the found transform node or null if not found at all.
  2059. */
  2060. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2061. /**
  2062. * Gets a sound using a given name
  2063. * @param name defines the name to search for
  2064. * @return the found sound or null if not found at all.
  2065. */
  2066. getSoundByName(name: string): Nullable<Sound>;
  2067. /**
  2068. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2069. * @param id defines the id to search for
  2070. * @return the found skeleton or null if not found at all.
  2071. */
  2072. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2073. /**
  2074. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2075. * @param id defines the id to search for
  2076. * @return the found skeleton or null if not found at all.
  2077. */
  2078. getSkeletonById(id: string): Nullable<Skeleton>;
  2079. /**
  2080. * Gets a skeleton using a given name
  2081. * @param name defines the name to search for
  2082. * @return the found skeleton or null if not found at all.
  2083. */
  2084. getSkeletonByName(name: string): Nullable<Skeleton>;
  2085. /**
  2086. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2087. * @param id defines the id to search for
  2088. * @return the found morph target manager or null if not found at all.
  2089. */
  2090. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2091. /**
  2092. * Gets a boolean indicating if the given mesh is active
  2093. * @param mesh defines the mesh to look for
  2094. * @returns true if the mesh is in the active list
  2095. */
  2096. isActiveMesh(mesh: AbstractMesh): boolean;
  2097. /**
  2098. * Return a unique id as a string which can serve as an identifier for the scene
  2099. */
  2100. readonly uid: string;
  2101. /**
  2102. * Add an externaly attached data from its key.
  2103. * This method call will fail and return false, if such key already exists.
  2104. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2105. * @param key the unique key that identifies the data
  2106. * @param data the data object to associate to the key for this Engine instance
  2107. * @return true if no such key were already present and the data was added successfully, false otherwise
  2108. */
  2109. addExternalData<T>(key: string, data: T): boolean;
  2110. /**
  2111. * Get an externaly attached data from its key
  2112. * @param key the unique key that identifies the data
  2113. * @return the associated data, if present (can be null), or undefined if not present
  2114. */
  2115. getExternalData<T>(key: string): Nullable<T>;
  2116. /**
  2117. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2118. * @param key the unique key that identifies the data
  2119. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2120. * @return the associated data, can be null if the factory returned null.
  2121. */
  2122. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2123. /**
  2124. * Remove an externaly attached data from the Engine instance
  2125. * @param key the unique key that identifies the data
  2126. * @return true if the data was successfully removed, false if it doesn't exist
  2127. */
  2128. removeExternalData(key: string): boolean;
  2129. private _evaluateSubMesh(subMesh, mesh);
  2130. /**
  2131. * Clear the processed materials smart array preventing retention point in material dispose.
  2132. */
  2133. freeProcessedMaterials(): void;
  2134. /**
  2135. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2136. */
  2137. freeActiveMeshes(): void;
  2138. /**
  2139. * Clear the info related to rendering groups preventing retention points during dispose.
  2140. */
  2141. freeRenderingGroups(): void;
  2142. /** @hidden */
  2143. _isInIntermediateRendering(): boolean;
  2144. private _activeMeshCandidateProvider;
  2145. /**
  2146. * Defines the current active mesh candidate provider
  2147. * @param provider defines the provider to use
  2148. */
  2149. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2150. /**
  2151. * Gets the current active mesh candidate provider
  2152. * @returns the current active mesh candidate provider
  2153. */
  2154. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2155. private _activeMeshesFrozen;
  2156. /**
  2157. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2158. * @returns the current scene
  2159. */
  2160. freezeActiveMeshes(): Scene;
  2161. /**
  2162. * Use this function to restart evaluating active meshes on every frame
  2163. * @returns the current scene
  2164. */
  2165. unfreezeActiveMeshes(): Scene;
  2166. private _evaluateActiveMeshes();
  2167. private _activeMesh(sourceMesh, mesh);
  2168. /**
  2169. * Update the transform matrix to update from the current active camera
  2170. * @param force defines a boolean used to force the update even if cache is up to date
  2171. */
  2172. updateTransformMatrix(force?: boolean): void;
  2173. /**
  2174. * 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)
  2175. * @param alternateCamera defines the camera to use
  2176. */
  2177. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2178. private _renderForCamera(camera, rigParent?);
  2179. private _processSubCameras(camera);
  2180. private _checkIntersections();
  2181. /**
  2182. * Render the scene
  2183. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2184. */
  2185. render(updateCameras?: boolean): void;
  2186. private _updateAudioParameters();
  2187. /**
  2188. * Gets or sets if audio support is enabled
  2189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2190. */
  2191. audioEnabled: boolean;
  2192. private _disableAudio();
  2193. private _enableAudio();
  2194. /**
  2195. * Gets or sets if audio will be output to headphones
  2196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2197. */
  2198. headphone: boolean;
  2199. private _switchAudioModeForHeadphones();
  2200. private _switchAudioModeForNormalSpeakers();
  2201. /**
  2202. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2203. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2204. * @returns the created depth renderer
  2205. */
  2206. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2207. /**
  2208. * Disables a depth renderer for a given camera
  2209. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2210. */
  2211. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2212. /**
  2213. * Enables a GeometryBufferRender and associates it with the scene
  2214. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2215. * @returns the GeometryBufferRenderer
  2216. */
  2217. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2218. /**
  2219. * Disables the GeometryBufferRender associated with the scene
  2220. */
  2221. disableGeometryBufferRenderer(): void;
  2222. /**
  2223. * Freeze all materials
  2224. * A frozen material will not be updatable but should be faster to render
  2225. */
  2226. freezeMaterials(): void;
  2227. /**
  2228. * Unfreeze all materials
  2229. * A frozen material will not be updatable but should be faster to render
  2230. */
  2231. unfreezeMaterials(): void;
  2232. /**
  2233. * Releases all held ressources
  2234. */
  2235. dispose(): void;
  2236. /**
  2237. * Gets if the scene is already disposed
  2238. */
  2239. readonly isDisposed: boolean;
  2240. /**
  2241. * Releases sounds & soundtracks
  2242. */
  2243. disposeSounds(): void;
  2244. /**
  2245. * Call this function to reduce memory footprint of the scene.
  2246. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2247. */
  2248. clearCachedVertexData(): void;
  2249. /**
  2250. * This function will remove the local cached buffer data from texture.
  2251. * It will save memory but will prevent the texture from being rebuilt
  2252. */
  2253. cleanCachedTextureBuffer(): void;
  2254. /**
  2255. * Get the world extend vectors with an optional filter
  2256. *
  2257. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2258. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2259. */
  2260. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2261. min: Vector3;
  2262. max: Vector3;
  2263. };
  2264. /**
  2265. * Creates or updates the octree used to boost selection (picking)
  2266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2267. * @param maxCapacity defines the maximum capacity per leaf
  2268. * @param maxDepth defines the maximum depth of the octree
  2269. * @returns an octree of AbstractMesh
  2270. */
  2271. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2272. /**
  2273. * Creates a ray that can be used to pick in the scene
  2274. * @param x defines the x coordinate of the origin (on-screen)
  2275. * @param y defines the y coordinate of the origin (on-screen)
  2276. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2277. * @param camera defines the camera to use for the picking
  2278. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2279. * @returns a Ray
  2280. */
  2281. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2282. /**
  2283. * Creates a ray that can be used to pick in the scene
  2284. * @param x defines the x coordinate of the origin (on-screen)
  2285. * @param y defines the y coordinate of the origin (on-screen)
  2286. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2287. * @param result defines the ray where to store the picking ray
  2288. * @param camera defines the camera to use for the picking
  2289. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2290. * @returns the current scene
  2291. */
  2292. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2293. /**
  2294. * Creates a ray that can be used to pick in the scene
  2295. * @param x defines the x coordinate of the origin (on-screen)
  2296. * @param y defines the y coordinate of the origin (on-screen)
  2297. * @param camera defines the camera to use for the picking
  2298. * @returns a Ray
  2299. */
  2300. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2301. /**
  2302. * Creates a ray that can be used to pick in the scene
  2303. * @param x defines the x coordinate of the origin (on-screen)
  2304. * @param y defines the y coordinate of the origin (on-screen)
  2305. * @param result defines the ray where to store the picking ray
  2306. * @param camera defines the camera to use for the picking
  2307. * @returns the current scene
  2308. */
  2309. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2310. private _internalPick(rayFunction, predicate?, fastCheck?);
  2311. private _internalMultiPick(rayFunction, predicate?);
  2312. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2313. private _tempPickingRay;
  2314. /** Launch a ray to try to pick a mesh in the scene
  2315. * @param x position on screen
  2316. * @param y position on screen
  2317. * @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
  2318. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2319. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2320. * @returns a PickingInfo
  2321. */
  2322. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2323. /** Launch a ray to try to pick a sprite in the scene
  2324. * @param x position on screen
  2325. * @param y position on screen
  2326. * @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
  2327. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2328. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2329. * @returns a PickingInfo
  2330. */
  2331. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2332. private _cachedRayForTransform;
  2333. /** Use the given ray to pick a mesh in the scene
  2334. * @param ray The ray to use to pick meshes
  2335. * @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
  2336. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2337. * @returns a PickingInfo
  2338. */
  2339. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2340. /**
  2341. * Launch a ray to try to pick a mesh in the scene
  2342. * @param x X position on screen
  2343. * @param y Y position on screen
  2344. * @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
  2345. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2346. * @returns an array of PickingInfo
  2347. */
  2348. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2349. /**
  2350. * Launch a ray to try to pick a mesh in the scene
  2351. * @param ray Ray to use
  2352. * @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
  2353. * @returns an array of PickingInfo
  2354. */
  2355. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2356. /**
  2357. * Force the value of meshUnderPointer
  2358. * @param mesh defines the mesh to use
  2359. */
  2360. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2361. /**
  2362. * Gets the mesh under the pointer
  2363. * @returns a Mesh or null if no mesh is under the pointer
  2364. */
  2365. getPointerOverMesh(): Nullable<AbstractMesh>;
  2366. /**
  2367. * Force the sprite under the pointer
  2368. * @param sprite defines the sprite to use
  2369. */
  2370. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2371. /**
  2372. * Gets the sprite under the pointer
  2373. * @returns a Sprite or null if no sprite is under the pointer
  2374. */
  2375. getPointerOverSprite(): Nullable<Sprite>;
  2376. /**
  2377. * Gets the current physics engine
  2378. * @returns a PhysicsEngine or null if none attached
  2379. */
  2380. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2381. /**
  2382. * Enables physics to the current scene
  2383. * @param gravity defines the scene's gravity for the physics engine
  2384. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2385. * @return a boolean indicating if the physics engine was initialized
  2386. */
  2387. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2388. /**
  2389. * Disables and disposes the physics engine associated with the scene
  2390. */
  2391. disablePhysicsEngine(): void;
  2392. /**
  2393. * Gets a boolean indicating if there is an active physics engine
  2394. * @returns a boolean indicating if there is an active physics engine
  2395. */
  2396. isPhysicsEnabled(): boolean;
  2397. /**
  2398. * Deletes a physics compound impostor
  2399. * @param compound defines the compound to delete
  2400. */
  2401. deleteCompoundImpostor(compound: any): void;
  2402. /** @hidden */
  2403. _rebuildGeometries(): void;
  2404. /** @hidden */
  2405. _rebuildTextures(): void;
  2406. /**
  2407. * Creates a default light for the scene.
  2408. * @param replace Whether to replace the existing lights in the scene.
  2409. */
  2410. createDefaultLight(replace?: boolean): void;
  2411. /**
  2412. * Creates a default camera for the scene.
  2413. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2414. * @param replace Whether to replace the existing active camera in the scene.
  2415. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2416. */
  2417. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2418. /**
  2419. * Creates a default camera and a default light
  2420. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2421. * @param replace defines if the camera and/or light will replace the existing ones
  2422. * @param attachCameraControls defines if attachControl will be called on the new camera
  2423. */
  2424. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2425. /**
  2426. * Creates a new sky box
  2427. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2428. * @param environmentTexture defines the texture to use as environment texture
  2429. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2430. * @param scale defines the overall scale of the skybox
  2431. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2432. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2433. * @returns a new mesh holding the sky box
  2434. */
  2435. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2436. /**
  2437. * Creates a new environment
  2438. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2439. * @param options defines the options you can use to configure the environment
  2440. * @returns the new EnvironmentHelper
  2441. */
  2442. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2443. /**
  2444. * Creates a new VREXperienceHelper
  2445. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2446. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2447. * @returns a new VREXperienceHelper
  2448. */
  2449. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2450. private _getByTags(list, tagsQuery, forEach?);
  2451. /**
  2452. * Get a list of meshes by tags
  2453. * @param tagsQuery defines the tags query to use
  2454. * @param forEach defines a predicate used to filter results
  2455. * @returns an array of Mesh
  2456. */
  2457. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2458. /**
  2459. * Get a list of cameras by tags
  2460. * @param tagsQuery defines the tags query to use
  2461. * @param forEach defines a predicate used to filter results
  2462. * @returns an array of Camera
  2463. */
  2464. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2465. /**
  2466. * Get a list of lights by tags
  2467. * @param tagsQuery defines the tags query to use
  2468. * @param forEach defines a predicate used to filter results
  2469. * @returns an array of Light
  2470. */
  2471. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2472. /**
  2473. * Get a list of materials by tags
  2474. * @param tagsQuery defines the tags query to use
  2475. * @param forEach defines a predicate used to filter results
  2476. * @returns an array of Material
  2477. */
  2478. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2479. /**
  2480. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2481. * This allowed control for front to back rendering or reversly depending of the special needs.
  2482. *
  2483. * @param renderingGroupId The rendering group id corresponding to its index
  2484. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2485. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2486. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2487. */
  2488. 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;
  2489. /**
  2490. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2491. *
  2492. * @param renderingGroupId The rendering group id corresponding to its index
  2493. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2494. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2495. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2496. */
  2497. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2498. /**
  2499. * Will flag all materials as dirty to trigger new shader compilation
  2500. * @param flag defines the flag used to specify which material part must be marked as dirty
  2501. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2502. */
  2503. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2504. /** @hidden */
  2505. _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;
  2506. /** @hidden */
  2507. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Groups all the scene component constants in one place to ease maintenance.
  2513. * @hidden
  2514. */
  2515. class SceneComponentConstants {
  2516. static readonly NAME_EFFECTLAYER: string;
  2517. static readonly NAME_LAYER: string;
  2518. static readonly NAME_LENSFLARESYSTEM: string;
  2519. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2520. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2521. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2522. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2523. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2524. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2525. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2526. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2527. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2528. }
  2529. /**
  2530. * This represents a scene component.
  2531. *
  2532. * This is used to decouple the dependency the scene is having on the different workloads like
  2533. * layers, post processes...
  2534. */
  2535. interface ISceneComponent {
  2536. /**
  2537. * The name of the component. Each component must have a unique name.
  2538. */
  2539. name: string;
  2540. /**
  2541. * The scene the component belongs to.
  2542. */
  2543. scene: Scene;
  2544. /**
  2545. * Register the component to one instance of a scene.
  2546. */
  2547. register(): void;
  2548. /**
  2549. * Adds all the element from the container to the scene
  2550. * @param container the container holding the elements
  2551. */
  2552. addFromContainer(container: AbstractScene): void;
  2553. /**
  2554. * Removes all the elements in the container from the scene
  2555. * @param container contains the elements to remove
  2556. */
  2557. removeFromContainer(container: AbstractScene): void;
  2558. /**
  2559. * Rebuilds the elements related to this component in case of
  2560. * context lost for instance.
  2561. */
  2562. rebuild(): void;
  2563. /**
  2564. * Serializes the component data to the specified json object
  2565. * @param serializationObject The object to serialize to
  2566. */
  2567. serialize(serializationObject: any): void;
  2568. /**
  2569. * Disposes the component and the associated ressources.
  2570. */
  2571. dispose(): void;
  2572. }
  2573. /**
  2574. * Strong typing of a Mesh related stage step action
  2575. */
  2576. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2577. /**
  2578. * Strong typing of a Camera related stage step action
  2579. */
  2580. type CameraStageAction = (camera: Camera) => void;
  2581. /**
  2582. * Strong typing of a RenderingGroup related stage step action
  2583. */
  2584. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2585. /**
  2586. * Strong typing of a simple stage step action
  2587. */
  2588. type SimpleStageAction = () => void;
  2589. /**
  2590. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2591. * @hidden
  2592. */
  2593. class Stage<T extends Function> extends Array<{
  2594. index: number;
  2595. component: ISceneComponent;
  2596. action: T;
  2597. }> {
  2598. /**
  2599. * Hide ctor from the rest of the world.
  2600. * @param items The items to add.
  2601. */
  2602. private constructor();
  2603. /**
  2604. * Creates a new Stage.
  2605. * @returns A new instance of a Stage
  2606. */
  2607. static Create<T extends Function>(): Stage<T>;
  2608. /**
  2609. * Registers a step in an ordered way in the targeted stage.
  2610. * @param index Defines the position to register the step in
  2611. * @param component Defines the component attached to the step
  2612. * @param action Defines the action to launch during the step
  2613. */
  2614. registerStep(index: number, component: ISceneComponent, action: T): void;
  2615. /**
  2616. * Clears all the steps from the stage.
  2617. */
  2618. clear(): void;
  2619. }
  2620. }
  2621. declare module BABYLON {
  2622. type Nullable<T> = T | null;
  2623. type float = number;
  2624. type double = number;
  2625. type int = number;
  2626. type FloatArray = number[] | Float32Array;
  2627. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2628. /**
  2629. * Alias for types that can be used by a Buffer or VertexBuffer.
  2630. */
  2631. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2632. }
  2633. declare module BABYLON {
  2634. /**
  2635. * The action to be carried out following a trigger
  2636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2637. */
  2638. class Action {
  2639. /** the trigger, with or without parameters, for the action */
  2640. triggerOptions: any;
  2641. /**
  2642. * Trigger for the action
  2643. */
  2644. trigger: number;
  2645. /**
  2646. * Internal only - manager for action
  2647. * @hidden
  2648. */
  2649. _actionManager: ActionManager;
  2650. private _nextActiveAction;
  2651. private _child;
  2652. private _condition?;
  2653. private _triggerParameter;
  2654. /**
  2655. * An event triggered prior to action being executed.
  2656. */
  2657. onBeforeExecuteObservable: Observable<Action>;
  2658. /**
  2659. * Creates a new Action
  2660. * @param triggerOptions the trigger, with or without parameters, for the action
  2661. * @param condition an optional determinant of action
  2662. */
  2663. constructor(
  2664. /** the trigger, with or without parameters, for the action */
  2665. triggerOptions: any, condition?: Condition);
  2666. /**
  2667. * Internal only
  2668. * @hidden
  2669. */
  2670. _prepare(): void;
  2671. /**
  2672. * Gets the trigger parameters
  2673. * @returns the trigger parameters
  2674. */
  2675. getTriggerParameter(): any;
  2676. /**
  2677. * Internal only - executes current action event
  2678. * @hidden
  2679. */
  2680. _executeCurrent(evt?: ActionEvent): void;
  2681. /**
  2682. * Execute placeholder for child classes
  2683. * @param evt optional action event
  2684. */
  2685. execute(evt?: ActionEvent): void;
  2686. /**
  2687. * Skips to next active action
  2688. */
  2689. skipToNextActiveAction(): void;
  2690. /**
  2691. * Adds action to chain of actions, may be a DoNothingAction
  2692. * @param action defines the next action to execute
  2693. * @returns The action passed in
  2694. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2695. */
  2696. then(action: Action): Action;
  2697. /**
  2698. * Internal only
  2699. * @hidden
  2700. */
  2701. _getProperty(propertyPath: string): string;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getEffectiveTarget(target: any, propertyPath: string): any;
  2707. /**
  2708. * Serialize placeholder for child classes
  2709. * @param parent of child
  2710. * @returns the serialized object
  2711. */
  2712. serialize(parent: any): any;
  2713. /**
  2714. * Internal only called by serialize
  2715. * @hidden
  2716. */
  2717. protected _serialize(serializedAction: any, parent?: any): any;
  2718. /**
  2719. * Internal only
  2720. * @hidden
  2721. */
  2722. static _SerializeValueAsString: (value: any) => string;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _GetTargetProperty: (target: Scene | Node) => {
  2728. name: string;
  2729. targetType: string;
  2730. value: string;
  2731. };
  2732. }
  2733. }
  2734. declare module BABYLON {
  2735. /**
  2736. * ActionEvent is the event being sent when an action is triggered.
  2737. */
  2738. class ActionEvent {
  2739. /** The mesh or sprite that triggered the action */
  2740. source: any;
  2741. /** The X mouse cursor position at the time of the event */
  2742. pointerX: number;
  2743. /** The Y mouse cursor position at the time of the event */
  2744. pointerY: number;
  2745. /** The mesh that is currently pointed at (can be null) */
  2746. meshUnderPointer: Nullable<AbstractMesh>;
  2747. /** the original (browser) event that triggered the ActionEvent */
  2748. sourceEvent: any;
  2749. /** additional data for the event */
  2750. additionalData: any;
  2751. /**
  2752. * Creates a new ActionEvent
  2753. * @param source The mesh or sprite that triggered the action
  2754. * @param pointerX The X mouse cursor position at the time of the event
  2755. * @param pointerY The Y mouse cursor position at the time of the event
  2756. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2757. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2758. * @param additionalData additional data for the event
  2759. */
  2760. constructor(
  2761. /** The mesh or sprite that triggered the action */
  2762. source: any,
  2763. /** The X mouse cursor position at the time of the event */
  2764. pointerX: number,
  2765. /** The Y mouse cursor position at the time of the event */
  2766. pointerY: number,
  2767. /** The mesh that is currently pointed at (can be null) */
  2768. meshUnderPointer: Nullable<AbstractMesh>,
  2769. /** the original (browser) event that triggered the ActionEvent */
  2770. sourceEvent?: any,
  2771. /** additional data for the event */
  2772. additionalData?: any);
  2773. /**
  2774. * Helper function to auto-create an ActionEvent from a source mesh.
  2775. * @param source The source mesh that triggered the event
  2776. * @param evt The original (browser) event
  2777. * @param additionalData additional data for the event
  2778. * @returns the new ActionEvent
  2779. */
  2780. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2781. /**
  2782. * Helper function to auto-create an ActionEvent from a source sprite
  2783. * @param source The source sprite that triggered the event
  2784. * @param scene Scene associated with the sprite
  2785. * @param evt The original (browser) event
  2786. * @param additionalData additional data for the event
  2787. * @returns the new ActionEvent
  2788. */
  2789. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2790. /**
  2791. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2792. * @param scene the scene where the event occurred
  2793. * @param evt The original (browser) event
  2794. * @returns the new ActionEvent
  2795. */
  2796. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2797. /**
  2798. * Helper function to auto-create an ActionEvent from a primitive
  2799. * @param prim defines the target primitive
  2800. * @param pointerPos defines the pointer position
  2801. * @param evt The original (browser) event
  2802. * @param additionalData additional data for the event
  2803. * @returns the new ActionEvent
  2804. */
  2805. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2806. }
  2807. /**
  2808. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2809. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2811. */
  2812. class ActionManager {
  2813. private static _NothingTrigger;
  2814. private static _OnPickTrigger;
  2815. private static _OnLeftPickTrigger;
  2816. private static _OnRightPickTrigger;
  2817. private static _OnCenterPickTrigger;
  2818. private static _OnPickDownTrigger;
  2819. private static _OnDoublePickTrigger;
  2820. private static _OnPickUpTrigger;
  2821. private static _OnLongPressTrigger;
  2822. private static _OnPointerOverTrigger;
  2823. private static _OnPointerOutTrigger;
  2824. private static _OnEveryFrameTrigger;
  2825. private static _OnIntersectionEnterTrigger;
  2826. private static _OnIntersectionExitTrigger;
  2827. private static _OnKeyDownTrigger;
  2828. private static _OnKeyUpTrigger;
  2829. private static _OnPickOutTrigger;
  2830. /**
  2831. * Nothing
  2832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2833. */
  2834. static readonly NothingTrigger: number;
  2835. /**
  2836. * On pick
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly OnPickTrigger: number;
  2840. /**
  2841. * On left pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnLeftPickTrigger: number;
  2845. /**
  2846. * On right pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnRightPickTrigger: number;
  2850. /**
  2851. * On center pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnCenterPickTrigger: number;
  2855. /**
  2856. * On pick down
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnPickDownTrigger: number;
  2860. /**
  2861. * On double pick
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnDoublePickTrigger: number;
  2865. /**
  2866. * On pick up
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnPickUpTrigger: number;
  2870. /**
  2871. * On pick out.
  2872. * This trigger will only be raised if you also declared a OnPickDown
  2873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2874. */
  2875. static readonly OnPickOutTrigger: number;
  2876. /**
  2877. * On long press
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnLongPressTrigger: number;
  2881. /**
  2882. * On pointer over
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnPointerOverTrigger: number;
  2886. /**
  2887. * On pointer out
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOutTrigger: number;
  2891. /**
  2892. * On every frame
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnEveryFrameTrigger: number;
  2896. /**
  2897. * On intersection enter
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnIntersectionEnterTrigger: number;
  2901. /**
  2902. * On intersection exit
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionExitTrigger: number;
  2906. /**
  2907. * On key down
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnKeyDownTrigger: number;
  2911. /**
  2912. * On key up
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyUpTrigger: number;
  2916. /** Gets the list of active triggers */
  2917. static Triggers: {
  2918. [key: string]: number;
  2919. };
  2920. /** Gets the list of actions */
  2921. actions: Action[];
  2922. /** Gets the cursor to use when hovering items */
  2923. hoverCursor: string;
  2924. private _scene;
  2925. /**
  2926. * Creates a new action manager
  2927. * @param scene defines the hosting scene
  2928. */
  2929. constructor(scene: Scene);
  2930. /**
  2931. * Releases all associated resources
  2932. */
  2933. dispose(): void;
  2934. /**
  2935. * Gets hosting scene
  2936. * @returns the hosting scene
  2937. */
  2938. getScene(): Scene;
  2939. /**
  2940. * Does this action manager handles actions of any of the given triggers
  2941. * @param triggers defines the triggers to be tested
  2942. * @return a boolean indicating whether one (or more) of the triggers is handled
  2943. */
  2944. hasSpecificTriggers(triggers: number[]): boolean;
  2945. /**
  2946. * Does this action manager handles actions of a given trigger
  2947. * @param trigger defines the trigger to be tested
  2948. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2949. * @return whether the trigger is handled
  2950. */
  2951. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2952. /**
  2953. * Does this action manager has pointer triggers
  2954. */
  2955. readonly hasPointerTriggers: boolean;
  2956. /**
  2957. * Does this action manager has pick triggers
  2958. */
  2959. readonly hasPickTriggers: boolean;
  2960. /**
  2961. * Does exist one action manager with at least one trigger
  2962. **/
  2963. static readonly HasTriggers: boolean;
  2964. /**
  2965. * Does exist one action manager with at least one pick trigger
  2966. **/
  2967. static readonly HasPickTriggers: boolean;
  2968. /**
  2969. * Does exist one action manager that handles actions of a given trigger
  2970. * @param trigger defines the trigger to be tested
  2971. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2972. **/
  2973. static HasSpecificTrigger(trigger: number): boolean;
  2974. /**
  2975. * Registers an action to this action manager
  2976. * @param action defines the action to be registered
  2977. * @return the action amended (prepared) after registration
  2978. */
  2979. registerAction(action: Action): Nullable<Action>;
  2980. /**
  2981. * Unregisters an action to this action manager
  2982. * @param action defines the action to be unregistered
  2983. * @return a boolean indicating whether the action has been unregistered
  2984. */
  2985. unregisterAction(action: Action): Boolean;
  2986. /**
  2987. * Process a specific trigger
  2988. * @param trigger defines the trigger to process
  2989. * @param evt defines the event details to be processed
  2990. */
  2991. processTrigger(trigger: number, evt?: ActionEvent): void;
  2992. /** @hidden */
  2993. _getEffectiveTarget(target: any, propertyPath: string): any;
  2994. /** @hidden */
  2995. _getProperty(propertyPath: string): string;
  2996. /**
  2997. * Serialize this manager to a JSON object
  2998. * @param name defines the property name to store this manager
  2999. * @returns a JSON representation of this manager
  3000. */
  3001. serialize(name: string): any;
  3002. /**
  3003. * Creates a new ActionManager from a JSON data
  3004. * @param parsedActions defines the JSON data to read from
  3005. * @param object defines the hosting mesh
  3006. * @param scene defines the hosting scene
  3007. */
  3008. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3009. /**
  3010. * Get a trigger name by index
  3011. * @param trigger defines the trigger index
  3012. * @returns a trigger name
  3013. */
  3014. static GetTriggerName(trigger: number): string;
  3015. }
  3016. }
  3017. declare module BABYLON {
  3018. /**
  3019. * A Condition applied to an Action
  3020. */
  3021. class Condition {
  3022. /**
  3023. * Internal only - manager for action
  3024. * @hidden
  3025. */
  3026. _actionManager: ActionManager;
  3027. /**
  3028. * Internal only
  3029. * @hidden
  3030. */
  3031. _evaluationId: number;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _currentResult: boolean;
  3037. /**
  3038. * Creates a new Condition
  3039. * @param actionManager the manager of the action the condition is applied to
  3040. */
  3041. constructor(actionManager: ActionManager);
  3042. /**
  3043. * Check if the current condition is valid
  3044. * @returns a boolean
  3045. */
  3046. isValid(): boolean;
  3047. /**
  3048. * Internal only
  3049. * @hidden
  3050. */
  3051. _getProperty(propertyPath: string): string;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getEffectiveTarget(target: any, propertyPath: string): any;
  3057. /**
  3058. * Serialize placeholder for child classes
  3059. * @returns the serialized object
  3060. */
  3061. serialize(): any;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. protected _serialize(serializedCondition: any): any;
  3067. }
  3068. /**
  3069. * Defines specific conditional operators as extensions of Condition
  3070. */
  3071. class ValueCondition extends Condition {
  3072. /** path to specify the property of the target the conditional operator uses */
  3073. propertyPath: string;
  3074. /** the value compared by the conditional operator against the current value of the property */
  3075. value: any;
  3076. /** the conditional operator, default ValueCondition.IsEqual */
  3077. operator: number;
  3078. /**
  3079. * Internal only
  3080. * @hidden
  3081. */
  3082. private static _IsEqual;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsDifferent;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsGreater;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsLesser;
  3098. /**
  3099. * returns the number for IsEqual
  3100. */
  3101. static readonly IsEqual: number;
  3102. /**
  3103. * Returns the number for IsDifferent
  3104. */
  3105. static readonly IsDifferent: number;
  3106. /**
  3107. * Returns the number for IsGreater
  3108. */
  3109. static readonly IsGreater: number;
  3110. /**
  3111. * Returns the number for IsLesser
  3112. */
  3113. static readonly IsLesser: number;
  3114. /**
  3115. * Internal only The action manager for the condition
  3116. * @hidden
  3117. */
  3118. _actionManager: ActionManager;
  3119. /**
  3120. * Internal only
  3121. * @hidden
  3122. */
  3123. private _target;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _effectiveTarget;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _property;
  3134. /**
  3135. * Creates a new ValueCondition
  3136. * @param actionManager manager for the action the condition applies to
  3137. * @param target for the action
  3138. * @param propertyPath path to specify the property of the target the conditional operator uses
  3139. * @param value the value compared by the conditional operator against the current value of the property
  3140. * @param operator the conditional operator, default ValueCondition.IsEqual
  3141. */
  3142. constructor(actionManager: ActionManager, target: any,
  3143. /** path to specify the property of the target the conditional operator uses */
  3144. propertyPath: string,
  3145. /** the value compared by the conditional operator against the current value of the property */
  3146. value: any,
  3147. /** the conditional operator, default ValueCondition.IsEqual */
  3148. operator?: number);
  3149. /**
  3150. * Compares the given value with the property value for the specified conditional operator
  3151. * @returns the result of the comparison
  3152. */
  3153. isValid(): boolean;
  3154. /**
  3155. * Serialize the ValueCondition into a JSON compatible object
  3156. * @returns serialization object
  3157. */
  3158. serialize(): any;
  3159. /**
  3160. * Gets the name of the conditional operator for the ValueCondition
  3161. * @param operator the conditional operator
  3162. * @returns the name
  3163. */
  3164. static GetOperatorName(operator: number): string;
  3165. }
  3166. /**
  3167. * Defines a predicate condition as an extension of Condition
  3168. */
  3169. class PredicateCondition extends Condition {
  3170. /** defines the predicate function used to validate the condition */
  3171. predicate: () => boolean;
  3172. /**
  3173. * Internal only - manager for action
  3174. * @hidden
  3175. */
  3176. _actionManager: ActionManager;
  3177. /**
  3178. * Creates a new PredicateCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param predicate defines the predicate function used to validate the condition
  3181. */
  3182. constructor(actionManager: ActionManager,
  3183. /** defines the predicate function used to validate the condition */
  3184. predicate: () => boolean);
  3185. /**
  3186. * @returns the validity of the predicate condition
  3187. */
  3188. isValid(): boolean;
  3189. }
  3190. /**
  3191. * Defines a state condition as an extension of Condition
  3192. */
  3193. class StateCondition extends Condition {
  3194. value: string;
  3195. /**
  3196. * Internal only - manager for action
  3197. * @hidden
  3198. */
  3199. _actionManager: ActionManager;
  3200. /**
  3201. * Internal only
  3202. * @hidden
  3203. */
  3204. private _target;
  3205. /**
  3206. * Creates a new StateCondition
  3207. * @param actionManager manager for the action the condition applies to
  3208. * @param target of the condition
  3209. * @param value to compare with target state
  3210. */
  3211. constructor(actionManager: ActionManager, target: any, value: string);
  3212. /**
  3213. * @returns the validity of the state
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Serialize the StateCondition into a JSON compatible object
  3218. * @returns serialization object
  3219. */
  3220. serialize(): any;
  3221. }
  3222. }
  3223. declare module BABYLON {
  3224. class SwitchBooleanAction extends Action {
  3225. propertyPath: string;
  3226. private _target;
  3227. private _effectiveTarget;
  3228. private _property;
  3229. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3230. _prepare(): void;
  3231. execute(): void;
  3232. serialize(parent: any): any;
  3233. }
  3234. class SetStateAction extends Action {
  3235. value: string;
  3236. private _target;
  3237. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3238. execute(): void;
  3239. serialize(parent: any): any;
  3240. }
  3241. class SetValueAction extends Action {
  3242. propertyPath: string;
  3243. value: any;
  3244. private _target;
  3245. private _effectiveTarget;
  3246. private _property;
  3247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3248. _prepare(): void;
  3249. execute(): void;
  3250. serialize(parent: any): any;
  3251. }
  3252. class IncrementValueAction extends Action {
  3253. propertyPath: string;
  3254. value: any;
  3255. private _target;
  3256. private _effectiveTarget;
  3257. private _property;
  3258. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3259. _prepare(): void;
  3260. execute(): void;
  3261. serialize(parent: any): any;
  3262. }
  3263. class PlayAnimationAction extends Action {
  3264. from: number;
  3265. to: number;
  3266. loop: boolean | undefined;
  3267. private _target;
  3268. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3269. _prepare(): void;
  3270. execute(): void;
  3271. serialize(parent: any): any;
  3272. }
  3273. class StopAnimationAction extends Action {
  3274. private _target;
  3275. constructor(triggerOptions: any, target: any, condition?: Condition);
  3276. _prepare(): void;
  3277. execute(): void;
  3278. serialize(parent: any): any;
  3279. }
  3280. class DoNothingAction extends Action {
  3281. constructor(triggerOptions?: any, condition?: Condition);
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class CombineAction extends Action {
  3286. children: Action[];
  3287. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3288. _prepare(): void;
  3289. execute(evt: ActionEvent): void;
  3290. serialize(parent: any): any;
  3291. }
  3292. class ExecuteCodeAction extends Action {
  3293. func: (evt: ActionEvent) => void;
  3294. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3295. execute(evt: ActionEvent): void;
  3296. }
  3297. class SetParentAction extends Action {
  3298. private _parent;
  3299. private _target;
  3300. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3301. _prepare(): void;
  3302. execute(): void;
  3303. serialize(parent: any): any;
  3304. }
  3305. class PlaySoundAction extends Action {
  3306. private _sound;
  3307. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3308. _prepare(): void;
  3309. execute(): void;
  3310. serialize(parent: any): any;
  3311. }
  3312. class StopSoundAction extends Action {
  3313. private _sound;
  3314. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3315. _prepare(): void;
  3316. execute(): void;
  3317. serialize(parent: any): any;
  3318. }
  3319. }
  3320. declare module BABYLON {
  3321. class InterpolateValueAction extends Action {
  3322. propertyPath: string;
  3323. value: any;
  3324. duration: number;
  3325. stopOtherAnimations: boolean | undefined;
  3326. onInterpolationDone: (() => void) | undefined;
  3327. private _target;
  3328. private _effectiveTarget;
  3329. private _property;
  3330. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3331. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3332. _prepare(): void;
  3333. execute(): void;
  3334. serialize(parent: any): any;
  3335. }
  3336. }
  3337. declare module BABYLON {
  3338. /**
  3339. * Class used to store an actual running animation
  3340. */
  3341. class Animatable {
  3342. /** defines the target object */
  3343. target: any;
  3344. /** defines the starting frame number (default is 0) */
  3345. fromFrame: number;
  3346. /** defines the ending frame number (default is 100) */
  3347. toFrame: number;
  3348. /** defines if the animation must loop (default is false) */
  3349. loopAnimation: boolean;
  3350. /** defines a callback to call when animation ends if it is not looping */
  3351. onAnimationEnd: (() => void) | null | undefined;
  3352. private _localDelayOffset;
  3353. private _pausedDelay;
  3354. private _runtimeAnimations;
  3355. private _paused;
  3356. private _scene;
  3357. private _speedRatio;
  3358. private _weight;
  3359. private _syncRoot;
  3360. /**
  3361. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3362. * This will only apply for non looping animation (default is true)
  3363. */
  3364. disposeOnEnd: boolean;
  3365. /**
  3366. * Gets a boolean indicating if the animation has started
  3367. */
  3368. animationStarted: boolean;
  3369. /**
  3370. * Observer raised when the animation ends
  3371. */
  3372. onAnimationEndObservable: Observable<Animatable>;
  3373. /**
  3374. * Gets the root Animatable used to synchronize and normalize animations
  3375. */
  3376. readonly syncRoot: Animatable;
  3377. /**
  3378. * Gets the current frame of the first RuntimeAnimation
  3379. * Used to synchronize Animatables
  3380. */
  3381. readonly masterFrame: number;
  3382. /**
  3383. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3384. */
  3385. weight: number;
  3386. /**
  3387. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3388. */
  3389. speedRatio: number;
  3390. /**
  3391. * Creates a new Animatable
  3392. * @param scene defines the hosting scene
  3393. * @param target defines the target object
  3394. * @param fromFrame defines the starting frame number (default is 0)
  3395. * @param toFrame defines the ending frame number (default is 100)
  3396. * @param loopAnimation defines if the animation must loop (default is false)
  3397. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3398. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3399. * @param animations defines a group of animation to add to the new Animatable
  3400. */
  3401. constructor(scene: Scene,
  3402. /** defines the target object */
  3403. target: any,
  3404. /** defines the starting frame number (default is 0) */
  3405. fromFrame?: number,
  3406. /** defines the ending frame number (default is 100) */
  3407. toFrame?: number,
  3408. /** defines if the animation must loop (default is false) */
  3409. loopAnimation?: boolean, speedRatio?: number,
  3410. /** defines a callback to call when animation ends if it is not looping */
  3411. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3412. /**
  3413. * Synchronize and normalize current Animatable with a source Animatable
  3414. * This is useful when using animation weights and when animations are not of the same length
  3415. * @param root defines the root Animatable to synchronize with
  3416. * @returns the current Animatable
  3417. */
  3418. syncWith(root: Animatable): Animatable;
  3419. /**
  3420. * Gets the list of runtime animations
  3421. * @returns an array of RuntimeAnimation
  3422. */
  3423. getAnimations(): RuntimeAnimation[];
  3424. /**
  3425. * Adds more animations to the current animatable
  3426. * @param target defines the target of the animations
  3427. * @param animations defines the new animations to add
  3428. */
  3429. appendAnimations(target: any, animations: Animation[]): void;
  3430. /**
  3431. * Gets the source animation for a specific property
  3432. * @param property defines the propertyu to look for
  3433. * @returns null or the source animation for the given property
  3434. */
  3435. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3436. /**
  3437. * Gets the runtime animation for a specific property
  3438. * @param property defines the propertyu to look for
  3439. * @returns null or the runtime animation for the given property
  3440. */
  3441. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3442. /**
  3443. * Resets the animatable to its original state
  3444. */
  3445. reset(): void;
  3446. /**
  3447. * Allows the animatable to blend with current running animations
  3448. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3449. * @param blendingSpeed defines the blending speed to use
  3450. */
  3451. enableBlending(blendingSpeed: number): void;
  3452. /**
  3453. * Disable animation blending
  3454. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3455. */
  3456. disableBlending(): void;
  3457. /**
  3458. * Jump directly to a given frame
  3459. * @param frame defines the frame to jump to
  3460. */
  3461. goToFrame(frame: number): void;
  3462. /**
  3463. * Pause the animation
  3464. */
  3465. pause(): void;
  3466. /**
  3467. * Restart the animation
  3468. */
  3469. restart(): void;
  3470. private _raiseOnAnimationEnd();
  3471. /**
  3472. * Stop and delete the current animation
  3473. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3474. */
  3475. stop(animationName?: string): void;
  3476. /**
  3477. * Wait asynchronously for the animation to end
  3478. * @returns a promise which will be fullfilled when the animation ends
  3479. */
  3480. waitAsync(): Promise<Animatable>;
  3481. /** @hidden */
  3482. _animate(delay: number): boolean;
  3483. }
  3484. }
  3485. declare module BABYLON {
  3486. /**
  3487. * Represents the range of an animation
  3488. */
  3489. class AnimationRange {
  3490. /**The name of the animation range**/
  3491. name: string;
  3492. /**The starting frame of the animation */
  3493. from: number;
  3494. /**The ending frame of the animation*/
  3495. to: number;
  3496. /**
  3497. * Initializes the range of an animation
  3498. * @param name The name of the animation range
  3499. * @param from The starting frame of the animation
  3500. * @param to The ending frame of the animation
  3501. */
  3502. constructor(
  3503. /**The name of the animation range**/
  3504. name: string,
  3505. /**The starting frame of the animation */
  3506. from: number,
  3507. /**The ending frame of the animation*/
  3508. to: number);
  3509. /**
  3510. * Makes a copy of the animation range
  3511. * @returns A copy of the animation range
  3512. */
  3513. clone(): AnimationRange;
  3514. }
  3515. /**
  3516. * Composed of a frame, and an action function
  3517. */
  3518. class AnimationEvent {
  3519. /** The frame for which the event is triggered **/
  3520. frame: number;
  3521. /** The event to perform when triggered **/
  3522. action: () => void;
  3523. /** Specifies if the event should be triggered only once**/
  3524. onlyOnce: boolean | undefined;
  3525. /**
  3526. * Specifies if the animation event is done
  3527. */
  3528. isDone: boolean;
  3529. /**
  3530. * Initializes the animation event
  3531. * @param frame The frame for which the event is triggered
  3532. * @param action The event to perform when triggered
  3533. * @param onlyOnce Specifies if the event should be triggered only once
  3534. */
  3535. constructor(
  3536. /** The frame for which the event is triggered **/
  3537. frame: number,
  3538. /** The event to perform when triggered **/
  3539. action: () => void,
  3540. /** Specifies if the event should be triggered only once**/
  3541. onlyOnce?: boolean | undefined);
  3542. /** @hidden */
  3543. _clone(): AnimationEvent;
  3544. }
  3545. /**
  3546. * A cursor which tracks a point on a path
  3547. */
  3548. class PathCursor {
  3549. private path;
  3550. /**
  3551. * Stores path cursor callbacks for when an onchange event is triggered
  3552. */
  3553. private _onchange;
  3554. /**
  3555. * The value of the path cursor
  3556. */
  3557. value: number;
  3558. /**
  3559. * The animation array of the path cursor
  3560. */
  3561. animations: Animation[];
  3562. /**
  3563. * Initializes the path cursor
  3564. * @param path The path to track
  3565. */
  3566. constructor(path: Path2);
  3567. /**
  3568. * Gets the cursor point on the path
  3569. * @returns A point on the path cursor at the cursor location
  3570. */
  3571. getPoint(): Vector3;
  3572. /**
  3573. * Moves the cursor ahead by the step amount
  3574. * @param step The amount to move the cursor forward
  3575. * @returns This path cursor
  3576. */
  3577. moveAhead(step?: number): PathCursor;
  3578. /**
  3579. * Moves the cursor behind by the step amount
  3580. * @param step The amount to move the cursor back
  3581. * @returns This path cursor
  3582. */
  3583. moveBack(step?: number): PathCursor;
  3584. /**
  3585. * Moves the cursor by the step amount
  3586. * If the step amount is greater than one, an exception is thrown
  3587. * @param step The amount to move the cursor
  3588. * @returns This path cursor
  3589. */
  3590. move(step: number): PathCursor;
  3591. /**
  3592. * Ensures that the value is limited between zero and one
  3593. * @returns This path cursor
  3594. */
  3595. private ensureLimits();
  3596. /**
  3597. * Runs onchange callbacks on change (used by the animation engine)
  3598. * @returns This path cursor
  3599. */
  3600. private raiseOnChange();
  3601. /**
  3602. * Executes a function on change
  3603. * @param f A path cursor onchange callback
  3604. * @returns This path cursor
  3605. */
  3606. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3607. }
  3608. /**
  3609. * Defines an interface which represents an animation key frame
  3610. */
  3611. interface IAnimationKey {
  3612. /**
  3613. * Frame of the key frame
  3614. */
  3615. frame: number;
  3616. /**
  3617. * Value at the specifies key frame
  3618. */
  3619. value: any;
  3620. /**
  3621. * The input tangent for the cubic hermite spline
  3622. */
  3623. inTangent?: any;
  3624. /**
  3625. * The output tangent for the cubic hermite spline
  3626. */
  3627. outTangent?: any;
  3628. /**
  3629. * The animation interpolation type
  3630. */
  3631. interpolation?: AnimationKeyInterpolation;
  3632. }
  3633. /**
  3634. * Enum for the animation key frame interpolation type
  3635. */
  3636. enum AnimationKeyInterpolation {
  3637. /**
  3638. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3639. */
  3640. STEP = 1,
  3641. }
  3642. /**
  3643. * Class used to store any kind of animation
  3644. */
  3645. class Animation {
  3646. /**Name of the animation */
  3647. name: string;
  3648. /**Property to animate */
  3649. targetProperty: string;
  3650. /**The frames per second of the animation */
  3651. framePerSecond: number;
  3652. /**The data type of the animation */
  3653. dataType: number;
  3654. /**The loop mode of the animation */
  3655. loopMode: number | undefined;
  3656. /**Specifies if blending should be enabled */
  3657. enableBlending: boolean | undefined;
  3658. /**
  3659. * Use matrix interpolation instead of using direct key value when animating matrices
  3660. */
  3661. static AllowMatricesInterpolation: boolean;
  3662. /**
  3663. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3664. */
  3665. static AllowMatrixDecomposeForInterpolation: boolean;
  3666. /**
  3667. * Stores the key frames of the animation
  3668. */
  3669. private _keys;
  3670. /**
  3671. * Stores the easing function of the animation
  3672. */
  3673. private _easingFunction;
  3674. /**
  3675. * @hidden Internal use only
  3676. */
  3677. _runtimeAnimations: RuntimeAnimation[];
  3678. /**
  3679. * The set of event that will be linked to this animation
  3680. */
  3681. private _events;
  3682. /**
  3683. * Stores an array of target property paths
  3684. */
  3685. targetPropertyPath: string[];
  3686. /**
  3687. * Stores the blending speed of the animation
  3688. */
  3689. blendingSpeed: number;
  3690. /**
  3691. * Stores the animation ranges for the animation
  3692. */
  3693. private _ranges;
  3694. /**
  3695. * @hidden Internal use
  3696. */
  3697. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3698. /**
  3699. * Sets up an animation
  3700. * @param property The property to animate
  3701. * @param animationType The animation type to apply
  3702. * @param framePerSecond The frames per second of the animation
  3703. * @param easingFunction The easing function used in the animation
  3704. * @returns The created animation
  3705. */
  3706. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3707. /**
  3708. * Create and start an animation on a node
  3709. * @param name defines the name of the global animation that will be run on all nodes
  3710. * @param node defines the root node where the animation will take place
  3711. * @param targetProperty defines property to animate
  3712. * @param framePerSecond defines the number of frame per second yo use
  3713. * @param totalFrame defines the number of frames in total
  3714. * @param from defines the initial value
  3715. * @param to defines the final value
  3716. * @param loopMode defines which loop mode you want to use (off by default)
  3717. * @param easingFunction defines the easing function to use (linear by default)
  3718. * @param onAnimationEnd defines the callback to call when animation end
  3719. * @returns the animatable created for this animation
  3720. */
  3721. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3722. /**
  3723. * Create and start an animation on a node and its descendants
  3724. * @param name defines the name of the global animation that will be run on all nodes
  3725. * @param node defines the root node where the animation will take place
  3726. * @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
  3727. * @param targetProperty defines property to animate
  3728. * @param framePerSecond defines the number of frame per second to use
  3729. * @param totalFrame defines the number of frames in total
  3730. * @param from defines the initial value
  3731. * @param to defines the final value
  3732. * @param loopMode defines which loop mode you want to use (off by default)
  3733. * @param easingFunction defines the easing function to use (linear by default)
  3734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3735. * @returns the list of animatables created for all nodes
  3736. * @example https://www.babylonjs-playground.com/#MH0VLI
  3737. */
  3738. 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[]>;
  3739. /**
  3740. * Creates a new animation, merges it with the existing animations and starts it
  3741. * @param name Name of the animation
  3742. * @param node Node which contains the scene that begins the animations
  3743. * @param targetProperty Specifies which property to animate
  3744. * @param framePerSecond The frames per second of the animation
  3745. * @param totalFrame The total number of frames
  3746. * @param from The frame at the beginning of the animation
  3747. * @param to The frame at the end of the animation
  3748. * @param loopMode Specifies the loop mode of the animation
  3749. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3750. * @param onAnimationEnd Callback to run once the animation is complete
  3751. * @returns Nullable animation
  3752. */
  3753. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3754. /**
  3755. * Transition property of an host to the target Value
  3756. * @param property The property to transition
  3757. * @param targetValue The target Value of the property
  3758. * @param host The object where the property to animate belongs
  3759. * @param scene Scene used to run the animation
  3760. * @param frameRate Framerate (in frame/s) to use
  3761. * @param transition The transition type we want to use
  3762. * @param duration The duration of the animation, in milliseconds
  3763. * @param onAnimationEnd Callback trigger at the end of the animation
  3764. * @returns Nullable animation
  3765. */
  3766. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3767. /**
  3768. * Return the array of runtime animations currently using this animation
  3769. */
  3770. readonly runtimeAnimations: RuntimeAnimation[];
  3771. /**
  3772. * Specifies if any of the runtime animations are currently running
  3773. */
  3774. readonly hasRunningRuntimeAnimations: boolean;
  3775. /**
  3776. * Initializes the animation
  3777. * @param name Name of the animation
  3778. * @param targetProperty Property to animate
  3779. * @param framePerSecond The frames per second of the animation
  3780. * @param dataType The data type of the animation
  3781. * @param loopMode The loop mode of the animation
  3782. * @param enableBlendings Specifies if blending should be enabled
  3783. */
  3784. constructor(
  3785. /**Name of the animation */
  3786. name: string,
  3787. /**Property to animate */
  3788. targetProperty: string,
  3789. /**The frames per second of the animation */
  3790. framePerSecond: number,
  3791. /**The data type of the animation */
  3792. dataType: number,
  3793. /**The loop mode of the animation */
  3794. loopMode?: number | undefined,
  3795. /**Specifies if blending should be enabled */
  3796. enableBlending?: boolean | undefined);
  3797. /**
  3798. * Converts the animation to a string
  3799. * @param fullDetails support for multiple levels of logging within scene loading
  3800. * @returns String form of the animation
  3801. */
  3802. toString(fullDetails?: boolean): string;
  3803. /**
  3804. * Add an event to this animation
  3805. * @param event Event to add
  3806. */
  3807. addEvent(event: AnimationEvent): void;
  3808. /**
  3809. * Remove all events found at the given frame
  3810. * @param frame The frame to remove events from
  3811. */
  3812. removeEvents(frame: number): void;
  3813. /**
  3814. * Retrieves all the events from the animation
  3815. * @returns Events from the animation
  3816. */
  3817. getEvents(): AnimationEvent[];
  3818. /**
  3819. * Creates an animation range
  3820. * @param name Name of the animation range
  3821. * @param from Starting frame of the animation range
  3822. * @param to Ending frame of the animation
  3823. */
  3824. createRange(name: string, from: number, to: number): void;
  3825. /**
  3826. * Deletes an animation range by name
  3827. * @param name Name of the animation range to delete
  3828. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3829. */
  3830. deleteRange(name: string, deleteFrames?: boolean): void;
  3831. /**
  3832. * Gets the animation range by name, or null if not defined
  3833. * @param name Name of the animation range
  3834. * @returns Nullable animation range
  3835. */
  3836. getRange(name: string): Nullable<AnimationRange>;
  3837. /**
  3838. * Gets the key frames from the animation
  3839. * @returns The key frames of the animation
  3840. */
  3841. getKeys(): Array<IAnimationKey>;
  3842. /**
  3843. * Gets the highest frame rate of the animation
  3844. * @returns Highest frame rate of the animation
  3845. */
  3846. getHighestFrame(): number;
  3847. /**
  3848. * Gets the easing function of the animation
  3849. * @returns Easing function of the animation
  3850. */
  3851. getEasingFunction(): IEasingFunction;
  3852. /**
  3853. * Sets the easing function of the animation
  3854. * @param easingFunction A custom mathematical formula for animation
  3855. */
  3856. setEasingFunction(easingFunction: EasingFunction): void;
  3857. /**
  3858. * Interpolates a scalar linearly
  3859. * @param startValue Start value of the animation curve
  3860. * @param endValue End value of the animation curve
  3861. * @param gradient Scalar amount to interpolate
  3862. * @returns Interpolated scalar value
  3863. */
  3864. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3865. /**
  3866. * Interpolates a scalar cubically
  3867. * @param startValue Start value of the animation curve
  3868. * @param outTangent End tangent of the animation
  3869. * @param endValue End value of the animation curve
  3870. * @param inTangent Start tangent of the animation curve
  3871. * @param gradient Scalar amount to interpolate
  3872. * @returns Interpolated scalar value
  3873. */
  3874. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3875. /**
  3876. * Interpolates a quaternion using a spherical linear interpolation
  3877. * @param startValue Start value of the animation curve
  3878. * @param endValue End value of the animation curve
  3879. * @param gradient Scalar amount to interpolate
  3880. * @returns Interpolated quaternion value
  3881. */
  3882. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3883. /**
  3884. * Interpolates a quaternion cubically
  3885. * @param startValue Start value of the animation curve
  3886. * @param outTangent End tangent of the animation curve
  3887. * @param endValue End value of the animation curve
  3888. * @param inTangent Start tangent of the animation curve
  3889. * @param gradient Scalar amount to interpolate
  3890. * @returns Interpolated quaternion value
  3891. */
  3892. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3893. /**
  3894. * Interpolates a Vector3 linearl
  3895. * @param startValue Start value of the animation curve
  3896. * @param endValue End value of the animation curve
  3897. * @param gradient Scalar amount to interpolate
  3898. * @returns Interpolated scalar value
  3899. */
  3900. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3901. /**
  3902. * Interpolates a Vector3 cubically
  3903. * @param startValue Start value of the animation curve
  3904. * @param outTangent End tangent of the animation
  3905. * @param endValue End value of the animation curve
  3906. * @param inTangent Start tangent of the animation curve
  3907. * @param gradient Scalar amount to interpolate
  3908. * @returns InterpolatedVector3 value
  3909. */
  3910. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3911. /**
  3912. * Interpolates a Vector2 linearly
  3913. * @param startValue Start value of the animation curve
  3914. * @param endValue End value of the animation curve
  3915. * @param gradient Scalar amount to interpolate
  3916. * @returns Interpolated Vector2 value
  3917. */
  3918. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3919. /**
  3920. * Interpolates a Vector2 cubically
  3921. * @param startValue Start value of the animation curve
  3922. * @param outTangent End tangent of the animation
  3923. * @param endValue End value of the animation curve
  3924. * @param inTangent Start tangent of the animation curve
  3925. * @param gradient Scalar amount to interpolate
  3926. * @returns Interpolated Vector2 value
  3927. */
  3928. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3929. /**
  3930. * Interpolates a size linearly
  3931. * @param startValue Start value of the animation curve
  3932. * @param endValue End value of the animation curve
  3933. * @param gradient Scalar amount to interpolate
  3934. * @returns Interpolated Size value
  3935. */
  3936. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3937. /**
  3938. * Interpolates a Color3 linearly
  3939. * @param startValue Start value of the animation curve
  3940. * @param endValue End value of the animation curve
  3941. * @param gradient Scalar amount to interpolate
  3942. * @returns Interpolated Color3 value
  3943. */
  3944. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3945. /**
  3946. * @hidden Internal use only
  3947. */
  3948. _getKeyValue(value: any): any;
  3949. /**
  3950. * @hidden Internal use only
  3951. */
  3952. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3953. /**
  3954. * Defines the function to use to interpolate matrices
  3955. * @param startValue defines the start matrix
  3956. * @param endValue defines the end matrix
  3957. * @param gradient defines the gradient between both matrices
  3958. * @param result defines an optional target matrix where to store the interpolation
  3959. * @returns the interpolated matrix
  3960. */
  3961. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3962. /**
  3963. * Makes a copy of the animation
  3964. * @returns Cloned animation
  3965. */
  3966. clone(): Animation;
  3967. /**
  3968. * Sets the key frames of the animation
  3969. * @param values The animation key frames to set
  3970. */
  3971. setKeys(values: Array<IAnimationKey>): void;
  3972. /**
  3973. * Serializes the animation to an object
  3974. * @returns Serialized object
  3975. */
  3976. serialize(): any;
  3977. /**
  3978. * Float animation type
  3979. */
  3980. private static _ANIMATIONTYPE_FLOAT;
  3981. /**
  3982. * Vector3 animation type
  3983. */
  3984. private static _ANIMATIONTYPE_VECTOR3;
  3985. /**
  3986. * Quaternion animation type
  3987. */
  3988. private static _ANIMATIONTYPE_QUATERNION;
  3989. /**
  3990. * Matrix animation type
  3991. */
  3992. private static _ANIMATIONTYPE_MATRIX;
  3993. /**
  3994. * Color3 animation type
  3995. */
  3996. private static _ANIMATIONTYPE_COLOR3;
  3997. /**
  3998. * Vector2 animation type
  3999. */
  4000. private static _ANIMATIONTYPE_VECTOR2;
  4001. /**
  4002. * Size animation type
  4003. */
  4004. private static _ANIMATIONTYPE_SIZE;
  4005. /**
  4006. * Relative Loop Mode
  4007. */
  4008. private static _ANIMATIONLOOPMODE_RELATIVE;
  4009. /**
  4010. * Cycle Loop Mode
  4011. */
  4012. private static _ANIMATIONLOOPMODE_CYCLE;
  4013. /**
  4014. * Constant Loop Mode
  4015. */
  4016. private static _ANIMATIONLOOPMODE_CONSTANT;
  4017. /**
  4018. * Get the float animation type
  4019. */
  4020. static readonly ANIMATIONTYPE_FLOAT: number;
  4021. /**
  4022. * Get the Vector3 animation type
  4023. */
  4024. static readonly ANIMATIONTYPE_VECTOR3: number;
  4025. /**
  4026. * Get the Vectpr2 animation type
  4027. */
  4028. static readonly ANIMATIONTYPE_VECTOR2: number;
  4029. /**
  4030. * Get the Size animation type
  4031. */
  4032. static readonly ANIMATIONTYPE_SIZE: number;
  4033. /**
  4034. * Get the Quaternion animation type
  4035. */
  4036. static readonly ANIMATIONTYPE_QUATERNION: number;
  4037. /**
  4038. * Get the Matrix animation type
  4039. */
  4040. static readonly ANIMATIONTYPE_MATRIX: number;
  4041. /**
  4042. * Get the Color3 animation type
  4043. */
  4044. static readonly ANIMATIONTYPE_COLOR3: number;
  4045. /**
  4046. * Get the Relative Loop Mode
  4047. */
  4048. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4049. /**
  4050. * Get the Cycle Loop Mode
  4051. */
  4052. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4053. /**
  4054. * Get the Constant Loop Mode
  4055. */
  4056. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4057. /** @hidden */
  4058. static _UniversalLerp(left: any, right: any, amount: number): any;
  4059. /**
  4060. * Parses an animation object and creates an animation
  4061. * @param parsedAnimation Parsed animation object
  4062. * @returns Animation object
  4063. */
  4064. static Parse(parsedAnimation: any): Animation;
  4065. /**
  4066. * Appends the serialized animations from the source animations
  4067. * @param source Source containing the animations
  4068. * @param destination Target to store the animations
  4069. */
  4070. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4071. }
  4072. }
  4073. declare module BABYLON {
  4074. /**
  4075. * This class defines the direct association between an animation and a target
  4076. */
  4077. class TargetedAnimation {
  4078. animation: Animation;
  4079. target: any;
  4080. }
  4081. /**
  4082. * Use this class to create coordinated animations on multiple targets
  4083. */
  4084. class AnimationGroup implements IDisposable {
  4085. name: string;
  4086. private _scene;
  4087. private _targetedAnimations;
  4088. private _animatables;
  4089. private _from;
  4090. private _to;
  4091. private _isStarted;
  4092. private _speedRatio;
  4093. onAnimationEndObservable: Observable<TargetedAnimation>;
  4094. /**
  4095. * This observable will notify when all animations have ended.
  4096. */
  4097. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4098. /**
  4099. * Gets the first frame
  4100. */
  4101. readonly from: number;
  4102. /**
  4103. * Gets the last frame
  4104. */
  4105. readonly to: number;
  4106. /**
  4107. * Define if the animations are started
  4108. */
  4109. readonly isStarted: boolean;
  4110. /**
  4111. * Gets or sets the speed ratio to use for all animations
  4112. */
  4113. /**
  4114. * Gets or sets the speed ratio to use for all animations
  4115. */
  4116. speedRatio: number;
  4117. /**
  4118. * Gets the targeted animations for this animation group
  4119. */
  4120. readonly targetedAnimations: Array<TargetedAnimation>;
  4121. /**
  4122. * returning the list of animatables controlled by this animation group.
  4123. */
  4124. readonly animatables: Array<Animatable>;
  4125. constructor(name: string, scene?: Nullable<Scene>);
  4126. /**
  4127. * Add an animation (with its target) in the group
  4128. * @param animation defines the animation we want to add
  4129. * @param target defines the target of the animation
  4130. * @returns the {BABYLON.TargetedAnimation} object
  4131. */
  4132. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4133. /**
  4134. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4135. * It can add constant keys at begin or end
  4136. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4137. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4138. */
  4139. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4140. /**
  4141. * Start all animations on given targets
  4142. * @param loop defines if animations must loop
  4143. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4144. * @param from defines the from key (optional)
  4145. * @param to defines the to key (optional)
  4146. * @returns the current animation group
  4147. */
  4148. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4149. /**
  4150. * Pause all animations
  4151. */
  4152. pause(): AnimationGroup;
  4153. /**
  4154. * Play all animations to initial state
  4155. * This function will start() the animations if they were not started or will restart() them if they were paused
  4156. * @param loop defines if animations must loop
  4157. */
  4158. play(loop?: boolean): AnimationGroup;
  4159. /**
  4160. * Reset all animations to initial state
  4161. */
  4162. reset(): AnimationGroup;
  4163. /**
  4164. * Restart animations from key 0
  4165. */
  4166. restart(): AnimationGroup;
  4167. /**
  4168. * Stop all animations
  4169. */
  4170. stop(): AnimationGroup;
  4171. /**
  4172. * Set animation weight for all animatables
  4173. * @param weight defines the weight to use
  4174. * @return the animationGroup
  4175. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4176. */
  4177. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4178. /**
  4179. * Synchronize and normalize all animatables with a source animatable
  4180. * @param root defines the root animatable to synchronize with
  4181. * @return the animationGroup
  4182. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4183. */
  4184. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4185. /**
  4186. * Goes to a specific frame in this animation group
  4187. * @param frame the frame number to go to
  4188. * @return the animationGroup
  4189. */
  4190. goToFrame(frame: number): AnimationGroup;
  4191. /**
  4192. * Dispose all associated resources
  4193. */
  4194. dispose(): void;
  4195. private _checkAnimationGroupEnded(animatable);
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * Class used to override all child animations of a given target
  4201. */
  4202. class AnimationPropertiesOverride {
  4203. /**
  4204. * Gets or sets a value indicating if animation blending must be used
  4205. */
  4206. enableBlending: boolean;
  4207. /**
  4208. * Gets or sets the blending speed to use when enableBlending is true
  4209. */
  4210. blendingSpeed: number;
  4211. /**
  4212. * Gets or sets the default loop mode to use
  4213. */
  4214. loopMode: number;
  4215. }
  4216. }
  4217. declare module BABYLON {
  4218. interface IEasingFunction {
  4219. ease(gradient: number): number;
  4220. }
  4221. class EasingFunction implements IEasingFunction {
  4222. private static _EASINGMODE_EASEIN;
  4223. private static _EASINGMODE_EASEOUT;
  4224. private static _EASINGMODE_EASEINOUT;
  4225. static readonly EASINGMODE_EASEIN: number;
  4226. static readonly EASINGMODE_EASEOUT: number;
  4227. static readonly EASINGMODE_EASEINOUT: number;
  4228. private _easingMode;
  4229. setEasingMode(easingMode: number): void;
  4230. getEasingMode(): number;
  4231. easeInCore(gradient: number): number;
  4232. ease(gradient: number): number;
  4233. }
  4234. class CircleEase extends EasingFunction implements IEasingFunction {
  4235. easeInCore(gradient: number): number;
  4236. }
  4237. class BackEase extends EasingFunction implements IEasingFunction {
  4238. amplitude: number;
  4239. constructor(amplitude?: number);
  4240. easeInCore(gradient: number): number;
  4241. }
  4242. class BounceEase extends EasingFunction implements IEasingFunction {
  4243. bounces: number;
  4244. bounciness: number;
  4245. constructor(bounces?: number, bounciness?: number);
  4246. easeInCore(gradient: number): number;
  4247. }
  4248. class CubicEase extends EasingFunction implements IEasingFunction {
  4249. easeInCore(gradient: number): number;
  4250. }
  4251. class ElasticEase extends EasingFunction implements IEasingFunction {
  4252. oscillations: number;
  4253. springiness: number;
  4254. constructor(oscillations?: number, springiness?: number);
  4255. easeInCore(gradient: number): number;
  4256. }
  4257. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4258. exponent: number;
  4259. constructor(exponent?: number);
  4260. easeInCore(gradient: number): number;
  4261. }
  4262. class PowerEase extends EasingFunction implements IEasingFunction {
  4263. power: number;
  4264. constructor(power?: number);
  4265. easeInCore(gradient: number): number;
  4266. }
  4267. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4268. easeInCore(gradient: number): number;
  4269. }
  4270. class QuarticEase extends EasingFunction implements IEasingFunction {
  4271. easeInCore(gradient: number): number;
  4272. }
  4273. class QuinticEase extends EasingFunction implements IEasingFunction {
  4274. easeInCore(gradient: number): number;
  4275. }
  4276. class SineEase extends EasingFunction implements IEasingFunction {
  4277. easeInCore(gradient: number): number;
  4278. }
  4279. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4280. x1: number;
  4281. y1: number;
  4282. x2: number;
  4283. y2: number;
  4284. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4285. easeInCore(gradient: number): number;
  4286. }
  4287. }
  4288. declare module BABYLON {
  4289. /**
  4290. * Defines a runtime animation
  4291. */
  4292. class RuntimeAnimation {
  4293. private _events;
  4294. /**
  4295. * The current frame of the runtime animation
  4296. */
  4297. private _currentFrame;
  4298. /**
  4299. * The animation used by the runtime animation
  4300. */
  4301. private _animation;
  4302. /**
  4303. * The target of the runtime animation
  4304. */
  4305. private _target;
  4306. /**
  4307. * The initiating animatable
  4308. */
  4309. private _host;
  4310. /**
  4311. * The original value of the runtime animation
  4312. */
  4313. private _originalValue;
  4314. /**
  4315. * The original blend value of the runtime animation
  4316. */
  4317. private _originalBlendValue;
  4318. /**
  4319. * The offsets cache of the runtime animation
  4320. */
  4321. private _offsetsCache;
  4322. /**
  4323. * The high limits cache of the runtime animation
  4324. */
  4325. private _highLimitsCache;
  4326. /**
  4327. * Specifies if the runtime animation has been stopped
  4328. */
  4329. private _stopped;
  4330. /**
  4331. * The blending factor of the runtime animation
  4332. */
  4333. private _blendingFactor;
  4334. /**
  4335. * The BabylonJS scene
  4336. */
  4337. private _scene;
  4338. /**
  4339. * The current value of the runtime animation
  4340. */
  4341. private _currentValue;
  4342. /** @hidden */
  4343. _workValue: any;
  4344. /**
  4345. * The active target of the runtime animation
  4346. */
  4347. private _activeTarget;
  4348. /**
  4349. * The target path of the runtime animation
  4350. */
  4351. private _targetPath;
  4352. /**
  4353. * The weight of the runtime animation
  4354. */
  4355. private _weight;
  4356. /**
  4357. * The ratio offset of the runtime animation
  4358. */
  4359. private _ratioOffset;
  4360. /**
  4361. * The previous delay of the runtime animation
  4362. */
  4363. private _previousDelay;
  4364. /**
  4365. * The previous ratio of the runtime animation
  4366. */
  4367. private _previousRatio;
  4368. /**
  4369. * Gets the current frame of the runtime animation
  4370. */
  4371. readonly currentFrame: number;
  4372. /**
  4373. * Gets the weight of the runtime animation
  4374. */
  4375. readonly weight: number;
  4376. /**
  4377. * Gets the current value of the runtime animation
  4378. */
  4379. readonly currentValue: any;
  4380. /**
  4381. * Gets the target path of the runtime animation
  4382. */
  4383. readonly targetPath: string;
  4384. /**
  4385. * Gets the actual target of the runtime animation
  4386. */
  4387. readonly target: any;
  4388. /**
  4389. * Create a new RuntimeAnimation object
  4390. * @param target defines the target of the animation
  4391. * @param animation defines the source animation object
  4392. * @param scene defines the hosting scene
  4393. * @param host defines the initiating Animatable
  4394. */
  4395. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4396. /**
  4397. * Gets the animation from the runtime animation
  4398. */
  4399. readonly animation: Animation;
  4400. /**
  4401. * Resets the runtime animation to the beginning
  4402. * @param restoreOriginal defines whether to restore the target property to the original value
  4403. */
  4404. reset(restoreOriginal?: boolean): void;
  4405. /**
  4406. * Specifies if the runtime animation is stopped
  4407. * @returns Boolean specifying if the runtime animation is stopped
  4408. */
  4409. isStopped(): boolean;
  4410. /**
  4411. * Disposes of the runtime animation
  4412. */
  4413. dispose(): void;
  4414. /**
  4415. * Interpolates the animation from the current frame
  4416. * @param currentFrame The frame to interpolate the animation to
  4417. * @param repeatCount The number of times that the animation should loop
  4418. * @param loopMode The type of looping mode to use
  4419. * @param offsetValue Animation offset value
  4420. * @param highLimitValue The high limit value
  4421. * @returns The interpolated value
  4422. */
  4423. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4424. /**
  4425. * Apply the interpolated value to the target
  4426. * @param currentValue defines the value computed by the animation
  4427. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4428. */
  4429. setValue(currentValue: any, weight?: number): void;
  4430. private _setValue(target, currentValue, weight, targetIndex?);
  4431. /**
  4432. * Gets the loop pmode of the runtime animation
  4433. * @returns Loop Mode
  4434. */
  4435. private _getCorrectLoopMode();
  4436. /**
  4437. * Move the current animation to a given frame
  4438. * @param frame defines the frame to move to
  4439. */
  4440. goToFrame(frame: number): void;
  4441. /**
  4442. * @hidden Internal use only
  4443. */
  4444. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4445. /**
  4446. * Execute the current animation
  4447. * @param delay defines the delay to add to the current frame
  4448. * @param from defines the lower bound of the animation range
  4449. * @param to defines the upper bound of the animation range
  4450. * @param loop defines if the current animation must loop
  4451. * @param speedRatio defines the current speed ratio
  4452. * @param weight defines the weight of the animation (default is -1 so no weight)
  4453. * @returns a boolean indicating if the animation has ended
  4454. */
  4455. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4456. }
  4457. }
  4458. declare module BABYLON {
  4459. /**
  4460. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4462. */
  4463. class Analyser {
  4464. /**
  4465. * Gets or sets the smoothing
  4466. * @ignorenaming
  4467. */
  4468. SMOOTHING: number;
  4469. /**
  4470. * Gets or sets the FFT table size
  4471. * @ignorenaming
  4472. */
  4473. FFT_SIZE: number;
  4474. /**
  4475. * Gets or sets the bar graph amplitude
  4476. * @ignorenaming
  4477. */
  4478. BARGRAPHAMPLITUDE: number;
  4479. /**
  4480. * Gets or sets the position of the debug canvas
  4481. * @ignorenaming
  4482. */
  4483. DEBUGCANVASPOS: {
  4484. x: number;
  4485. y: number;
  4486. };
  4487. /**
  4488. * Gets or sets the debug canvas size
  4489. * @ignorenaming
  4490. */
  4491. DEBUGCANVASSIZE: {
  4492. width: number;
  4493. height: number;
  4494. };
  4495. private _byteFreqs;
  4496. private _byteTime;
  4497. private _floatFreqs;
  4498. private _webAudioAnalyser;
  4499. private _debugCanvas;
  4500. private _debugCanvasContext;
  4501. private _scene;
  4502. private _registerFunc;
  4503. private _audioEngine;
  4504. /**
  4505. * Creates a new analyser
  4506. * @param scene defines hosting scene
  4507. */
  4508. constructor(scene: Scene);
  4509. /**
  4510. * Get the number of data values you will have to play with for the visualization
  4511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4512. * @returns a number
  4513. */
  4514. getFrequencyBinCount(): number;
  4515. /**
  4516. * Gets the current frequency data as a byte array
  4517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4518. * @returns a Uint8Array
  4519. */
  4520. getByteFrequencyData(): Uint8Array;
  4521. /**
  4522. * Gets the current waveform as a byte array
  4523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4524. * @returns a Uint8Array
  4525. */
  4526. getByteTimeDomainData(): Uint8Array;
  4527. /**
  4528. * Gets the current frequency data as a float array
  4529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4530. * @returns a Float32Array
  4531. */
  4532. getFloatFrequencyData(): Float32Array;
  4533. /**
  4534. * Renders the debug canvas
  4535. */
  4536. drawDebugCanvas(): void;
  4537. /**
  4538. * Stops rendering the debug canvas and removes it
  4539. */
  4540. stopDebugCanvas(): void;
  4541. /**
  4542. * Connects two audio nodes
  4543. * @param inputAudioNode defines first node to connect
  4544. * @param outputAudioNode defines second node to connect
  4545. */
  4546. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4547. /**
  4548. * Releases all associated resources
  4549. */
  4550. dispose(): void;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. class AudioEngine {
  4555. private _audioContext;
  4556. private _audioContextInitialized;
  4557. canUseWebAudio: boolean;
  4558. masterGain: GainNode;
  4559. private _connectedAnalyser;
  4560. WarnedWebAudioUnsupported: boolean;
  4561. unlocked: boolean;
  4562. onAudioUnlocked: () => any;
  4563. isMP3supported: boolean;
  4564. isOGGsupported: boolean;
  4565. readonly audioContext: Nullable<AudioContext>;
  4566. constructor();
  4567. private _unlockiOSaudio();
  4568. private _initializeAudioContext();
  4569. dispose(): void;
  4570. getGlobalVolume(): number;
  4571. setGlobalVolume(newVolume: number): void;
  4572. connectToAnalyser(analyser: Analyser): void;
  4573. }
  4574. }
  4575. declare module BABYLON {
  4576. class Sound {
  4577. name: string;
  4578. autoplay: boolean;
  4579. loop: boolean;
  4580. useCustomAttenuation: boolean;
  4581. soundTrackId: number;
  4582. spatialSound: boolean;
  4583. refDistance: number;
  4584. rolloffFactor: number;
  4585. maxDistance: number;
  4586. distanceModel: string;
  4587. private _panningModel;
  4588. onended: () => any;
  4589. private _playbackRate;
  4590. private _streaming;
  4591. private _startTime;
  4592. private _startOffset;
  4593. private _position;
  4594. private _localDirection;
  4595. private _volume;
  4596. private _isReadyToPlay;
  4597. isPlaying: boolean;
  4598. isPaused: boolean;
  4599. private _isDirectional;
  4600. private _readyToPlayCallback;
  4601. private _audioBuffer;
  4602. private _soundSource;
  4603. private _streamingSource;
  4604. private _soundPanner;
  4605. private _soundGain;
  4606. private _inputAudioNode;
  4607. private _ouputAudioNode;
  4608. private _coneInnerAngle;
  4609. private _coneOuterAngle;
  4610. private _coneOuterGain;
  4611. private _scene;
  4612. private _connectedMesh;
  4613. private _customAttenuationFunction;
  4614. private _registerFunc;
  4615. private _isOutputConnected;
  4616. private _htmlAudioElement;
  4617. private _urlType;
  4618. /**
  4619. * Create a sound and attach it to a scene
  4620. * @param name Name of your sound
  4621. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4622. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4623. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4624. */
  4625. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4626. dispose(): void;
  4627. isReady(): boolean;
  4628. private _soundLoaded(audioData);
  4629. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4630. updateOptions(options: any): void;
  4631. private _createSpatialParameters();
  4632. private _updateSpatialParameters();
  4633. switchPanningModelToHRTF(): void;
  4634. switchPanningModelToEqualPower(): void;
  4635. private _switchPanningModel();
  4636. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4637. /**
  4638. * Transform this sound into a directional source
  4639. * @param coneInnerAngle Size of the inner cone in degree
  4640. * @param coneOuterAngle Size of the outer cone in degree
  4641. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4642. */
  4643. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4644. setPosition(newPosition: Vector3): void;
  4645. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4646. private _updateDirection();
  4647. updateDistanceFromListener(): void;
  4648. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4649. /**
  4650. * Play the sound
  4651. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4652. * @param offset (optional) Start the sound setting it at a specific time
  4653. */
  4654. play(time?: number, offset?: number): void;
  4655. private _onended();
  4656. /**
  4657. * Stop the sound
  4658. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4659. */
  4660. stop(time?: number): void;
  4661. pause(): void;
  4662. setVolume(newVolume: number, time?: number): void;
  4663. setPlaybackRate(newPlaybackRate: number): void;
  4664. getVolume(): number;
  4665. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4666. detachFromMesh(): void;
  4667. private _onRegisterAfterWorldMatrixUpdate(node);
  4668. clone(): Nullable<Sound>;
  4669. getAudioBuffer(): AudioBuffer | null;
  4670. serialize(): any;
  4671. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4672. }
  4673. }
  4674. declare module BABYLON {
  4675. class SoundTrack {
  4676. private _outputAudioNode;
  4677. private _scene;
  4678. id: number;
  4679. soundCollection: Array<Sound>;
  4680. private _isMainTrack;
  4681. private _connectedAnalyser;
  4682. private _options;
  4683. private _isInitialized;
  4684. constructor(scene: Scene, options?: any);
  4685. private _initializeSoundTrackAudioGraph();
  4686. dispose(): void;
  4687. AddSound(sound: Sound): void;
  4688. RemoveSound(sound: Sound): void;
  4689. setVolume(newVolume: number): void;
  4690. switchPanningModelToHRTF(): void;
  4691. switchPanningModelToEqualPower(): void;
  4692. connectToAnalyser(analyser: Analyser): void;
  4693. }
  4694. }
  4695. declare module BABYLON {
  4696. /**
  4697. * Interface used to define a behavior
  4698. */
  4699. interface Behavior<T> {
  4700. /** gets or sets behavior's name */
  4701. name: string;
  4702. /**
  4703. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4704. */
  4705. init(): void;
  4706. /**
  4707. * Called when the behavior is attached to a target
  4708. * @param target defines the target where the behavior is attached to
  4709. */
  4710. attach(target: T): void;
  4711. /**
  4712. * Called when the behavior is detached from its target
  4713. */
  4714. detach(): void;
  4715. }
  4716. /**
  4717. * Interface implemented by classes supporting behaviors
  4718. */
  4719. interface IBehaviorAware<T> {
  4720. /**
  4721. * Attach a behavior
  4722. * @param behavior defines the behavior to attach
  4723. * @returns the current host
  4724. */
  4725. addBehavior(behavior: Behavior<T>): T;
  4726. /**
  4727. * Remove a behavior from the current object
  4728. * @param behavior defines the behavior to detach
  4729. * @returns the current host
  4730. */
  4731. removeBehavior(behavior: Behavior<T>): T;
  4732. /**
  4733. * Gets a behavior using its name to search
  4734. * @param name defines the name to search
  4735. * @returns the behavior or null if not found
  4736. */
  4737. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4738. }
  4739. }
  4740. declare module BABYLON {
  4741. /**
  4742. * Class used to store bone information
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4744. */
  4745. class Bone extends Node {
  4746. /**
  4747. * defines the bone name
  4748. */
  4749. name: string;
  4750. private static _tmpVecs;
  4751. private static _tmpQuat;
  4752. private static _tmpMats;
  4753. /**
  4754. * Gets the list of child bones
  4755. */
  4756. children: Bone[];
  4757. /** Gets the animations associated with this bone */
  4758. animations: Animation[];
  4759. /**
  4760. * Gets or sets bone length
  4761. */
  4762. length: number;
  4763. /**
  4764. * @hidden Internal only
  4765. * Set this value to map this bone to a different index in the transform matrices
  4766. * Set this value to -1 to exclude the bone from the transform matrices
  4767. */
  4768. _index: Nullable<number>;
  4769. private _skeleton;
  4770. private _localMatrix;
  4771. private _restPose;
  4772. private _baseMatrix;
  4773. private _absoluteTransform;
  4774. private _invertedAbsoluteTransform;
  4775. private _parent;
  4776. private _scalingDeterminant;
  4777. private _worldTransform;
  4778. private _localScaling;
  4779. private _localRotation;
  4780. private _localPosition;
  4781. private _needToDecompose;
  4782. private _needToCompose;
  4783. /** @hidden */
  4784. /** @hidden */
  4785. _matrix: Matrix;
  4786. /**
  4787. * Create a new bone
  4788. * @param name defines the bone name
  4789. * @param skeleton defines the parent skeleton
  4790. * @param parentBone defines the parent (can be null if the bone is the root)
  4791. * @param localMatrix defines the local matrix
  4792. * @param restPose defines the rest pose matrix
  4793. * @param baseMatrix defines the base matrix
  4794. * @param index defines index of the bone in the hiearchy
  4795. */
  4796. constructor(
  4797. /**
  4798. * defines the bone name
  4799. */
  4800. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4801. /**
  4802. * Gets the parent skeleton
  4803. * @returns a skeleton
  4804. */
  4805. getSkeleton(): Skeleton;
  4806. /**
  4807. * Gets parent bone
  4808. * @returns a bone or null if the bone is the root of the bone hierarchy
  4809. */
  4810. getParent(): Nullable<Bone>;
  4811. /**
  4812. * Sets the parent bone
  4813. * @param parent defines the parent (can be null if the bone is the root)
  4814. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4815. */
  4816. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4817. /**
  4818. * Gets the local matrix
  4819. * @returns a matrix
  4820. */
  4821. getLocalMatrix(): Matrix;
  4822. /**
  4823. * Gets the base matrix (initial matrix which remains unchanged)
  4824. * @returns a matrix
  4825. */
  4826. getBaseMatrix(): Matrix;
  4827. /**
  4828. * Gets the rest pose matrix
  4829. * @returns a matrix
  4830. */
  4831. getRestPose(): Matrix;
  4832. /**
  4833. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4834. */
  4835. getWorldMatrix(): Matrix;
  4836. /**
  4837. * Sets the local matrix to rest pose matrix
  4838. */
  4839. returnToRest(): void;
  4840. /**
  4841. * Gets the inverse of the absolute transform matrix.
  4842. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4843. * @returns a matrix
  4844. */
  4845. getInvertedAbsoluteTransform(): Matrix;
  4846. /**
  4847. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4848. * @returns a matrix
  4849. */
  4850. getAbsoluteTransform(): Matrix;
  4851. /** Gets or sets current position (in local space) */
  4852. position: Vector3;
  4853. /** Gets or sets current rotation (in local space) */
  4854. rotation: Vector3;
  4855. /** Gets or sets current rotation quaternion (in local space) */
  4856. rotationQuaternion: Quaternion;
  4857. /** Gets or sets current scaling (in local space) */
  4858. scaling: Vector3;
  4859. /**
  4860. * Gets the animation properties override
  4861. */
  4862. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4863. private _decompose();
  4864. private _compose();
  4865. /**
  4866. * Update the base and local matrices
  4867. * @param matrix defines the new base or local matrix
  4868. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4869. * @param updateLocalMatrix defines if the local matrix should be updated
  4870. */
  4871. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4872. /** @hidden */
  4873. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4874. /**
  4875. * Flag the bone as dirty (Forcing it to update everything)
  4876. */
  4877. markAsDirty(): void;
  4878. private _markAsDirtyAndCompose();
  4879. private _markAsDirtyAndDecompose();
  4880. /**
  4881. * Copy an animation range from another bone
  4882. * @param source defines the source bone
  4883. * @param rangeName defines the range name to copy
  4884. * @param frameOffset defines the frame offset
  4885. * @param rescaleAsRequired defines if rescaling must be applied if required
  4886. * @param skelDimensionsRatio defines the scaling ratio
  4887. * @returns true if operation was successful
  4888. */
  4889. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4890. /**
  4891. * Translate the bone in local or world space
  4892. * @param vec The amount to translate the bone
  4893. * @param space The space that the translation is in
  4894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4895. */
  4896. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4897. /**
  4898. * Set the postion of the bone in local or world space
  4899. * @param position The position to set the bone
  4900. * @param space The space that the position is in
  4901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4902. */
  4903. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4904. /**
  4905. * Set the absolute position of the bone (world space)
  4906. * @param position The position to set the bone
  4907. * @param mesh The mesh that this bone is attached to
  4908. */
  4909. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4910. /**
  4911. * Scale the bone on the x, y and z axes (in local space)
  4912. * @param x The amount to scale the bone on the x axis
  4913. * @param y The amount to scale the bone on the y axis
  4914. * @param z The amount to scale the bone on the z axis
  4915. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4916. */
  4917. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4918. /**
  4919. * Set the bone scaling in local space
  4920. * @param scale defines the scaling vector
  4921. */
  4922. setScale(scale: Vector3): void;
  4923. /**
  4924. * Gets the current scaling in local space
  4925. * @returns the current scaling vector
  4926. */
  4927. getScale(): Vector3;
  4928. /**
  4929. * Gets the current scaling in local space and stores it in a target vector
  4930. * @param result defines the target vector
  4931. */
  4932. getScaleToRef(result: Vector3): void;
  4933. /**
  4934. * Set the yaw, pitch, and roll of the bone in local or world space
  4935. * @param yaw The rotation of the bone on the y axis
  4936. * @param pitch The rotation of the bone on the x axis
  4937. * @param roll The rotation of the bone on the z axis
  4938. * @param space The space that the axes of rotation are in
  4939. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4940. */
  4941. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4942. /**
  4943. * Add a rotation to the bone on an axis in local or world space
  4944. * @param axis The axis to rotate the bone on
  4945. * @param amount The amount to rotate the bone
  4946. * @param space The space that the axis is in
  4947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4948. */
  4949. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4950. /**
  4951. * Set the rotation of the bone to a particular axis angle in local or world space
  4952. * @param axis The axis to rotate the bone on
  4953. * @param angle The angle that the bone should be rotated to
  4954. * @param space The space that the axis is in
  4955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4956. */
  4957. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4958. /**
  4959. * Set the euler rotation of the bone in local of world space
  4960. * @param rotation The euler rotation that the bone should be set to
  4961. * @param space The space that the rotation is in
  4962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4963. */
  4964. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4965. /**
  4966. * Set the quaternion rotation of the bone in local of world space
  4967. * @param quat The quaternion rotation that the bone should be set to
  4968. * @param space The space that the rotation is in
  4969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4970. */
  4971. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4972. /**
  4973. * Set the rotation matrix of the bone in local of world space
  4974. * @param rotMat The rotation matrix that the bone should be set to
  4975. * @param space The space that the rotation is in
  4976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4977. */
  4978. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4979. private _rotateWithMatrix(rmat, space?, mesh?);
  4980. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4981. /**
  4982. * Get the position of the bone in local or world space
  4983. * @param space The space that the returned position is in
  4984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4985. * @returns The position of the bone
  4986. */
  4987. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4988. /**
  4989. * Copy the position of the bone to a vector3 in local or world space
  4990. * @param space The space that the returned position is in
  4991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4992. * @param result The vector3 to copy the position to
  4993. */
  4994. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4995. /**
  4996. * Get the absolute position of the bone (world space)
  4997. * @param mesh The mesh that this bone is attached to
  4998. * @returns The absolute position of the bone
  4999. */
  5000. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5001. /**
  5002. * Copy the absolute position of the bone (world space) to the result param
  5003. * @param mesh The mesh that this bone is attached to
  5004. * @param result The vector3 to copy the absolute position to
  5005. */
  5006. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5007. /**
  5008. * Compute the absolute transforms of this bone and its children
  5009. */
  5010. computeAbsoluteTransforms(): void;
  5011. /**
  5012. * Get the world direction from an axis that is in the local space of the bone
  5013. * @param localAxis The local direction that is used to compute the world direction
  5014. * @param mesh The mesh that this bone is attached to
  5015. * @returns The world direction
  5016. */
  5017. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5018. /**
  5019. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5020. * @param localAxis The local direction that is used to compute the world direction
  5021. * @param mesh The mesh that this bone is attached to
  5022. * @param result The vector3 that the world direction will be copied to
  5023. */
  5024. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5025. /**
  5026. * Get the euler rotation of the bone in local or world space
  5027. * @param space The space that the rotation should be in
  5028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5029. * @returns The euler rotation
  5030. */
  5031. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5032. /**
  5033. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5034. * @param space The space that the rotation should be in
  5035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5036. * @param result The vector3 that the rotation should be copied to
  5037. */
  5038. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5039. /**
  5040. * Get the quaternion rotation of the bone in either local or world space
  5041. * @param space The space that the rotation should be in
  5042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5043. * @returns The quaternion rotation
  5044. */
  5045. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5046. /**
  5047. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5048. * @param space The space that the rotation should be in
  5049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5050. * @param result The quaternion that the rotation should be copied to
  5051. */
  5052. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5053. /**
  5054. * Get the rotation matrix of the bone in local or world space
  5055. * @param space The space that the rotation should be in
  5056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5057. * @returns The rotation matrix
  5058. */
  5059. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5060. /**
  5061. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5062. * @param space The space that the rotation should be in
  5063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5064. * @param result The quaternion that the rotation should be copied to
  5065. */
  5066. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5067. /**
  5068. * Get the world position of a point that is in the local space of the bone
  5069. * @param position The local position
  5070. * @param mesh The mesh that this bone is attached to
  5071. * @returns The world position
  5072. */
  5073. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5074. /**
  5075. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5076. * @param position The local position
  5077. * @param mesh The mesh that this bone is attached to
  5078. * @param result The vector3 that the world position should be copied to
  5079. */
  5080. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5081. /**
  5082. * Get the local position of a point that is in world space
  5083. * @param position The world position
  5084. * @param mesh The mesh that this bone is attached to
  5085. * @returns The local position
  5086. */
  5087. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5088. /**
  5089. * Get the local position of a point that is in world space and copy it to the result param
  5090. * @param position The world position
  5091. * @param mesh The mesh that this bone is attached to
  5092. * @param result The vector3 that the local position should be copied to
  5093. */
  5094. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5095. }
  5096. }
  5097. declare module BABYLON {
  5098. /**
  5099. * Class used to apply inverse kinematics to bones
  5100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5101. */
  5102. class BoneIKController {
  5103. private static _tmpVecs;
  5104. private static _tmpQuat;
  5105. private static _tmpMats;
  5106. /**
  5107. * Gets or sets the target mesh
  5108. */
  5109. targetMesh: AbstractMesh;
  5110. /** Gets or sets the mesh used as pole */
  5111. poleTargetMesh: AbstractMesh;
  5112. /**
  5113. * Gets or sets the bone used as pole
  5114. */
  5115. poleTargetBone: Nullable<Bone>;
  5116. /**
  5117. * Gets or sets the target position
  5118. */
  5119. targetPosition: Vector3;
  5120. /**
  5121. * Gets or sets the pole target position
  5122. */
  5123. poleTargetPosition: Vector3;
  5124. /**
  5125. * Gets or sets the pole target local offset
  5126. */
  5127. poleTargetLocalOffset: Vector3;
  5128. /**
  5129. * Gets or sets the pole angle
  5130. */
  5131. poleAngle: number;
  5132. /**
  5133. * Gets or sets the mesh associated with the controller
  5134. */
  5135. mesh: AbstractMesh;
  5136. /**
  5137. * 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)
  5138. */
  5139. slerpAmount: number;
  5140. private _bone1Quat;
  5141. private _bone1Mat;
  5142. private _bone2Ang;
  5143. private _bone1;
  5144. private _bone2;
  5145. private _bone1Length;
  5146. private _bone2Length;
  5147. private _maxAngle;
  5148. private _maxReach;
  5149. private _rightHandedSystem;
  5150. private _bendAxis;
  5151. private _slerping;
  5152. private _adjustRoll;
  5153. /**
  5154. * Gets or sets maximum allowed angle
  5155. */
  5156. maxAngle: number;
  5157. /**
  5158. * Creates a new BoneIKController
  5159. * @param mesh defines the mesh to control
  5160. * @param bone defines the bone to control
  5161. * @param options defines options to set up the controller
  5162. */
  5163. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5164. targetMesh?: AbstractMesh;
  5165. poleTargetMesh?: AbstractMesh;
  5166. poleTargetBone?: Bone;
  5167. poleTargetLocalOffset?: Vector3;
  5168. poleAngle?: number;
  5169. bendAxis?: Vector3;
  5170. maxAngle?: number;
  5171. slerpAmount?: number;
  5172. });
  5173. private _setMaxAngle(ang);
  5174. /**
  5175. * Force the controller to update the bones
  5176. */
  5177. update(): void;
  5178. }
  5179. }
  5180. declare module BABYLON {
  5181. /**
  5182. * Class used to make a bone look toward a point in space
  5183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5184. */
  5185. class BoneLookController {
  5186. private static _tmpVecs;
  5187. private static _tmpQuat;
  5188. private static _tmpMats;
  5189. /**
  5190. * The target Vector3 that the bone will look at
  5191. */
  5192. target: Vector3;
  5193. /**
  5194. * The mesh that the bone is attached to
  5195. */
  5196. mesh: AbstractMesh;
  5197. /**
  5198. * The bone that will be looking to the target
  5199. */
  5200. bone: Bone;
  5201. /**
  5202. * The up axis of the coordinate system that is used when the bone is rotated
  5203. */
  5204. upAxis: Vector3;
  5205. /**
  5206. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5207. */
  5208. upAxisSpace: Space;
  5209. /**
  5210. * Used to make an adjustment to the yaw of the bone
  5211. */
  5212. adjustYaw: number;
  5213. /**
  5214. * Used to make an adjustment to the pitch of the bone
  5215. */
  5216. adjustPitch: number;
  5217. /**
  5218. * Used to make an adjustment to the roll of the bone
  5219. */
  5220. adjustRoll: number;
  5221. /**
  5222. * 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)
  5223. */
  5224. slerpAmount: number;
  5225. private _minYaw;
  5226. private _maxYaw;
  5227. private _minPitch;
  5228. private _maxPitch;
  5229. private _minYawSin;
  5230. private _minYawCos;
  5231. private _maxYawSin;
  5232. private _maxYawCos;
  5233. private _midYawConstraint;
  5234. private _minPitchTan;
  5235. private _maxPitchTan;
  5236. private _boneQuat;
  5237. private _slerping;
  5238. private _transformYawPitch;
  5239. private _transformYawPitchInv;
  5240. private _firstFrameSkipped;
  5241. private _yawRange;
  5242. private _fowardAxis;
  5243. /**
  5244. * Gets or sets the minimum yaw angle that the bone can look to
  5245. */
  5246. minYaw: number;
  5247. /**
  5248. * Gets or sets the maximum yaw angle that the bone can look to
  5249. */
  5250. maxYaw: number;
  5251. /**
  5252. * Gets or sets the minimum pitch angle that the bone can look to
  5253. */
  5254. minPitch: number;
  5255. /**
  5256. * Gets or sets the maximum pitch angle that the bone can look to
  5257. */
  5258. maxPitch: number;
  5259. /**
  5260. * Create a BoneLookController
  5261. * @param mesh the mesh that the bone belongs to
  5262. * @param bone the bone that will be looking to the target
  5263. * @param target the target Vector3 to look at
  5264. * @param settings optional settings:
  5265. * * maxYaw: the maximum angle the bone will yaw to
  5266. * * minYaw: the minimum angle the bone will yaw to
  5267. * * maxPitch: the maximum angle the bone will pitch to
  5268. * * minPitch: the minimum angle the bone will yaw to
  5269. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5270. * * upAxis: the up axis of the coordinate system
  5271. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5272. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5273. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5274. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5275. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5276. * * adjustRoll: used to make an adjustment to the roll of the bone
  5277. **/
  5278. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5279. maxYaw?: number;
  5280. minYaw?: number;
  5281. maxPitch?: number;
  5282. minPitch?: number;
  5283. slerpAmount?: number;
  5284. upAxis?: Vector3;
  5285. upAxisSpace?: Space;
  5286. yawAxis?: Vector3;
  5287. pitchAxis?: Vector3;
  5288. adjustYaw?: number;
  5289. adjustPitch?: number;
  5290. adjustRoll?: number;
  5291. });
  5292. /**
  5293. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5294. */
  5295. update(): void;
  5296. private _getAngleDiff(ang1, ang2);
  5297. private _getAngleBetween(ang1, ang2);
  5298. private _isAngleBetween(ang, ang1, ang2);
  5299. }
  5300. }
  5301. declare module BABYLON {
  5302. /**
  5303. * Class used to handle skinning animations
  5304. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5305. */
  5306. class Skeleton implements IAnimatable {
  5307. /** defines the skeleton name */
  5308. name: string;
  5309. /** defines the skeleton Id */
  5310. id: string;
  5311. /**
  5312. * Gets the list of child bones
  5313. */
  5314. bones: Bone[];
  5315. /**
  5316. * Gets an estimate of the dimension of the skeleton at rest
  5317. */
  5318. dimensionsAtRest: Vector3;
  5319. /**
  5320. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5321. */
  5322. needInitialSkinMatrix: boolean;
  5323. /**
  5324. * Gets the list of animations attached to this skeleton
  5325. */
  5326. animations: Array<Animation>;
  5327. private _scene;
  5328. private _isDirty;
  5329. private _transformMatrices;
  5330. private _meshesWithPoseMatrix;
  5331. private _animatables;
  5332. private _identity;
  5333. private _synchronizedWithMesh;
  5334. private _ranges;
  5335. private _lastAbsoluteTransformsUpdateId;
  5336. /**
  5337. * Specifies if the skeleton should be serialized
  5338. */
  5339. doNotSerialize: boolean;
  5340. private _animationPropertiesOverride;
  5341. /**
  5342. * Gets or sets the animation properties override
  5343. */
  5344. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5345. /**
  5346. * An observable triggered before computing the skeleton's matrices
  5347. */
  5348. onBeforeComputeObservable: Observable<Skeleton>;
  5349. /**
  5350. * Creates a new skeleton
  5351. * @param name defines the skeleton name
  5352. * @param id defines the skeleton Id
  5353. * @param scene defines the hosting scene
  5354. */
  5355. constructor(
  5356. /** defines the skeleton name */
  5357. name: string,
  5358. /** defines the skeleton Id */
  5359. id: string, scene: Scene);
  5360. /**
  5361. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5362. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5363. * @returns a Float32Array containing matrices data
  5364. */
  5365. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5366. /**
  5367. * Gets the current hosting scene
  5368. * @returns a scene object
  5369. */
  5370. getScene(): Scene;
  5371. /**
  5372. * Gets a string representing the current skeleton data
  5373. * @param fullDetails defines a boolean indicating if we want a verbose version
  5374. * @returns a string representing the current skeleton data
  5375. */
  5376. toString(fullDetails?: boolean): string;
  5377. /**
  5378. * Get bone's index searching by name
  5379. * @param name defines bone's name to search for
  5380. * @return the indice of the bone. Returns -1 if not found
  5381. */
  5382. getBoneIndexByName(name: string): number;
  5383. /**
  5384. * Creater a new animation range
  5385. * @param name defines the name of the range
  5386. * @param from defines the start key
  5387. * @param to defines the end key
  5388. */
  5389. createAnimationRange(name: string, from: number, to: number): void;
  5390. /**
  5391. * Delete a specific animation range
  5392. * @param name defines the name of the range
  5393. * @param deleteFrames defines if frames must be removed as well
  5394. */
  5395. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5396. /**
  5397. * Gets a specific animation range
  5398. * @param name defines the name of the range to look for
  5399. * @returns the requested animation range or null if not found
  5400. */
  5401. getAnimationRange(name: string): Nullable<AnimationRange>;
  5402. /**
  5403. * Gets the list of all animation ranges defined on this skeleton
  5404. * @returns an array
  5405. */
  5406. getAnimationRanges(): Nullable<AnimationRange>[];
  5407. /**
  5408. * Copy animation range from a source skeleton.
  5409. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5410. * @param source defines the source skeleton
  5411. * @param name defines the name of the range to copy
  5412. * @param rescaleAsRequired defines if rescaling must be applied if required
  5413. * @returns true if operation was successful
  5414. */
  5415. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5416. /**
  5417. * Forces the skeleton to go to rest pose
  5418. */
  5419. returnToRest(): void;
  5420. private _getHighestAnimationFrame();
  5421. /**
  5422. * Begin a specific animation range
  5423. * @param name defines the name of the range to start
  5424. * @param loop defines if looping must be turned on (false by default)
  5425. * @param speedRatio defines the speed ratio to apply (1 by default)
  5426. * @param onAnimationEnd defines a callback which will be called when animation will end
  5427. * @returns a new animatable
  5428. */
  5429. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5430. /** @hidden */
  5431. _markAsDirty(): void;
  5432. /** @hidden */
  5433. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5434. /** @hidden */
  5435. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5436. /** @hidden */
  5437. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5438. /**
  5439. * Build all resources required to render a skeleton
  5440. */
  5441. prepare(): void;
  5442. /**
  5443. * Gets the list of animatables currently running for this skeleton
  5444. * @returns an array of animatables
  5445. */
  5446. getAnimatables(): IAnimatable[];
  5447. /**
  5448. * Clone the current skeleton
  5449. * @param name defines the name of the new skeleton
  5450. * @param id defines the id of the enw skeleton
  5451. * @returns the new skeleton
  5452. */
  5453. clone(name: string, id: string): Skeleton;
  5454. /**
  5455. * Enable animation blending for this skeleton
  5456. * @param blendingSpeed defines the blending speed to apply
  5457. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5458. */
  5459. enableBlending(blendingSpeed?: number): void;
  5460. /**
  5461. * Releases all resources associated with the current skeleton
  5462. */
  5463. dispose(): void;
  5464. /**
  5465. * Serialize the skeleton in a JSON object
  5466. * @returns a JSON object
  5467. */
  5468. serialize(): any;
  5469. /**
  5470. * Creates a new skeleton from serialized data
  5471. * @param parsedSkeleton defines the serialized data
  5472. * @param scene defines the hosting scene
  5473. * @returns a new skeleton
  5474. */
  5475. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5476. /**
  5477. * Compute all node absolute transforms
  5478. * @param forceUpdate defines if computation must be done even if cache is up to date
  5479. */
  5480. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5481. /**
  5482. * Gets the root pose matrix
  5483. * @returns a matrix
  5484. */
  5485. getPoseMatrix(): Nullable<Matrix>;
  5486. /**
  5487. * Sorts bones per internal index
  5488. */
  5489. sortBones(): void;
  5490. private _sortBones(index, bones, visited);
  5491. }
  5492. }
  5493. declare module BABYLON {
  5494. class ArcRotateCamera extends TargetCamera {
  5495. alpha: number;
  5496. beta: number;
  5497. radius: number;
  5498. protected _target: Vector3;
  5499. protected _targetHost: Nullable<AbstractMesh>;
  5500. target: Vector3;
  5501. inertialAlphaOffset: number;
  5502. inertialBetaOffset: number;
  5503. inertialRadiusOffset: number;
  5504. lowerAlphaLimit: Nullable<number>;
  5505. upperAlphaLimit: Nullable<number>;
  5506. lowerBetaLimit: number;
  5507. upperBetaLimit: number;
  5508. lowerRadiusLimit: Nullable<number>;
  5509. upperRadiusLimit: Nullable<number>;
  5510. inertialPanningX: number;
  5511. inertialPanningY: number;
  5512. pinchToPanMaxDistance: number;
  5513. panningDistanceLimit: Nullable<number>;
  5514. panningOriginTarget: Vector3;
  5515. panningInertia: number;
  5516. angularSensibilityX: number;
  5517. angularSensibilityY: number;
  5518. pinchPrecision: number;
  5519. pinchDeltaPercentage: number;
  5520. panningSensibility: number;
  5521. keysUp: number[];
  5522. keysDown: number[];
  5523. keysLeft: number[];
  5524. keysRight: number[];
  5525. wheelPrecision: number;
  5526. wheelDeltaPercentage: number;
  5527. zoomOnFactor: number;
  5528. targetScreenOffset: Vector2;
  5529. allowUpsideDown: boolean;
  5530. _viewMatrix: Matrix;
  5531. _useCtrlForPanning: boolean;
  5532. _panningMouseButton: number;
  5533. inputs: ArcRotateCameraInputsManager;
  5534. _reset: () => void;
  5535. panningAxis: Vector3;
  5536. protected _localDirection: Vector3;
  5537. protected _transformedDirection: Vector3;
  5538. private _bouncingBehavior;
  5539. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5540. useBouncingBehavior: boolean;
  5541. private _framingBehavior;
  5542. readonly framingBehavior: Nullable<FramingBehavior>;
  5543. useFramingBehavior: boolean;
  5544. private _autoRotationBehavior;
  5545. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5546. useAutoRotationBehavior: boolean;
  5547. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5548. onCollide: (collidedMesh: AbstractMesh) => void;
  5549. checkCollisions: boolean;
  5550. collisionRadius: Vector3;
  5551. protected _collider: Collider;
  5552. protected _previousPosition: Vector3;
  5553. protected _collisionVelocity: Vector3;
  5554. protected _newPosition: Vector3;
  5555. protected _previousAlpha: number;
  5556. protected _previousBeta: number;
  5557. protected _previousRadius: number;
  5558. protected _collisionTriggered: boolean;
  5559. protected _targetBoundingCenter: Nullable<Vector3>;
  5560. private _computationVector;
  5561. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5562. _initCache(): void;
  5563. _updateCache(ignoreParentClass?: boolean): void;
  5564. protected _getTargetPosition(): Vector3;
  5565. /**
  5566. * Store current camera state (fov, position, etc..)
  5567. */
  5568. private _storedAlpha;
  5569. private _storedBeta;
  5570. private _storedRadius;
  5571. private _storedTarget;
  5572. storeState(): Camera;
  5573. /**
  5574. * Restored camera state. You must call storeState() first
  5575. */
  5576. _restoreStateValues(): boolean;
  5577. _isSynchronizedViewMatrix(): boolean;
  5578. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5579. detachControl(element: HTMLElement): void;
  5580. _checkInputs(): void;
  5581. protected _checkLimits(): void;
  5582. rebuildAnglesAndRadius(): void;
  5583. setPosition(position: Vector3): void;
  5584. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5585. _getViewMatrix(): Matrix;
  5586. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5587. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5588. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5589. min: Vector3;
  5590. max: Vector3;
  5591. distance: number;
  5592. }, doNotUpdateMaxZ?: boolean): void;
  5593. /**
  5594. * @override
  5595. * Override Camera.createRigCamera
  5596. */
  5597. createRigCamera(name: string, cameraIndex: number): Camera;
  5598. /**
  5599. * @override
  5600. * Override Camera._updateRigCameras
  5601. */
  5602. _updateRigCameras(): void;
  5603. dispose(): void;
  5604. getClassName(): string;
  5605. }
  5606. }
  5607. declare module BABYLON {
  5608. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5609. constructor(camera: ArcRotateCamera);
  5610. addMouseWheel(): ArcRotateCameraInputsManager;
  5611. addPointers(): ArcRotateCameraInputsManager;
  5612. addKeyboard(): ArcRotateCameraInputsManager;
  5613. addGamepad(): ArcRotateCameraInputsManager;
  5614. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5615. }
  5616. }
  5617. declare module BABYLON {
  5618. class Camera extends Node {
  5619. inputs: CameraInputsManager<Camera>;
  5620. private static _PERSPECTIVE_CAMERA;
  5621. private static _ORTHOGRAPHIC_CAMERA;
  5622. private static _FOVMODE_VERTICAL_FIXED;
  5623. private static _FOVMODE_HORIZONTAL_FIXED;
  5624. private static _RIG_MODE_NONE;
  5625. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5626. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5627. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5628. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5629. private static _RIG_MODE_VR;
  5630. private static _RIG_MODE_WEBVR;
  5631. static readonly PERSPECTIVE_CAMERA: number;
  5632. static readonly ORTHOGRAPHIC_CAMERA: number;
  5633. /**
  5634. * This is the default FOV mode for perspective cameras.
  5635. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5636. *
  5637. */
  5638. static readonly FOVMODE_VERTICAL_FIXED: number;
  5639. /**
  5640. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5641. *
  5642. */
  5643. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5644. static readonly RIG_MODE_NONE: number;
  5645. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5646. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5647. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5648. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5649. static readonly RIG_MODE_VR: number;
  5650. static readonly RIG_MODE_WEBVR: number;
  5651. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5652. static UseAlternateWebVRRendering: boolean;
  5653. position: Vector3;
  5654. /**
  5655. * The vector the camera should consider as up.
  5656. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5657. */
  5658. upVector: Vector3;
  5659. orthoLeft: Nullable<number>;
  5660. orthoRight: Nullable<number>;
  5661. orthoBottom: Nullable<number>;
  5662. orthoTop: Nullable<number>;
  5663. /**
  5664. * FOV is set in Radians. (default is 0.8)
  5665. */
  5666. fov: number;
  5667. minZ: number;
  5668. maxZ: number;
  5669. inertia: number;
  5670. mode: number;
  5671. isIntermediate: boolean;
  5672. viewport: Viewport;
  5673. /**
  5674. * Restricts the camera to viewing objects with the same layerMask.
  5675. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5676. */
  5677. layerMask: number;
  5678. /**
  5679. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5680. */
  5681. fovMode: number;
  5682. cameraRigMode: number;
  5683. interaxialDistance: number;
  5684. isStereoscopicSideBySide: boolean;
  5685. _cameraRigParams: any;
  5686. _rigCameras: Camera[];
  5687. _rigPostProcess: Nullable<PostProcess>;
  5688. protected _webvrViewMatrix: Matrix;
  5689. _skipRendering: boolean;
  5690. _alternateCamera: Camera;
  5691. customRenderTargets: RenderTargetTexture[];
  5692. onViewMatrixChangedObservable: Observable<Camera>;
  5693. onProjectionMatrixChangedObservable: Observable<Camera>;
  5694. onAfterCheckInputsObservable: Observable<Camera>;
  5695. onRestoreStateObservable: Observable<Camera>;
  5696. private _computedViewMatrix;
  5697. _projectionMatrix: Matrix;
  5698. private _doNotComputeProjectionMatrix;
  5699. private _worldMatrix;
  5700. _postProcesses: Nullable<PostProcess>[];
  5701. private _transformMatrix;
  5702. _activeMeshes: SmartArray<AbstractMesh>;
  5703. protected _globalPosition: Vector3;
  5704. private _frustumPlanes;
  5705. private _refreshFrustumPlanes;
  5706. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5707. private _storedFov;
  5708. private _stateStored;
  5709. /**
  5710. * Store current camera state (fov, position, etc..)
  5711. */
  5712. storeState(): Camera;
  5713. /**
  5714. * Restores the camera state values if it has been stored. You must call storeState() first
  5715. */
  5716. protected _restoreStateValues(): boolean;
  5717. /**
  5718. * Restored camera state. You must call storeState() first
  5719. */
  5720. restoreState(): boolean;
  5721. getClassName(): string;
  5722. /**
  5723. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5724. */
  5725. toString(fullDetails?: boolean): string;
  5726. readonly globalPosition: Vector3;
  5727. getActiveMeshes(): SmartArray<AbstractMesh>;
  5728. isActiveMesh(mesh: Mesh): boolean;
  5729. /**
  5730. * Is this camera ready to be used/rendered
  5731. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5732. * @return true if the camera is ready
  5733. */
  5734. isReady(completeCheck?: boolean): boolean;
  5735. _initCache(): void;
  5736. _updateCache(ignoreParentClass?: boolean): void;
  5737. _isSynchronized(): boolean;
  5738. _isSynchronizedViewMatrix(): boolean;
  5739. _isSynchronizedProjectionMatrix(): boolean;
  5740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5741. detachControl(element: HTMLElement): void;
  5742. update(): void;
  5743. _checkInputs(): void;
  5744. readonly rigCameras: Camera[];
  5745. readonly rigPostProcess: Nullable<PostProcess>;
  5746. /**
  5747. * Internal, gets the first post proces.
  5748. * @returns the first post process to be run on this camera.
  5749. */
  5750. _getFirstPostProcess(): Nullable<PostProcess>;
  5751. private _cascadePostProcessesToRigCams();
  5752. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5753. detachPostProcess(postProcess: PostProcess): void;
  5754. getWorldMatrix(): Matrix;
  5755. _getViewMatrix(): Matrix;
  5756. getViewMatrix(force?: boolean): Matrix;
  5757. freezeProjectionMatrix(projection?: Matrix): void;
  5758. unfreezeProjectionMatrix(): void;
  5759. getProjectionMatrix(force?: boolean): Matrix;
  5760. getTranformationMatrix(): Matrix;
  5761. private updateFrustumPlanes();
  5762. isInFrustum(target: ICullable): boolean;
  5763. isCompletelyInFrustum(target: ICullable): boolean;
  5764. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5765. /**
  5766. * Releases resources associated with this node.
  5767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5769. */
  5770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5771. readonly leftCamera: Nullable<FreeCamera>;
  5772. readonly rightCamera: Nullable<FreeCamera>;
  5773. getLeftTarget(): Nullable<Vector3>;
  5774. getRightTarget(): Nullable<Vector3>;
  5775. setCameraRigMode(mode: number, rigParams: any): void;
  5776. private _getVRProjectionMatrix();
  5777. protected _updateCameraRotationMatrix(): void;
  5778. protected _updateWebVRCameraRotationMatrix(): void;
  5779. /**
  5780. * This function MUST be overwritten by the different WebVR cameras available.
  5781. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5782. */
  5783. protected _getWebVRProjectionMatrix(): Matrix;
  5784. /**
  5785. * This function MUST be overwritten by the different WebVR cameras available.
  5786. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5787. */
  5788. protected _getWebVRViewMatrix(): Matrix;
  5789. setCameraRigParameter(name: string, value: any): void;
  5790. /**
  5791. * needs to be overridden by children so sub has required properties to be copied
  5792. */
  5793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5794. /**
  5795. * May need to be overridden by children
  5796. */
  5797. _updateRigCameras(): void;
  5798. _setupInputs(): void;
  5799. serialize(): any;
  5800. clone(name: string): Camera;
  5801. getDirection(localAxis: Vector3): Vector3;
  5802. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5803. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5804. computeWorldMatrix(): Matrix;
  5805. static Parse(parsedCamera: any, scene: Scene): Camera;
  5806. }
  5807. }
  5808. declare module BABYLON {
  5809. var CameraInputTypes: {};
  5810. interface ICameraInput<TCamera extends Camera> {
  5811. camera: Nullable<TCamera>;
  5812. getClassName(): string;
  5813. getSimpleName(): string;
  5814. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5815. detachControl: (element: Nullable<HTMLElement>) => void;
  5816. checkInputs?: () => void;
  5817. }
  5818. interface CameraInputsMap<TCamera extends Camera> {
  5819. [name: string]: ICameraInput<TCamera>;
  5820. [idx: number]: ICameraInput<TCamera>;
  5821. }
  5822. class CameraInputsManager<TCamera extends Camera> {
  5823. attached: CameraInputsMap<TCamera>;
  5824. attachedElement: Nullable<HTMLElement>;
  5825. noPreventDefault: boolean;
  5826. camera: TCamera;
  5827. checkInputs: () => void;
  5828. constructor(camera: TCamera);
  5829. /**
  5830. * Add an input method to a camera.
  5831. * builtin inputs example: camera.inputs.addGamepad();
  5832. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5833. * @param input camera input method
  5834. */
  5835. add(input: ICameraInput<TCamera>): void;
  5836. /**
  5837. * Remove a specific input method from a camera
  5838. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5839. * @param inputToRemove camera input method
  5840. */
  5841. remove(inputToRemove: ICameraInput<TCamera>): void;
  5842. removeByType(inputType: string): void;
  5843. private _addCheckInputs(fn);
  5844. attachInput(input: ICameraInput<TCamera>): void;
  5845. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5846. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5847. rebuildInputCheck(): void;
  5848. /**
  5849. * Remove all attached input methods from a camera
  5850. */
  5851. clear(): void;
  5852. serialize(serializedCamera: any): void;
  5853. parse(parsedCamera: any): void;
  5854. }
  5855. }
  5856. declare module BABYLON {
  5857. /**
  5858. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5859. * being tilted forward or back and left or right.
  5860. */
  5861. class DeviceOrientationCamera extends FreeCamera {
  5862. private _initialQuaternion;
  5863. private _quaternionCache;
  5864. /**
  5865. * Creates a new device orientation camera
  5866. * @param name The name of the camera
  5867. * @param position The start position camera
  5868. * @param scene The scene the camera belongs to
  5869. */
  5870. constructor(name: string, position: Vector3, scene: Scene);
  5871. /**
  5872. * Gets the current instance class name ("DeviceOrientationCamera").
  5873. * This helps avoiding instanceof at run time.
  5874. * @returns the class name
  5875. */
  5876. getClassName(): string;
  5877. /**
  5878. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5879. */
  5880. _checkInputs(): void;
  5881. /**
  5882. * Reset the camera to its default orientation on the specified axis only.
  5883. * @param axis The axis to reset
  5884. */
  5885. resetToCurrentRotation(axis?: Axis): void;
  5886. }
  5887. }
  5888. declare module BABYLON {
  5889. class FollowCamera extends TargetCamera {
  5890. radius: number;
  5891. rotationOffset: number;
  5892. heightOffset: number;
  5893. cameraAcceleration: number;
  5894. maxCameraSpeed: number;
  5895. lockedTarget: Nullable<AbstractMesh>;
  5896. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5897. private getRadians(degrees);
  5898. private follow(cameraTarget);
  5899. _checkInputs(): void;
  5900. getClassName(): string;
  5901. }
  5902. class ArcFollowCamera extends TargetCamera {
  5903. alpha: number;
  5904. beta: number;
  5905. radius: number;
  5906. target: Nullable<AbstractMesh>;
  5907. private _cartesianCoordinates;
  5908. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5909. private follow();
  5910. _checkInputs(): void;
  5911. getClassName(): string;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. class FreeCamera extends TargetCamera {
  5916. ellipsoid: Vector3;
  5917. ellipsoidOffset: Vector3;
  5918. checkCollisions: boolean;
  5919. applyGravity: boolean;
  5920. inputs: FreeCameraInputsManager;
  5921. /**
  5922. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5923. * Higher values reduce sensitivity.
  5924. */
  5925. /**
  5926. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5927. * Higher values reduce sensitivity.
  5928. */
  5929. angularSensibility: number;
  5930. keysUp: number[];
  5931. keysDown: number[];
  5932. keysLeft: number[];
  5933. keysRight: number[];
  5934. onCollide: (collidedMesh: AbstractMesh) => void;
  5935. private _collider;
  5936. private _needMoveForGravity;
  5937. private _oldPosition;
  5938. private _diffPosition;
  5939. private _newPosition;
  5940. _localDirection: Vector3;
  5941. _transformedDirection: Vector3;
  5942. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5944. detachControl(element: HTMLElement): void;
  5945. private _collisionMask;
  5946. collisionMask: number;
  5947. _collideWithWorld(displacement: Vector3): void;
  5948. private _onCollisionPositionChange;
  5949. _checkInputs(): void;
  5950. _decideIfNeedsToMove(): boolean;
  5951. _updatePosition(): void;
  5952. dispose(): void;
  5953. getClassName(): string;
  5954. }
  5955. }
  5956. declare module BABYLON {
  5957. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5958. constructor(camera: FreeCamera);
  5959. addKeyboard(): FreeCameraInputsManager;
  5960. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5961. addGamepad(): FreeCameraInputsManager;
  5962. addDeviceOrientation(): FreeCameraInputsManager;
  5963. addTouch(): FreeCameraInputsManager;
  5964. addVirtualJoystick(): FreeCameraInputsManager;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. class GamepadCamera extends UniversalCamera {
  5969. gamepadAngularSensibility: number;
  5970. gamepadMoveSensibility: number;
  5971. constructor(name: string, position: Vector3, scene: Scene);
  5972. getClassName(): string;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  5978. */
  5979. class AnaglyphFreeCamera extends FreeCamera {
  5980. /**
  5981. * Creates a new AnaglyphFreeCamera
  5982. * @param name defines camera name
  5983. * @param position defines initial position
  5984. * @param interaxialDistance defines distance between each color axis
  5985. * @param scene defines the hosting scene
  5986. */
  5987. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5988. /**
  5989. * Gets camera class name
  5990. * @returns AnaglyphFreeCamera
  5991. */
  5992. getClassName(): string;
  5993. }
  5994. /**
  5995. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  5996. */
  5997. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5998. /**
  5999. * Creates a new AnaglyphArcRotateCamera
  6000. * @param name defines camera name
  6001. * @param alpha defines alpha angle (in radians)
  6002. * @param beta defines beta angle (in radians)
  6003. * @param radius defines radius
  6004. * @param target defines camera target
  6005. * @param interaxialDistance defines distance between each color axis
  6006. * @param scene defines the hosting scene
  6007. */
  6008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6009. /**
  6010. * Gets camera class name
  6011. * @returns AnaglyphArcRotateCamera
  6012. */
  6013. getClassName(): string;
  6014. }
  6015. /**
  6016. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6017. */
  6018. class AnaglyphGamepadCamera extends GamepadCamera {
  6019. /**
  6020. * Creates a new AnaglyphGamepadCamera
  6021. * @param name defines camera name
  6022. * @param position defines initial position
  6023. * @param interaxialDistance defines distance between each color axis
  6024. * @param scene defines the hosting scene
  6025. */
  6026. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6027. /**
  6028. * Gets camera class name
  6029. * @returns AnaglyphGamepadCamera
  6030. */
  6031. getClassName(): string;
  6032. }
  6033. /**
  6034. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6035. */
  6036. class AnaglyphUniversalCamera extends UniversalCamera {
  6037. /**
  6038. * Creates a new AnaglyphUniversalCamera
  6039. * @param name defines camera name
  6040. * @param position defines initial position
  6041. * @param interaxialDistance defines distance between each color axis
  6042. * @param scene defines the hosting scene
  6043. */
  6044. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6045. /**
  6046. * Gets camera class name
  6047. * @returns AnaglyphUniversalCamera
  6048. */
  6049. getClassName(): string;
  6050. }
  6051. /**
  6052. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6053. */
  6054. class StereoscopicFreeCamera extends FreeCamera {
  6055. /**
  6056. * Creates a new StereoscopicFreeCamera
  6057. * @param name defines camera name
  6058. * @param position defines initial position
  6059. * @param interaxialDistance defines distance between each color axis
  6060. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6061. * @param scene defines the hosting scene
  6062. */
  6063. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6064. /**
  6065. * Gets camera class name
  6066. * @returns StereoscopicFreeCamera
  6067. */
  6068. getClassName(): string;
  6069. }
  6070. /**
  6071. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6072. */
  6073. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6074. /**
  6075. * Creates a new StereoscopicArcRotateCamera
  6076. * @param name defines camera name
  6077. * @param alpha defines alpha angle (in radians)
  6078. * @param beta defines beta angle (in radians)
  6079. * @param radius defines radius
  6080. * @param target defines camera target
  6081. * @param interaxialDistance defines distance between each color axis
  6082. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6083. * @param scene defines the hosting scene
  6084. */
  6085. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6086. /**
  6087. * Gets camera class name
  6088. * @returns StereoscopicArcRotateCamera
  6089. */
  6090. getClassName(): string;
  6091. }
  6092. /**
  6093. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6094. */
  6095. class StereoscopicGamepadCamera extends GamepadCamera {
  6096. /**
  6097. * Creates a new StereoscopicGamepadCamera
  6098. * @param name defines camera name
  6099. * @param position defines initial position
  6100. * @param interaxialDistance defines distance between each color axis
  6101. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6102. * @param scene defines the hosting scene
  6103. */
  6104. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6105. /**
  6106. * Gets camera class name
  6107. * @returns StereoscopicGamepadCamera
  6108. */
  6109. getClassName(): string;
  6110. }
  6111. /**
  6112. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6113. */
  6114. class StereoscopicUniversalCamera extends UniversalCamera {
  6115. /**
  6116. * Creates a new StereoscopicUniversalCamera
  6117. * @param name defines camera name
  6118. * @param position defines initial position
  6119. * @param interaxialDistance defines distance between each color axis
  6120. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6121. * @param scene defines the hosting scene
  6122. */
  6123. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6124. /**
  6125. * Gets camera class name
  6126. * @returns StereoscopicUniversalCamera
  6127. */
  6128. getClassName(): string;
  6129. }
  6130. }
  6131. declare module BABYLON {
  6132. class TargetCamera extends Camera {
  6133. cameraDirection: Vector3;
  6134. cameraRotation: Vector2;
  6135. rotation: Vector3;
  6136. rotationQuaternion: Quaternion;
  6137. speed: number;
  6138. noRotationConstraint: boolean;
  6139. lockedTarget: any;
  6140. _currentTarget: Vector3;
  6141. _viewMatrix: Matrix;
  6142. _camMatrix: Matrix;
  6143. _cameraTransformMatrix: Matrix;
  6144. _cameraRotationMatrix: Matrix;
  6145. private _rigCamTransformMatrix;
  6146. _referencePoint: Vector3;
  6147. private _currentUpVector;
  6148. _transformedReferencePoint: Vector3;
  6149. protected _globalCurrentTarget: Vector3;
  6150. protected _globalCurrentUpVector: Vector3;
  6151. _reset: () => void;
  6152. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6153. getFrontPosition(distance: number): Vector3;
  6154. _getLockedTargetPosition(): Nullable<Vector3>;
  6155. /**
  6156. * Store current camera state (fov, position, etc..)
  6157. */
  6158. private _storedPosition;
  6159. private _storedRotation;
  6160. private _storedRotationQuaternion;
  6161. storeState(): Camera;
  6162. /**
  6163. * Restored camera state. You must call storeState() first
  6164. */
  6165. _restoreStateValues(): boolean;
  6166. _initCache(): void;
  6167. _updateCache(ignoreParentClass?: boolean): void;
  6168. _isSynchronizedViewMatrix(): boolean;
  6169. _computeLocalCameraSpeed(): number;
  6170. setTarget(target: Vector3): void;
  6171. /**
  6172. * Return the current target position of the camera. This value is expressed in local space.
  6173. */
  6174. getTarget(): Vector3;
  6175. _decideIfNeedsToMove(): boolean;
  6176. _updatePosition(): void;
  6177. _checkInputs(): void;
  6178. protected _updateCameraRotationMatrix(): void;
  6179. _getViewMatrix(): Matrix;
  6180. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6181. /**
  6182. * @override
  6183. * Override Camera.createRigCamera
  6184. */
  6185. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6186. /**
  6187. * @override
  6188. * Override Camera._updateRigCameras
  6189. */
  6190. _updateRigCameras(): void;
  6191. private _getRigCamPosition(halfSpace, result);
  6192. getClassName(): string;
  6193. }
  6194. }
  6195. declare module BABYLON {
  6196. class TouchCamera extends FreeCamera {
  6197. touchAngularSensibility: number;
  6198. touchMoveSensibility: number;
  6199. constructor(name: string, position: Vector3, scene: Scene);
  6200. getClassName(): string;
  6201. _setupInputs(): void;
  6202. }
  6203. }
  6204. declare module BABYLON {
  6205. class UniversalCamera extends TouchCamera {
  6206. gamepadAngularSensibility: number;
  6207. gamepadMoveSensibility: number;
  6208. constructor(name: string, position: Vector3, scene: Scene);
  6209. getClassName(): string;
  6210. }
  6211. }
  6212. declare module BABYLON {
  6213. class VirtualJoysticksCamera extends FreeCamera {
  6214. constructor(name: string, position: Vector3, scene: Scene);
  6215. getClassName(): string;
  6216. }
  6217. }
  6218. interface VRDisplay extends EventTarget {
  6219. /**
  6220. * Dictionary of capabilities describing the VRDisplay.
  6221. */
  6222. readonly capabilities: VRDisplayCapabilities;
  6223. /**
  6224. * z-depth defining the far plane of the eye view frustum
  6225. * enables mapping of values in the render target depth
  6226. * attachment to scene coordinates. Initially set to 10000.0.
  6227. */
  6228. depthFar: number;
  6229. /**
  6230. * z-depth defining the near plane of the eye view frustum
  6231. * enables mapping of values in the render target depth
  6232. * attachment to scene coordinates. Initially set to 0.01.
  6233. */
  6234. depthNear: number;
  6235. /**
  6236. * An identifier for this distinct VRDisplay. Used as an
  6237. * association point in the Gamepad API.
  6238. */
  6239. readonly displayId: number;
  6240. /**
  6241. * A display name, a user-readable name identifying it.
  6242. */
  6243. readonly displayName: string;
  6244. readonly isConnected: boolean;
  6245. readonly isPresenting: boolean;
  6246. /**
  6247. * If this VRDisplay supports room-scale experiences, the optional
  6248. * stage attribute contains details on the room-scale parameters.
  6249. */
  6250. readonly stageParameters: VRStageParameters | null;
  6251. /**
  6252. * Passing the value returned by `requestAnimationFrame` to
  6253. * `cancelAnimationFrame` will unregister the callback.
  6254. */
  6255. cancelAnimationFrame(handle: number): void;
  6256. /**
  6257. * Stops presenting to the VRDisplay.
  6258. */
  6259. exitPresent(): Promise<void>;
  6260. getEyeParameters(whichEye: string): VREyeParameters;
  6261. /**
  6262. * Populates the passed VRFrameData with the information required to render
  6263. * the current frame.
  6264. */
  6265. getFrameData(frameData: VRFrameData): boolean;
  6266. /**
  6267. * Get the layers currently being presented.
  6268. */
  6269. getLayers(): VRLayer[];
  6270. /**
  6271. * Return a VRPose containing the future predicted pose of the VRDisplay
  6272. * when the current frame will be presented. The value returned will not
  6273. * change until JavaScript has returned control to the browser.
  6274. *
  6275. * The VRPose will contain the position, orientation, velocity,
  6276. * and acceleration of each of these properties.
  6277. */
  6278. getPose(): VRPose;
  6279. /**
  6280. * Return the current instantaneous pose of the VRDisplay, with no
  6281. * prediction applied.
  6282. */
  6283. getImmediatePose(): VRPose;
  6284. /**
  6285. * The callback passed to `requestAnimationFrame` will be called
  6286. * any time a new frame should be rendered. When the VRDisplay is
  6287. * presenting the callback will be called at the native refresh
  6288. * rate of the HMD. When not presenting this function acts
  6289. * identically to how window.requestAnimationFrame acts. Content should
  6290. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6291. * asynchronously from other displays and at differing refresh rates.
  6292. */
  6293. requestAnimationFrame(callback: FrameRequestCallback): number;
  6294. /**
  6295. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6296. * Repeat calls while already presenting will update the VRLayers being displayed.
  6297. */
  6298. requestPresent(layers: VRLayer[]): Promise<void>;
  6299. /**
  6300. * Reset the pose for this display, treating its current position and
  6301. * orientation as the "origin/zero" values. VRPose.position,
  6302. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6303. * updated when calling resetPose(). This should be called in only
  6304. * sitting-space experiences.
  6305. */
  6306. resetPose(): void;
  6307. /**
  6308. * The VRLayer provided to the VRDisplay will be captured and presented
  6309. * in the HMD. Calling this function has the same effect on the source
  6310. * canvas as any other operation that uses its source image, and canvases
  6311. * created without preserveDrawingBuffer set to true will be cleared.
  6312. */
  6313. submitFrame(pose?: VRPose): void;
  6314. }
  6315. declare var VRDisplay: {
  6316. prototype: VRDisplay;
  6317. new (): VRDisplay;
  6318. };
  6319. interface VRLayer {
  6320. leftBounds?: number[] | null;
  6321. rightBounds?: number[] | null;
  6322. source?: HTMLCanvasElement | null;
  6323. }
  6324. interface VRDisplayCapabilities {
  6325. readonly canPresent: boolean;
  6326. readonly hasExternalDisplay: boolean;
  6327. readonly hasOrientation: boolean;
  6328. readonly hasPosition: boolean;
  6329. readonly maxLayers: number;
  6330. }
  6331. interface VREyeParameters {
  6332. /** @deprecated */
  6333. readonly fieldOfView: VRFieldOfView;
  6334. readonly offset: Float32Array;
  6335. readonly renderHeight: number;
  6336. readonly renderWidth: number;
  6337. }
  6338. interface VRFieldOfView {
  6339. readonly downDegrees: number;
  6340. readonly leftDegrees: number;
  6341. readonly rightDegrees: number;
  6342. readonly upDegrees: number;
  6343. }
  6344. interface VRFrameData {
  6345. readonly leftProjectionMatrix: Float32Array;
  6346. readonly leftViewMatrix: Float32Array;
  6347. readonly pose: VRPose;
  6348. readonly rightProjectionMatrix: Float32Array;
  6349. readonly rightViewMatrix: Float32Array;
  6350. readonly timestamp: number;
  6351. }
  6352. interface VRPose {
  6353. readonly angularAcceleration: Float32Array | null;
  6354. readonly angularVelocity: Float32Array | null;
  6355. readonly linearAcceleration: Float32Array | null;
  6356. readonly linearVelocity: Float32Array | null;
  6357. readonly orientation: Float32Array | null;
  6358. readonly position: Float32Array | null;
  6359. readonly timestamp: number;
  6360. }
  6361. interface VRStageParameters {
  6362. sittingToStandingTransform?: Float32Array;
  6363. sizeX?: number;
  6364. sizeY?: number;
  6365. }
  6366. interface Navigator {
  6367. getVRDisplays(): Promise<VRDisplay[]>;
  6368. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6369. }
  6370. interface Window {
  6371. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6372. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6373. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6374. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6375. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6376. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6377. }
  6378. interface Gamepad {
  6379. readonly displayId: number;
  6380. }
  6381. declare module BABYLON {
  6382. class BoundingBox implements ICullable {
  6383. vectors: Vector3[];
  6384. center: Vector3;
  6385. centerWorld: Vector3;
  6386. extendSize: Vector3;
  6387. extendSizeWorld: Vector3;
  6388. directions: Vector3[];
  6389. vectorsWorld: Vector3[];
  6390. minimumWorld: Vector3;
  6391. maximumWorld: Vector3;
  6392. minimum: Vector3;
  6393. maximum: Vector3;
  6394. private _worldMatrix;
  6395. /**
  6396. * Creates a new bounding box
  6397. * @param min defines the minimum vector (in local space)
  6398. * @param max defines the maximum vector (in local space)
  6399. */
  6400. constructor(min: Vector3, max: Vector3);
  6401. /**
  6402. * Recreates the entire bounding box from scratch
  6403. * @param min defines the new minimum vector (in local space)
  6404. * @param max defines the new maximum vector (in local space)
  6405. */
  6406. reConstruct(min: Vector3, max: Vector3): void;
  6407. getWorldMatrix(): Matrix;
  6408. setWorldMatrix(matrix: Matrix): BoundingBox;
  6409. _update(world: Matrix): void;
  6410. isInFrustum(frustumPlanes: Plane[]): boolean;
  6411. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6412. intersectsPoint(point: Vector3): boolean;
  6413. intersectsSphere(sphere: BoundingSphere): boolean;
  6414. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6415. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6416. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6417. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6418. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6419. }
  6420. }
  6421. declare module BABYLON {
  6422. interface ICullable {
  6423. isInFrustum(frustumPlanes: Plane[]): boolean;
  6424. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6425. }
  6426. class BoundingInfo implements ICullable {
  6427. minimum: Vector3;
  6428. maximum: Vector3;
  6429. boundingBox: BoundingBox;
  6430. boundingSphere: BoundingSphere;
  6431. private _isLocked;
  6432. constructor(minimum: Vector3, maximum: Vector3);
  6433. isLocked: boolean;
  6434. update(world: Matrix): void;
  6435. /**
  6436. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6437. * @param center New center of the bounding info
  6438. * @param extend New extend of the bounding info
  6439. */
  6440. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6441. isInFrustum(frustumPlanes: Plane[]): boolean;
  6442. /**
  6443. * Gets the world distance between the min and max points of the bounding box
  6444. */
  6445. readonly diagonalLength: number;
  6446. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6447. _checkCollision(collider: Collider): boolean;
  6448. intersectsPoint(point: Vector3): boolean;
  6449. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6450. }
  6451. }
  6452. declare module BABYLON {
  6453. class BoundingSphere {
  6454. center: Vector3;
  6455. radius: number;
  6456. centerWorld: Vector3;
  6457. radiusWorld: number;
  6458. minimum: Vector3;
  6459. maximum: Vector3;
  6460. private _tempRadiusVector;
  6461. /**
  6462. * Creates a new bounding sphere
  6463. * @param min defines the minimum vector (in local space)
  6464. * @param max defines the maximum vector (in local space)
  6465. */
  6466. constructor(min: Vector3, max: Vector3);
  6467. /**
  6468. * Recreates the entire bounding sphere from scratch
  6469. * @param min defines the new minimum vector (in local space)
  6470. * @param max defines the new maximum vector (in local space)
  6471. */
  6472. reConstruct(min: Vector3, max: Vector3): void;
  6473. _update(world: Matrix): void;
  6474. isInFrustum(frustumPlanes: Plane[]): boolean;
  6475. intersectsPoint(point: Vector3): boolean;
  6476. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6477. }
  6478. }
  6479. declare module BABYLON {
  6480. class Ray {
  6481. origin: Vector3;
  6482. direction: Vector3;
  6483. length: number;
  6484. private _edge1;
  6485. private _edge2;
  6486. private _pvec;
  6487. private _tvec;
  6488. private _qvec;
  6489. private _tmpRay;
  6490. constructor(origin: Vector3, direction: Vector3, length?: number);
  6491. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6492. intersectsBox(box: BoundingBox): boolean;
  6493. intersectsSphere(sphere: BoundingSphere): boolean;
  6494. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6495. intersectsPlane(plane: Plane): Nullable<number>;
  6496. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6497. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6498. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6499. private static smallnum;
  6500. private static rayl;
  6501. /**
  6502. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6503. * @param sega the first point of the segment to test the intersection against
  6504. * @param segb the second point of the segment to test the intersection against
  6505. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6506. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6507. */
  6508. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6510. static Zero(): Ray;
  6511. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6512. /**
  6513. * 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
  6514. * transformed to the given world matrix.
  6515. * @param origin The origin point
  6516. * @param end The end point
  6517. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6518. */
  6519. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6520. static Transform(ray: Ray, matrix: Matrix): Ray;
  6521. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6522. }
  6523. }
  6524. /**
  6525. * Module Debug contains the (visual) components to debug a scene correctly
  6526. */
  6527. declare module BABYLON.Debug {
  6528. /**
  6529. * The Axes viewer will show 3 axes in a specific point in space
  6530. */
  6531. class AxesViewer {
  6532. private _xline;
  6533. private _yline;
  6534. private _zline;
  6535. private _xmesh;
  6536. private _ymesh;
  6537. private _zmesh;
  6538. /**
  6539. * Gets the hosting scene
  6540. */
  6541. scene: Nullable<Scene>;
  6542. /**
  6543. * Gets or sets a number used to scale line length
  6544. */
  6545. scaleLines: number;
  6546. /**
  6547. * Creates a new AxesViewer
  6548. * @param scene defines the hosting scene
  6549. * @param scaleLines defines a number used to scale line length (1 by default)
  6550. */
  6551. constructor(scene: Scene, scaleLines?: number);
  6552. /**
  6553. * Force the viewer to update
  6554. * @param position defines the position of the viewer
  6555. * @param xaxis defines the x axis of the viewer
  6556. * @param yaxis defines the y axis of the viewer
  6557. * @param zaxis defines the z axis of the viewer
  6558. */
  6559. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6560. /** Releases resources */
  6561. dispose(): void;
  6562. }
  6563. }
  6564. declare module BABYLON.Debug {
  6565. /**
  6566. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6567. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6568. */
  6569. class BoneAxesViewer extends AxesViewer {
  6570. /**
  6571. * Gets or sets the target mesh where to display the axes viewer
  6572. */
  6573. mesh: Nullable<Mesh>;
  6574. /**
  6575. * Gets or sets the target bone where to display the axes viewer
  6576. */
  6577. bone: Nullable<Bone>;
  6578. /** Gets current position */
  6579. pos: Vector3;
  6580. /** Gets direction of X axis */
  6581. xaxis: Vector3;
  6582. /** Gets direction of Y axis */
  6583. yaxis: Vector3;
  6584. /** Gets direction of Z axis */
  6585. zaxis: Vector3;
  6586. /**
  6587. * Creates a new BoneAxesViewer
  6588. * @param scene defines the hosting scene
  6589. * @param bone defines the target bone
  6590. * @param mesh defines the target mesh
  6591. * @param scaleLines defines a scaling factor for line length (1 by default)
  6592. */
  6593. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6594. /**
  6595. * Force the viewer to update
  6596. */
  6597. update(): void;
  6598. /** Releases resources */
  6599. dispose(): void;
  6600. }
  6601. }
  6602. declare module BABYLON {
  6603. class DebugLayer {
  6604. private _scene;
  6605. static InspectorURL: string;
  6606. private _inspector;
  6607. private BJSINSPECTOR;
  6608. onPropertyChangedObservable: BABYLON.Observable<{
  6609. object: any;
  6610. property: string;
  6611. value: any;
  6612. initialValue: any;
  6613. }>;
  6614. constructor(scene: Scene);
  6615. /** Creates the inspector window. */
  6616. private _createInspector(config?);
  6617. isVisible(): boolean;
  6618. hide(): void;
  6619. /**
  6620. *
  6621. * Launch the debugLayer.
  6622. *
  6623. * initialTab:
  6624. * | Value | Tab Name |
  6625. * | --- | --- |
  6626. * | 0 | Scene |
  6627. * | 1 | Console |
  6628. * | 2 | Stats |
  6629. * | 3 | Textures |
  6630. * | 4 | Mesh |
  6631. * | 5 | Light |
  6632. * | 6 | Material |
  6633. * | 7 | GLTF |
  6634. * | 8 | GUI |
  6635. * | 9 | Physics |
  6636. * | 10 | Camera |
  6637. * | 11 | Audio |
  6638. *
  6639. */
  6640. show(config?: {
  6641. popup?: boolean;
  6642. initialTab?: number;
  6643. parentElement?: HTMLElement;
  6644. newColors?: {
  6645. backgroundColor?: string;
  6646. backgroundColorLighter?: string;
  6647. backgroundColorLighter2?: string;
  6648. backgroundColorLighter3?: string;
  6649. color?: string;
  6650. colorTop?: string;
  6651. colorBot?: string;
  6652. };
  6653. }): void;
  6654. /**
  6655. * Gets the active tab
  6656. * @return the index of the active tab or -1 if the inspector is hidden
  6657. */
  6658. getActiveTab(): number;
  6659. }
  6660. }
  6661. declare module BABYLON.Debug {
  6662. /**
  6663. * Used to show the physics impostor around the specific mesh
  6664. */
  6665. class PhysicsViewer {
  6666. /** @hidden */
  6667. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6668. /** @hidden */
  6669. protected _meshes: Array<Nullable<AbstractMesh>>;
  6670. /** @hidden */
  6671. protected _scene: Nullable<Scene>;
  6672. /** @hidden */
  6673. protected _numMeshes: number;
  6674. /** @hidden */
  6675. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6676. private _renderFunction;
  6677. private _debugBoxMesh;
  6678. private _debugSphereMesh;
  6679. private _debugMaterial;
  6680. /**
  6681. * Creates a new PhysicsViewer
  6682. * @param scene defines the hosting scene
  6683. */
  6684. constructor(scene: Scene);
  6685. /** @hidden */
  6686. protected _updateDebugMeshes(): void;
  6687. /**
  6688. * Renders a specified physic impostor
  6689. * @param impostor defines the impostor to render
  6690. */
  6691. showImpostor(impostor: PhysicsImpostor): void;
  6692. /**
  6693. * Hides a specified physic impostor
  6694. * @param impostor defines the impostor to hide
  6695. */
  6696. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6697. private _getDebugMaterial(scene);
  6698. private _getDebugBoxMesh(scene);
  6699. private _getDebugSphereMesh(scene);
  6700. private _getDebugMesh(impostor, scene);
  6701. /** Releases all resources */
  6702. dispose(): void;
  6703. }
  6704. }
  6705. declare module BABYLON {
  6706. class RayHelper {
  6707. ray: Nullable<Ray>;
  6708. private _renderPoints;
  6709. private _renderLine;
  6710. private _renderFunction;
  6711. private _scene;
  6712. private _updateToMeshFunction;
  6713. private _attachedToMesh;
  6714. private _meshSpaceDirection;
  6715. private _meshSpaceOrigin;
  6716. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6717. constructor(ray: Ray);
  6718. show(scene: Scene, color?: Color3): void;
  6719. hide(): void;
  6720. private _render();
  6721. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6722. detachFromMesh(): void;
  6723. private _updateToMesh();
  6724. dispose(): void;
  6725. }
  6726. }
  6727. declare module BABYLON.Debug {
  6728. /**
  6729. * Class used to render a debug view of a given skeleton
  6730. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6731. */
  6732. class SkeletonViewer {
  6733. /** defines the skeleton to render */
  6734. skeleton: Skeleton;
  6735. /** defines the mesh attached to the skeleton */
  6736. mesh: AbstractMesh;
  6737. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6738. autoUpdateBonesMatrices: boolean;
  6739. /** defines the rendering group id to use with the viewer */
  6740. renderingGroupId: number;
  6741. /** Gets or sets the color used to render the skeleton */
  6742. color: Color3;
  6743. private _scene;
  6744. private _debugLines;
  6745. private _debugMesh;
  6746. private _isEnabled;
  6747. private _renderFunction;
  6748. /**
  6749. * Creates a new SkeletonViewer
  6750. * @param skeleton defines the skeleton to render
  6751. * @param mesh defines the mesh attached to the skeleton
  6752. * @param scene defines the hosting scene
  6753. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6754. * @param renderingGroupId defines the rendering group id to use with the viewer
  6755. */
  6756. constructor(
  6757. /** defines the skeleton to render */
  6758. skeleton: Skeleton,
  6759. /** defines the mesh attached to the skeleton */
  6760. mesh: AbstractMesh, scene: Scene,
  6761. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6762. autoUpdateBonesMatrices?: boolean,
  6763. /** defines the rendering group id to use with the viewer */
  6764. renderingGroupId?: number);
  6765. /** Gets or sets a boolean indicating if the viewer is enabled */
  6766. isEnabled: boolean;
  6767. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6768. private _getLinesForBonesWithLength(bones, meshMat);
  6769. private _getLinesForBonesNoLength(bones, meshMat);
  6770. /** Update the viewer to sync with current skeleton state */
  6771. update(): void;
  6772. /** Release associated resources */
  6773. dispose(): void;
  6774. }
  6775. }
  6776. declare module BABYLON {
  6777. /**
  6778. * Interface for attribute information associated with buffer instanciation
  6779. */
  6780. class InstancingAttributeInfo {
  6781. /**
  6782. * Index/offset of the attribute in the vertex shader
  6783. */
  6784. index: number;
  6785. /**
  6786. * size of the attribute, 1, 2, 3 or 4
  6787. */
  6788. attributeSize: number;
  6789. /**
  6790. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6791. * default is FLOAT
  6792. */
  6793. attribyteType: number;
  6794. /**
  6795. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6796. */
  6797. normalized: boolean;
  6798. /**
  6799. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6800. */
  6801. offset: number;
  6802. /**
  6803. * Name of the GLSL attribute, for debugging purpose only
  6804. */
  6805. attributeName: string;
  6806. }
  6807. /**
  6808. * Define options used to create a render target texture
  6809. */
  6810. class RenderTargetCreationOptions {
  6811. /**
  6812. * Specifies is mipmaps must be generated
  6813. */
  6814. generateMipMaps?: boolean;
  6815. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6816. generateDepthBuffer?: boolean;
  6817. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6818. generateStencilBuffer?: boolean;
  6819. /** Defines texture type (int by default) */
  6820. type?: number;
  6821. /** Defines sampling mode (trilinear by default) */
  6822. samplingMode?: number;
  6823. /** Defines format (RGBA by default) */
  6824. format?: number;
  6825. }
  6826. /**
  6827. * Define options used to create a depth texture
  6828. */
  6829. class DepthTextureCreationOptions {
  6830. /** Specifies whether or not a stencil should be allocated in the texture */
  6831. generateStencil?: boolean;
  6832. /** Specifies whether or not bilinear filtering is enable on the texture */
  6833. bilinearFiltering?: boolean;
  6834. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6835. comparisonFunction?: number;
  6836. /** Specifies if the created texture is a cube texture */
  6837. isCube?: boolean;
  6838. }
  6839. /**
  6840. * Class used to describe the capabilities of the engine relatively to the current browser
  6841. */
  6842. class EngineCapabilities {
  6843. /** Maximum textures units per fragment shader */
  6844. maxTexturesImageUnits: number;
  6845. /** Maximum texture units per vertex shader */
  6846. maxVertexTextureImageUnits: number;
  6847. /** Maximum textures units in the entire pipeline */
  6848. maxCombinedTexturesImageUnits: number;
  6849. /** Maximum texture size */
  6850. maxTextureSize: number;
  6851. /** Maximum cube texture size */
  6852. maxCubemapTextureSize: number;
  6853. /** Maximum render texture size */
  6854. maxRenderTextureSize: number;
  6855. /** Maximum number of vertex attributes */
  6856. maxVertexAttribs: number;
  6857. /** Maximum number of varyings */
  6858. maxVaryingVectors: number;
  6859. /** Maximum number of uniforms per vertex shader */
  6860. maxVertexUniformVectors: number;
  6861. /** Maximum number of uniforms per fragment shader */
  6862. maxFragmentUniformVectors: number;
  6863. /** Defines if standard derivates (dx/dy) are supported */
  6864. standardDerivatives: boolean;
  6865. /** Defines if s3tc texture compression is supported */
  6866. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6867. /** Defines if pvrtc texture compression is supported */
  6868. pvrtc: any;
  6869. /** Defines if etc1 texture compression is supported */
  6870. etc1: any;
  6871. /** Defines if etc2 texture compression is supported */
  6872. etc2: any;
  6873. /** Defines if astc texture compression is supported */
  6874. astc: any;
  6875. /** Defines if float textures are supported */
  6876. textureFloat: boolean;
  6877. /** Defines if vertex array objects are supported */
  6878. vertexArrayObject: boolean;
  6879. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6880. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6881. /** Gets the maximum level of anisotropy supported */
  6882. maxAnisotropy: number;
  6883. /** Defines if instancing is supported */
  6884. instancedArrays: boolean;
  6885. /** Defines if 32 bits indices are supported */
  6886. uintIndices: boolean;
  6887. /** Defines if high precision shaders are supported */
  6888. highPrecisionShaderSupported: boolean;
  6889. /** Defines if depth reading in the fragment shader is supported */
  6890. fragmentDepthSupported: boolean;
  6891. /** Defines if float texture linear filtering is supported*/
  6892. textureFloatLinearFiltering: boolean;
  6893. /** Defines if rendering to float textures is supported */
  6894. textureFloatRender: boolean;
  6895. /** Defines if half float textures are supported*/
  6896. textureHalfFloat: boolean;
  6897. /** Defines if half float texture linear filtering is supported*/
  6898. textureHalfFloatLinearFiltering: boolean;
  6899. /** Defines if rendering to half float textures is supported */
  6900. textureHalfFloatRender: boolean;
  6901. /** Defines if textureLOD shader command is supported */
  6902. textureLOD: boolean;
  6903. /** Defines if draw buffers extension is supported */
  6904. drawBuffersExtension: boolean;
  6905. /** Defines if depth textures are supported */
  6906. depthTextureExtension: boolean;
  6907. /** Defines if float color buffer are supported */
  6908. colorBufferFloat: boolean;
  6909. /** Gets disjoint timer query extension (null if not supported) */
  6910. timerQuery: EXT_disjoint_timer_query;
  6911. /** Defines if timestamp can be used with timer query */
  6912. canUseTimestampForTimerQuery: boolean;
  6913. }
  6914. /** Interface defining initialization parameters for Engine class */
  6915. interface EngineOptions extends WebGLContextAttributes {
  6916. /**
  6917. * Defines if the engine should no exceed a specified device ratio
  6918. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6919. */
  6920. limitDeviceRatio?: number;
  6921. /**
  6922. * Defines if webvr should be enabled automatically
  6923. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6924. */
  6925. autoEnableWebVR?: boolean;
  6926. /**
  6927. * Defines if webgl2 should be turned off even if supported
  6928. * @see http://doc.babylonjs.com/features/webgl2
  6929. */
  6930. disableWebGL2Support?: boolean;
  6931. /**
  6932. * Defines if webaudio should be initialized as well
  6933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6934. */
  6935. audioEngine?: boolean;
  6936. /**
  6937. * Defines if animations should run using a deterministic lock step
  6938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6939. */
  6940. deterministicLockstep?: boolean;
  6941. /** Defines the maximum steps to use with deterministic lock step mode */
  6942. lockstepMaxSteps?: number;
  6943. /**
  6944. * Defines that engine should ignore context lost events
  6945. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6946. */
  6947. doNotHandleContextLost?: boolean;
  6948. }
  6949. /**
  6950. * Defines the interface used by display changed events
  6951. */
  6952. interface IDisplayChangedEventArgs {
  6953. /** Gets the vrDisplay object (if any) */
  6954. vrDisplay: Nullable<any>;
  6955. /** Gets a boolean indicating if webVR is supported */
  6956. vrSupported: boolean;
  6957. }
  6958. /**
  6959. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6960. */
  6961. class Engine {
  6962. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6963. static ExceptionList: ({
  6964. key: string;
  6965. capture: string;
  6966. captureConstraint: number;
  6967. targets: string[];
  6968. } | {
  6969. key: string;
  6970. capture: null;
  6971. captureConstraint: null;
  6972. targets: string[];
  6973. })[];
  6974. /** Gets the list of created engines */
  6975. static Instances: Engine[];
  6976. /**
  6977. * Gets the latest created engine
  6978. */
  6979. static readonly LastCreatedEngine: Nullable<Engine>;
  6980. /**
  6981. * Gets the latest created scene
  6982. */
  6983. static readonly LastCreatedScene: Nullable<Scene>;
  6984. /**
  6985. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6986. * @param flag defines which part of the materials must be marked as dirty
  6987. * @param predicate defines a predicate used to filter which materials should be affected
  6988. */
  6989. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6990. private static _ALPHA_DISABLE;
  6991. private static _ALPHA_ADD;
  6992. private static _ALPHA_COMBINE;
  6993. private static _ALPHA_SUBTRACT;
  6994. private static _ALPHA_MULTIPLY;
  6995. private static _ALPHA_MAXIMIZED;
  6996. private static _ALPHA_ONEONE;
  6997. private static _ALPHA_PREMULTIPLIED;
  6998. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6999. private static _ALPHA_INTERPOLATE;
  7000. private static _ALPHA_SCREENMODE;
  7001. private static _DELAYLOADSTATE_NONE;
  7002. private static _DELAYLOADSTATE_LOADED;
  7003. private static _DELAYLOADSTATE_LOADING;
  7004. private static _DELAYLOADSTATE_NOTLOADED;
  7005. private static _TEXTUREFORMAT_ALPHA;
  7006. private static _TEXTUREFORMAT_LUMINANCE;
  7007. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7008. private static _TEXTUREFORMAT_RGB;
  7009. private static _TEXTUREFORMAT_RGBA;
  7010. private static _TEXTUREFORMAT_R;
  7011. private static _TEXTUREFORMAT_RG;
  7012. private static _TEXTURETYPE_UNSIGNED_INT;
  7013. private static _TEXTURETYPE_FLOAT;
  7014. private static _TEXTURETYPE_HALF_FLOAT;
  7015. private static _NEVER;
  7016. private static _ALWAYS;
  7017. private static _LESS;
  7018. private static _EQUAL;
  7019. private static _LEQUAL;
  7020. private static _GREATER;
  7021. private static _GEQUAL;
  7022. private static _NOTEQUAL;
  7023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7024. static readonly NEVER: number;
  7025. /** 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 */
  7026. static readonly ALWAYS: number;
  7027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7028. static readonly LESS: number;
  7029. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7030. static readonly EQUAL: number;
  7031. /** 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 */
  7032. static readonly LEQUAL: number;
  7033. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7034. static readonly GREATER: number;
  7035. /** 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 */
  7036. static readonly GEQUAL: number;
  7037. /** 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 */
  7038. static readonly NOTEQUAL: number;
  7039. private static _KEEP;
  7040. private static _REPLACE;
  7041. private static _INCR;
  7042. private static _DECR;
  7043. private static _INVERT;
  7044. private static _INCR_WRAP;
  7045. private static _DECR_WRAP;
  7046. /** Passed to stencilOperation to specify that stencil value must be kept */
  7047. static readonly KEEP: number;
  7048. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7049. static readonly REPLACE: number;
  7050. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7051. static readonly INCR: number;
  7052. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7053. static readonly DECR: number;
  7054. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7055. static readonly INVERT: number;
  7056. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7057. static readonly INCR_WRAP: number;
  7058. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7059. static readonly DECR_WRAP: number;
  7060. /** Defines that alpha blending is disabled */
  7061. static readonly ALPHA_DISABLE: number;
  7062. /** Defines that alpha blending to SRC + DEST */
  7063. static readonly ALPHA_ONEONE: number;
  7064. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7065. static readonly ALPHA_ADD: number;
  7066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7067. static readonly ALPHA_COMBINE: number;
  7068. /** Defines that alpha blending to DEST - SRC * DEST */
  7069. static readonly ALPHA_SUBTRACT: number;
  7070. /** Defines that alpha blending to SRC * DEST */
  7071. static readonly ALPHA_MULTIPLY: number;
  7072. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7073. static readonly ALPHA_MAXIMIZED: number;
  7074. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7075. static readonly ALPHA_PREMULTIPLIED: number;
  7076. /**
  7077. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7078. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7079. */
  7080. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7081. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7082. static readonly ALPHA_INTERPOLATE: number;
  7083. /**
  7084. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7085. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7086. */
  7087. static readonly ALPHA_SCREENMODE: number;
  7088. /** Defines that the ressource is not delayed*/
  7089. static readonly DELAYLOADSTATE_NONE: number;
  7090. /** Defines that the ressource was successfully delay loaded */
  7091. static readonly DELAYLOADSTATE_LOADED: number;
  7092. /** Defines that the ressource is currently delay loading */
  7093. static readonly DELAYLOADSTATE_LOADING: number;
  7094. /** Defines that the ressource is delayed and has not started loading */
  7095. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7096. /** ALPHA */
  7097. static readonly TEXTUREFORMAT_ALPHA: number;
  7098. /** LUMINANCE */
  7099. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7100. /**
  7101. * R
  7102. */
  7103. static readonly TEXTUREFORMAT_R: number;
  7104. /**
  7105. * RG
  7106. */
  7107. static readonly TEXTUREFORMAT_RG: number;
  7108. /** LUMINANCE_ALPHA */
  7109. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7110. /** RGB */
  7111. static readonly TEXTUREFORMAT_RGB: number;
  7112. /** RGBA */
  7113. static readonly TEXTUREFORMAT_RGBA: number;
  7114. /** UNSIGNED_INT */
  7115. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7116. /** FLOAT */
  7117. static readonly TEXTURETYPE_FLOAT: number;
  7118. /** HALF_FLOAT */
  7119. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7120. private static _SCALEMODE_FLOOR;
  7121. private static _SCALEMODE_NEAREST;
  7122. private static _SCALEMODE_CEILING;
  7123. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7124. static readonly SCALEMODE_FLOOR: number;
  7125. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7126. static readonly SCALEMODE_NEAREST: number;
  7127. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7128. static readonly SCALEMODE_CEILING: number;
  7129. /**
  7130. * Returns the current version of the framework
  7131. */
  7132. static readonly Version: string;
  7133. /**
  7134. * Gets or sets the epsilon value used by collision engine
  7135. */
  7136. static CollisionsEpsilon: number;
  7137. /**
  7138. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7139. */
  7140. static CodeRepository: string;
  7141. /**
  7142. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7143. */
  7144. static ShadersRepository: string;
  7145. /**
  7146. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7147. */
  7148. forcePOTTextures: boolean;
  7149. /**
  7150. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7151. */
  7152. isFullscreen: boolean;
  7153. /**
  7154. * Gets a boolean indicating if the pointer is currently locked
  7155. */
  7156. isPointerLock: boolean;
  7157. /**
  7158. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7159. */
  7160. cullBackFaces: boolean;
  7161. /**
  7162. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7163. */
  7164. renderEvenInBackground: boolean;
  7165. /**
  7166. * Gets or sets a boolean indicating that cache can be kept between frames
  7167. */
  7168. preventCacheWipeBetweenFrames: boolean;
  7169. /**
  7170. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7171. **/
  7172. enableOfflineSupport: boolean;
  7173. /**
  7174. * 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)
  7175. **/
  7176. disableManifestCheck: boolean;
  7177. /**
  7178. * Gets the list of created scenes
  7179. */
  7180. scenes: Scene[];
  7181. /**
  7182. * Gets the list of created postprocesses
  7183. */
  7184. postProcesses: PostProcess[];
  7185. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7186. validateShaderPrograms: boolean;
  7187. /**
  7188. * Observable event triggered each time the rendering canvas is resized
  7189. */
  7190. onResizeObservable: Observable<Engine>;
  7191. /**
  7192. * Observable event triggered each time the canvas loses focus
  7193. */
  7194. onCanvasBlurObservable: Observable<Engine>;
  7195. /**
  7196. * Observable event triggered each time the canvas gains focus
  7197. */
  7198. onCanvasFocusObservable: Observable<Engine>;
  7199. /**
  7200. * Observable event triggered each time the canvas receives pointerout event
  7201. */
  7202. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7203. /**
  7204. * Observable event triggered before each texture is initialized
  7205. */
  7206. onBeforeTextureInitObservable: Observable<Texture>;
  7207. private _vrDisplay;
  7208. private _vrSupported;
  7209. private _oldSize;
  7210. private _oldHardwareScaleFactor;
  7211. private _vrExclusivePointerMode;
  7212. private _webVRInitPromise;
  7213. /**
  7214. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7215. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7216. */
  7217. readonly isInVRExclusivePointerMode: boolean;
  7218. /**
  7219. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7220. */
  7221. disableUniformBuffers: boolean;
  7222. /** @hidden */
  7223. _uniformBuffers: UniformBuffer[];
  7224. /**
  7225. * Gets a boolean indicating that the engine supports uniform buffers
  7226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7227. */
  7228. readonly supportsUniformBuffers: boolean;
  7229. /**
  7230. * Observable raised when the engine begins a new frame
  7231. */
  7232. onBeginFrameObservable: Observable<Engine>;
  7233. /**
  7234. * Observable raised when the engine ends the current frame
  7235. */
  7236. onEndFrameObservable: Observable<Engine>;
  7237. /**
  7238. * Observable raised when the engine is about to compile a shader
  7239. */
  7240. onBeforeShaderCompilationObservable: Observable<Engine>;
  7241. /**
  7242. * Observable raised when the engine has jsut compiled a shader
  7243. */
  7244. onAfterShaderCompilationObservable: Observable<Engine>;
  7245. private _gl;
  7246. private _renderingCanvas;
  7247. private _windowIsBackground;
  7248. private _webGLVersion;
  7249. /**
  7250. * Gets a boolean indicating that only power of 2 textures are supported
  7251. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7252. */
  7253. readonly needPOTTextures: boolean;
  7254. /** @hidden */
  7255. _badOS: boolean;
  7256. /** @hidden */
  7257. _badDesktopOS: boolean;
  7258. /**
  7259. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7260. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7261. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7262. */
  7263. disableTextureBindingOptimization: boolean;
  7264. /**
  7265. * Gets the audio engine
  7266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7267. * @ignorenaming
  7268. */
  7269. static audioEngine: AudioEngine;
  7270. private _onFocus;
  7271. private _onBlur;
  7272. private _onCanvasPointerOut;
  7273. private _onCanvasBlur;
  7274. private _onCanvasFocus;
  7275. private _onFullscreenChange;
  7276. private _onPointerLockChange;
  7277. private _onVRDisplayPointerRestricted;
  7278. private _onVRDisplayPointerUnrestricted;
  7279. private _onVrDisplayConnect;
  7280. private _onVrDisplayDisconnect;
  7281. private _onVrDisplayPresentChange;
  7282. /**
  7283. * Observable signaled when VR display mode changes
  7284. */
  7285. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7286. /**
  7287. * Observable signaled when VR request present is complete
  7288. */
  7289. onVRRequestPresentComplete: Observable<boolean>;
  7290. /**
  7291. * Observable signaled when VR request present starts
  7292. */
  7293. onVRRequestPresentStart: Observable<Engine>;
  7294. private _hardwareScalingLevel;
  7295. /** @hidden */
  7296. protected _caps: EngineCapabilities;
  7297. private _pointerLockRequested;
  7298. private _isStencilEnable;
  7299. private _colorWrite;
  7300. private _loadingScreen;
  7301. /** @hidden */
  7302. _drawCalls: PerfCounter;
  7303. /** @hidden */
  7304. _textureCollisions: PerfCounter;
  7305. private _glVersion;
  7306. private _glRenderer;
  7307. private _glVendor;
  7308. private _videoTextureSupported;
  7309. private _renderingQueueLaunched;
  7310. private _activeRenderLoops;
  7311. private _deterministicLockstep;
  7312. private _lockstepMaxSteps;
  7313. /**
  7314. * Observable signaled when a context lost event is raised
  7315. */
  7316. onContextLostObservable: Observable<Engine>;
  7317. /**
  7318. * Observable signaled when a context restored event is raised
  7319. */
  7320. onContextRestoredObservable: Observable<Engine>;
  7321. private _onContextLost;
  7322. private _onContextRestored;
  7323. private _contextWasLost;
  7324. private _doNotHandleContextLost;
  7325. /**
  7326. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7328. */
  7329. doNotHandleContextLost: boolean;
  7330. private _performanceMonitor;
  7331. private _fps;
  7332. private _deltaTime;
  7333. /**
  7334. * Turn this value on if you want to pause FPS computation when in background
  7335. */
  7336. disablePerformanceMonitorInBackground: boolean;
  7337. /**
  7338. * Gets the performance monitor attached to this engine
  7339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7340. */
  7341. readonly performanceMonitor: PerformanceMonitor;
  7342. /** @hidden */
  7343. protected _depthCullingState: _DepthCullingState;
  7344. /** @hidden */
  7345. protected _stencilState: _StencilState;
  7346. /** @hidden */
  7347. protected _alphaState: _AlphaState;
  7348. /** @hidden */
  7349. protected _alphaMode: number;
  7350. protected _internalTexturesCache: InternalTexture[];
  7351. /** @hidden */
  7352. protected _activeChannel: number;
  7353. private _currentTextureChannel;
  7354. /** @hidden */
  7355. protected _boundTexturesCache: {
  7356. [key: string]: Nullable<InternalTexture>;
  7357. };
  7358. /** @hidden */
  7359. protected _currentEffect: Nullable<Effect>;
  7360. /** @hidden */
  7361. protected _currentProgram: Nullable<WebGLProgram>;
  7362. private _compiledEffects;
  7363. private _vertexAttribArraysEnabled;
  7364. /** @hidden */
  7365. protected _cachedViewport: Nullable<Viewport>;
  7366. private _cachedVertexArrayObject;
  7367. /** @hidden */
  7368. protected _cachedVertexBuffers: any;
  7369. /** @hidden */
  7370. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7371. /** @hidden */
  7372. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7373. /** @hidden */
  7374. protected _currentRenderTarget: Nullable<InternalTexture>;
  7375. private _uintIndicesCurrentlySet;
  7376. private _currentBoundBuffer;
  7377. /** @hidden */
  7378. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7379. private _currentBufferPointers;
  7380. private _currentInstanceLocations;
  7381. private _currentInstanceBuffers;
  7382. private _textureUnits;
  7383. private _firstBoundInternalTextureTracker;
  7384. private _lastBoundInternalTextureTracker;
  7385. private _workingCanvas;
  7386. private _workingContext;
  7387. private _rescalePostProcess;
  7388. private _dummyFramebuffer;
  7389. private _externalData;
  7390. private _bindedRenderFunction;
  7391. private _vaoRecordInProgress;
  7392. private _mustWipeVertexAttributes;
  7393. private _emptyTexture;
  7394. private _emptyCubeTexture;
  7395. private _emptyTexture3D;
  7396. private _frameHandler;
  7397. private _nextFreeTextureSlots;
  7398. private _maxSimultaneousTextures;
  7399. private _activeRequests;
  7400. private _texturesSupported;
  7401. private _textureFormatInUse;
  7402. /**
  7403. * Gets the list of texture formats supported
  7404. */
  7405. readonly texturesSupported: Array<string>;
  7406. /**
  7407. * Gets the list of texture formats in use
  7408. */
  7409. readonly textureFormatInUse: Nullable<string>;
  7410. /**
  7411. * Gets the current viewport
  7412. */
  7413. readonly currentViewport: Nullable<Viewport>;
  7414. /**
  7415. * Gets the default empty texture
  7416. */
  7417. readonly emptyTexture: InternalTexture;
  7418. /**
  7419. * Gets the default empty 3D texture
  7420. */
  7421. readonly emptyTexture3D: InternalTexture;
  7422. /**
  7423. * Gets the default empty cube texture
  7424. */
  7425. readonly emptyCubeTexture: InternalTexture;
  7426. /**
  7427. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7428. */
  7429. readonly premultipliedAlpha: boolean;
  7430. /**
  7431. * Creates a new engine
  7432. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7433. * @param antialias defines enable antialiasing (default: false)
  7434. * @param options defines further options to be sent to the getContext() function
  7435. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7436. */
  7437. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7438. private _rebuildInternalTextures();
  7439. private _rebuildEffects();
  7440. private _rebuildBuffers();
  7441. private _initGLContext();
  7442. /**
  7443. * Gets version of the current webGL context
  7444. */
  7445. readonly webGLVersion: number;
  7446. /**
  7447. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7448. */
  7449. readonly isStencilEnable: boolean;
  7450. private _prepareWorkingCanvas();
  7451. /**
  7452. * Reset the texture cache to empty state
  7453. */
  7454. resetTextureCache(): void;
  7455. /**
  7456. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7458. * @returns true if engine is in deterministic lock step mode
  7459. */
  7460. isDeterministicLockStep(): boolean;
  7461. /**
  7462. * Gets the max steps when engine is running in deterministic lock step
  7463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7464. * @returns the max steps
  7465. */
  7466. getLockstepMaxSteps(): number;
  7467. /**
  7468. * Gets an object containing information about the current webGL context
  7469. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7470. */
  7471. getGlInfo(): {
  7472. vendor: string;
  7473. renderer: string;
  7474. version: string;
  7475. };
  7476. /**
  7477. * Gets current aspect ratio
  7478. * @param camera defines the camera to use to get the aspect ratio
  7479. * @param useScreen defines if screen size must be used (or the current render target if any)
  7480. * @returns a number defining the aspect ratio
  7481. */
  7482. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7483. /**
  7484. * Gets current screen aspect ratio
  7485. * @returns a number defining the aspect ratio
  7486. */
  7487. getScreenAspectRatio(): number;
  7488. /**
  7489. * Gets the current render width
  7490. * @param useScreen defines if screen size must be used (or the current render target if any)
  7491. * @returns a number defining the current render width
  7492. */
  7493. getRenderWidth(useScreen?: boolean): number;
  7494. /**
  7495. * Gets the current render height
  7496. * @param useScreen defines if screen size must be used (or the current render target if any)
  7497. * @returns a number defining the current render height
  7498. */
  7499. getRenderHeight(useScreen?: boolean): number;
  7500. /**
  7501. * Gets the HTML canvas attached with the current webGL context
  7502. * @returns a HTML canvas
  7503. */
  7504. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7505. /**
  7506. * Gets the client rect of the HTML canvas attached with the current webGL context
  7507. * @returns a client rectanglee
  7508. */
  7509. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7510. /**
  7511. * Defines the hardware scaling level.
  7512. * By default the hardware scaling level is computed from the window device ratio.
  7513. * 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.
  7514. * @param level defines the level to use
  7515. */
  7516. setHardwareScalingLevel(level: number): void;
  7517. /**
  7518. * Gets the current hardware scaling level.
  7519. * By default the hardware scaling level is computed from the window device ratio.
  7520. * 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.
  7521. * @returns a number indicating the current hardware scaling level
  7522. */
  7523. getHardwareScalingLevel(): number;
  7524. /**
  7525. * Gets the list of loaded textures
  7526. * @returns an array containing all loaded textures
  7527. */
  7528. getLoadedTexturesCache(): InternalTexture[];
  7529. /**
  7530. * Gets the object containing all engine capabilities
  7531. * @returns the EngineCapabilities object
  7532. */
  7533. getCaps(): EngineCapabilities;
  7534. /** @hidden */
  7535. readonly drawCalls: number;
  7536. /** @hidden */
  7537. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7538. /**
  7539. * Gets the current depth function
  7540. * @returns a number defining the depth function
  7541. */
  7542. getDepthFunction(): Nullable<number>;
  7543. /**
  7544. * Sets the current depth function
  7545. * @param depthFunc defines the function to use
  7546. */
  7547. setDepthFunction(depthFunc: number): void;
  7548. /**
  7549. * Sets the current depth function to GREATER
  7550. */
  7551. setDepthFunctionToGreater(): void;
  7552. /**
  7553. * Sets the current depth function to GEQUAL
  7554. */
  7555. setDepthFunctionToGreaterOrEqual(): void;
  7556. /**
  7557. * Sets the current depth function to LESS
  7558. */
  7559. setDepthFunctionToLess(): void;
  7560. /**
  7561. * Sets the current depth function to LEQUAL
  7562. */
  7563. setDepthFunctionToLessOrEqual(): void;
  7564. /**
  7565. * Gets a boolean indicating if stencil buffer is enabled
  7566. * @returns the current stencil buffer state
  7567. */
  7568. getStencilBuffer(): boolean;
  7569. /**
  7570. * Enable or disable the stencil buffer
  7571. * @param enable defines if the stencil buffer must be enabled or disabled
  7572. */
  7573. setStencilBuffer(enable: boolean): void;
  7574. /**
  7575. * Gets the current stencil mask
  7576. * @returns a number defining the new stencil mask to use
  7577. */
  7578. getStencilMask(): number;
  7579. /**
  7580. * Sets the current stencil mask
  7581. * @param mask defines the new stencil mask to use
  7582. */
  7583. setStencilMask(mask: number): void;
  7584. /**
  7585. * Gets the current stencil function
  7586. * @returns a number defining the stencil function to use
  7587. */
  7588. getStencilFunction(): number;
  7589. /**
  7590. * Gets the current stencil reference value
  7591. * @returns a number defining the stencil reference value to use
  7592. */
  7593. getStencilFunctionReference(): number;
  7594. /**
  7595. * Gets the current stencil mask
  7596. * @returns a number defining the stencil mask to use
  7597. */
  7598. getStencilFunctionMask(): number;
  7599. /**
  7600. * Sets the current stencil function
  7601. * @param stencilFunc defines the new stencil function to use
  7602. */
  7603. setStencilFunction(stencilFunc: number): void;
  7604. /**
  7605. * Sets the current stencil reference
  7606. * @param reference defines the new stencil reference to use
  7607. */
  7608. setStencilFunctionReference(reference: number): void;
  7609. /**
  7610. * Sets the current stencil mask
  7611. * @param mask defines the new stencil mask to use
  7612. */
  7613. setStencilFunctionMask(mask: number): void;
  7614. /**
  7615. * Gets the current stencil operation when stencil fails
  7616. * @returns a number defining stencil operation to use when stencil fails
  7617. */
  7618. getStencilOperationFail(): number;
  7619. /**
  7620. * Gets the current stencil operation when depth fails
  7621. * @returns a number defining stencil operation to use when depth fails
  7622. */
  7623. getStencilOperationDepthFail(): number;
  7624. /**
  7625. * Gets the current stencil operation when stencil passes
  7626. * @returns a number defining stencil operation to use when stencil passes
  7627. */
  7628. getStencilOperationPass(): number;
  7629. /**
  7630. * Sets the stencil operation to use when stencil fails
  7631. * @param operation defines the stencil operation to use when stencil fails
  7632. */
  7633. setStencilOperationFail(operation: number): void;
  7634. /**
  7635. * Sets the stencil operation to use when depth fails
  7636. * @param operation defines the stencil operation to use when depth fails
  7637. */
  7638. setStencilOperationDepthFail(operation: number): void;
  7639. /**
  7640. * Sets the stencil operation to use when stencil passes
  7641. * @param operation defines the stencil operation to use when stencil passes
  7642. */
  7643. setStencilOperationPass(operation: number): void;
  7644. /**
  7645. * Sets a boolean indicating if the dithering state is enabled or disabled
  7646. * @param value defines the dithering state
  7647. */
  7648. setDitheringState(value: boolean): void;
  7649. /**
  7650. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7651. * @param value defines the rasterizer state
  7652. */
  7653. setRasterizerState(value: boolean): void;
  7654. /**
  7655. * stop executing a render loop function and remove it from the execution array
  7656. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7657. */
  7658. stopRenderLoop(renderFunction?: () => void): void;
  7659. /** @hidden */
  7660. _renderLoop(): void;
  7661. /**
  7662. * Register and execute a render loop. The engine can have more than one render function
  7663. * @param renderFunction defines the function to continuously execute
  7664. */
  7665. runRenderLoop(renderFunction: () => void): void;
  7666. /**
  7667. * Toggle full screen mode
  7668. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7669. * @param options defines an option object to be sent to the requestFullscreen function
  7670. */
  7671. switchFullscreen(requestPointerLock: boolean): void;
  7672. /**
  7673. * Clear the current render buffer or the current render target (if any is set up)
  7674. * @param color defines the color to use
  7675. * @param backBuffer defines if the back buffer must be cleared
  7676. * @param depth defines if the depth buffer must be cleared
  7677. * @param stencil defines if the stencil buffer must be cleared
  7678. */
  7679. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7680. /**
  7681. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7682. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7683. * @param y defines the y-coordinate of the corner of the clear rectangle
  7684. * @param width defines the width of the clear rectangle
  7685. * @param height defines the height of the clear rectangle
  7686. * @param clearColor defines the clear color
  7687. */
  7688. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7689. private _viewportCached;
  7690. /** @hidden */
  7691. _viewport(x: number, y: number, width: number, height: number): void;
  7692. /**
  7693. * Set the WebGL's viewport
  7694. * @param viewport defines the viewport element to be used
  7695. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7696. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7697. */
  7698. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7699. /**
  7700. * Directly set the WebGL Viewport
  7701. * @param x defines the x coordinate of the viewport (in screen space)
  7702. * @param y defines the y coordinate of the viewport (in screen space)
  7703. * @param width defines the width of the viewport (in screen space)
  7704. * @param height defines the height of the viewport (in screen space)
  7705. * @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
  7706. */
  7707. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7708. /**
  7709. * Begin a new frame
  7710. */
  7711. beginFrame(): void;
  7712. /**
  7713. * Enf the current frame
  7714. */
  7715. endFrame(): void;
  7716. /**
  7717. * Resize the view according to the canvas' size
  7718. */
  7719. resize(): void;
  7720. /**
  7721. * Force a specific size of the canvas
  7722. * @param width defines the new canvas' width
  7723. * @param height defines the new canvas' height
  7724. */
  7725. setSize(width: number, height: number): void;
  7726. /**
  7727. * Gets a boolean indicating if a webVR device was detected
  7728. * @returns true if a webVR device was detected
  7729. */
  7730. isVRDevicePresent(): boolean;
  7731. /**
  7732. * Gets the current webVR device
  7733. * @returns the current webVR device (or null)
  7734. */
  7735. getVRDevice(): any;
  7736. /**
  7737. * Initializes a webVR display and starts listening to display change events
  7738. * The onVRDisplayChangedObservable will be notified upon these changes
  7739. * @returns The onVRDisplayChangedObservable
  7740. */
  7741. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7742. /**
  7743. * Initializes a webVR display and starts listening to display change events
  7744. * The onVRDisplayChangedObservable will be notified upon these changes
  7745. * @returns A promise containing a VRDisplay and if vr is supported
  7746. */
  7747. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7748. /**
  7749. * Call this function to switch to webVR mode
  7750. * Will do nothing if webVR is not supported or if there is no webVR device
  7751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7752. */
  7753. enableVR(): void;
  7754. /**
  7755. * Call this function to leave webVR mode
  7756. * Will do nothing if webVR is not supported or if there is no webVR device
  7757. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7758. */
  7759. disableVR(): void;
  7760. private _onVRFullScreenTriggered;
  7761. private _getVRDisplaysAsync();
  7762. /**
  7763. * Binds the frame buffer to the specified texture.
  7764. * @param texture The texture to render to or null for the default canvas
  7765. * @param faceIndex The face of the texture to render to in case of cube texture
  7766. * @param requiredWidth The width of the target to render to
  7767. * @param requiredHeight The height of the target to render to
  7768. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7769. * @param depthStencilTexture The depth stencil texture to use to render
  7770. * @param lodLevel defines le lod level to bind to the frame buffer
  7771. */
  7772. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7773. private bindUnboundFramebuffer(framebuffer);
  7774. /**
  7775. * Unbind the current render target texture from the webGL context
  7776. * @param texture defines the render target texture to unbind
  7777. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7778. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7779. */
  7780. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7781. /**
  7782. * Unbind a list of render target textures from the webGL context
  7783. * This is used only when drawBuffer extension or webGL2 are active
  7784. * @param textures defines the render target textures to unbind
  7785. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7786. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7787. */
  7788. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7789. /**
  7790. * Force the mipmap generation for the given render target texture
  7791. * @param texture defines the render target texture to use
  7792. */
  7793. generateMipMapsForCubemap(texture: InternalTexture): void;
  7794. /**
  7795. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7796. */
  7797. flushFramebuffer(): void;
  7798. /**
  7799. * Unbind the current render target and bind the default framebuffer
  7800. */
  7801. restoreDefaultFramebuffer(): void;
  7802. /**
  7803. * Create an uniform buffer
  7804. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7805. * @param elements defines the content of the uniform buffer
  7806. * @returns the webGL uniform buffer
  7807. */
  7808. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7809. /**
  7810. * Create a dynamic uniform buffer
  7811. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7812. * @param elements defines the content of the uniform buffer
  7813. * @returns the webGL uniform buffer
  7814. */
  7815. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7816. /**
  7817. * Update an existing uniform buffer
  7818. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7819. * @param uniformBuffer defines the target uniform buffer
  7820. * @param elements defines the content to update
  7821. * @param offset defines the offset in the uniform buffer where update should start
  7822. * @param count defines the size of the data to update
  7823. */
  7824. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7825. private _resetVertexBufferBinding();
  7826. /**
  7827. * Creates a vertex buffer
  7828. * @param data the data for the vertex buffer
  7829. * @returns the new WebGL static buffer
  7830. */
  7831. createVertexBuffer(data: DataArray): WebGLBuffer;
  7832. /**
  7833. * Creates a dynamic vertex buffer
  7834. * @param data the data for the dynamic vertex buffer
  7835. * @returns the new WebGL dynamic buffer
  7836. */
  7837. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7838. /**
  7839. * Update a dynamic index buffer
  7840. * @param indexBuffer defines the target index buffer
  7841. * @param indices defines the data to update
  7842. * @param offset defines the offset in the target index buffer where update should start
  7843. */
  7844. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7845. /**
  7846. * Updates a dynamic vertex buffer.
  7847. * @param vertexBuffer the vertex buffer to update
  7848. * @param data the data used to update the vertex buffer
  7849. * @param byteOffset the byte offset of the data
  7850. * @param byteLength the byte length of the data
  7851. */
  7852. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7853. private _resetIndexBufferBinding();
  7854. /**
  7855. * Creates a new index buffer
  7856. * @param indices defines the content of the index buffer
  7857. * @param updatable defines if the index buffer must be updatable
  7858. * @returns a new webGL buffer
  7859. */
  7860. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7861. /**
  7862. * Bind a webGL buffer to the webGL context
  7863. * @param buffer defines the buffer to bind
  7864. */
  7865. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7866. /**
  7867. * Bind an uniform buffer to the current webGL context
  7868. * @param buffer defines the buffer to bind
  7869. */
  7870. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7871. /**
  7872. * Bind a buffer to the current webGL context at a given location
  7873. * @param buffer defines the buffer to bind
  7874. * @param location defines the index where to bind the buffer
  7875. */
  7876. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7877. /**
  7878. * Bind a specific block at a given index in a specific shader program
  7879. * @param shaderProgram defines the shader program
  7880. * @param blockName defines the block name
  7881. * @param index defines the index where to bind the block
  7882. */
  7883. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7884. private bindIndexBuffer(buffer);
  7885. private bindBuffer(buffer, target);
  7886. /**
  7887. * update the bound buffer with the given data
  7888. * @param data defines the data to update
  7889. */
  7890. updateArrayBuffer(data: Float32Array): void;
  7891. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7892. private _bindIndexBufferWithCache(indexBuffer);
  7893. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7894. /**
  7895. * Records a vertex array object
  7896. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7897. * @param vertexBuffers defines the list of vertex buffers to store
  7898. * @param indexBuffer defines the index buffer to store
  7899. * @param effect defines the effect to store
  7900. * @returns the new vertex array object
  7901. */
  7902. recordVertexArrayObject(vertexBuffers: {
  7903. [key: string]: VertexBuffer;
  7904. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7905. /**
  7906. * Bind a specific vertex array object
  7907. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7908. * @param vertexArrayObject defines the vertex array object to bind
  7909. * @param indexBuffer defines the index buffer to bind
  7910. */
  7911. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7912. /**
  7913. * Bind webGl buffers directly to the webGL context
  7914. * @param vertexBuffer defines the vertex buffer to bind
  7915. * @param indexBuffer defines the index buffer to bind
  7916. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7917. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7918. * @param effect defines the effect associated with the vertex buffer
  7919. */
  7920. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7921. private _unbindVertexArrayObject();
  7922. /**
  7923. * Bind a list of vertex buffers to the webGL context
  7924. * @param vertexBuffers defines the list of vertex buffers to bind
  7925. * @param indexBuffer defines the index buffer to bind
  7926. * @param effect defines the effect associated with the vertex buffers
  7927. */
  7928. bindBuffers(vertexBuffers: {
  7929. [key: string]: Nullable<VertexBuffer>;
  7930. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7931. /**
  7932. * Unbind all instance attributes
  7933. */
  7934. unbindInstanceAttributes(): void;
  7935. /**
  7936. * Release and free the memory of a vertex array object
  7937. * @param vao defines the vertex array object to delete
  7938. */
  7939. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7940. /** @hidden */
  7941. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7942. /**
  7943. * Creates a webGL buffer to use with instanciation
  7944. * @param capacity defines the size of the buffer
  7945. * @returns the webGL buffer
  7946. */
  7947. createInstancesBuffer(capacity: number): WebGLBuffer;
  7948. /**
  7949. * Delete a webGL buffer used with instanciation
  7950. * @param buffer defines the webGL buffer to delete
  7951. */
  7952. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7953. /**
  7954. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7955. * @param instancesBuffer defines the webGL buffer to update and bind
  7956. * @param data defines the data to store in the buffer
  7957. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7958. */
  7959. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7960. /**
  7961. * Apply all cached states (depth, culling, stencil and alpha)
  7962. */
  7963. applyStates(): void;
  7964. /**
  7965. * Send a draw order
  7966. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7967. * @param indexStart defines the starting index
  7968. * @param indexCount defines the number of index to draw
  7969. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7970. */
  7971. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7972. /**
  7973. * Draw a list of points
  7974. * @param verticesStart defines the index of first vertex to draw
  7975. * @param verticesCount defines the count of vertices to draw
  7976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7977. */
  7978. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7979. /**
  7980. * Draw a list of unindexed primitives
  7981. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7982. * @param verticesStart defines the index of first vertex to draw
  7983. * @param verticesCount defines the count of vertices to draw
  7984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7985. */
  7986. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7987. /**
  7988. * Draw a list of indexed primitives
  7989. * @param fillMode defines the primitive to use
  7990. * @param indexStart defines the starting index
  7991. * @param indexCount defines the number of index to draw
  7992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7993. */
  7994. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7995. /**
  7996. * Draw a list of unindexed primitives
  7997. * @param fillMode defines the primitive to use
  7998. * @param verticesStart defines the index of first vertex to draw
  7999. * @param verticesCount defines the count of vertices to draw
  8000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8001. */
  8002. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8003. private _drawMode(fillMode);
  8004. /** @hidden */
  8005. _releaseEffect(effect: Effect): void;
  8006. /** @hidden */
  8007. _deleteProgram(program: WebGLProgram): void;
  8008. /**
  8009. * Create a new effect (used to store vertex/fragment shaders)
  8010. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8011. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8012. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8013. * @param samplers defines an array of string used to represent textures
  8014. * @param defines defines the string containing the defines to use to compile the shaders
  8015. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8016. * @param onCompiled defines a function to call when the effect creation is successful
  8017. * @param onError defines a function to call when the effect creation has failed
  8018. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8019. * @returns the new Effect
  8020. */
  8021. 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;
  8022. /**
  8023. * Create an effect to use with particle systems.
  8024. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  8025. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8026. * @param uniformsNames defines a list of attribute names
  8027. * @param samplers defines an array of string used to represent textures
  8028. * @param defines defines the string containing the defines to use to compile the shaders
  8029. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8030. * @param onCompiled defines a function to call when the effect creation is successful
  8031. * @param onError defines a function to call when the effect creation has failed
  8032. * @returns the new Effect
  8033. */
  8034. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8035. /**
  8036. * Directly creates a webGL program
  8037. * @param vertexCode defines the vertex shader code to use
  8038. * @param fragmentCode defines the fragment shader code to use
  8039. * @param context defines the webGL context to use (if not set, the current one will be used)
  8040. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8041. * @returns the new webGL program
  8042. */
  8043. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8044. /**
  8045. * Creates a webGL program
  8046. * @param vertexCode defines the vertex shader code to use
  8047. * @param fragmentCode defines the fragment shader code to use
  8048. * @param defines defines the string containing the defines to use to compile the shaders
  8049. * @param context defines the webGL context to use (if not set, the current one will be used)
  8050. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8051. * @returns the new webGL program
  8052. */
  8053. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8054. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8055. /**
  8056. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8057. * @param shaderProgram defines the webGL program to use
  8058. * @param uniformsNames defines the list of uniform names
  8059. * @returns an array of webGL uniform locations
  8060. */
  8061. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8062. /**
  8063. * Gets the lsit of active attributes for a given webGL program
  8064. * @param shaderProgram defines the webGL program to use
  8065. * @param attributesNames defines the list of attribute names to get
  8066. * @returns an array of indices indicating the offset of each attribute
  8067. */
  8068. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8069. /**
  8070. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8071. * @param effect defines the effect to activate
  8072. */
  8073. enableEffect(effect: Nullable<Effect>): void;
  8074. /**
  8075. * Set the value of an uniform to an array of int32
  8076. * @param uniform defines the webGL uniform location where to store the value
  8077. * @param array defines the array of int32 to store
  8078. */
  8079. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8080. /**
  8081. * Set the value of an uniform to an array of int32 (stored as vec2)
  8082. * @param uniform defines the webGL uniform location where to store the value
  8083. * @param array defines the array of int32 to store
  8084. */
  8085. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8086. /**
  8087. * Set the value of an uniform to an array of int32 (stored as vec3)
  8088. * @param uniform defines the webGL uniform location where to store the value
  8089. * @param array defines the array of int32 to store
  8090. */
  8091. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8092. /**
  8093. * Set the value of an uniform to an array of int32 (stored as vec4)
  8094. * @param uniform defines the webGL uniform location where to store the value
  8095. * @param array defines the array of int32 to store
  8096. */
  8097. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8098. /**
  8099. * Set the value of an uniform to an array of float32
  8100. * @param uniform defines the webGL uniform location where to store the value
  8101. * @param array defines the array of float32 to store
  8102. */
  8103. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8104. /**
  8105. * Set the value of an uniform to an array of float32 (stored as vec2)
  8106. * @param uniform defines the webGL uniform location where to store the value
  8107. * @param array defines the array of float32 to store
  8108. */
  8109. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8110. /**
  8111. * Set the value of an uniform to an array of float32 (stored as vec3)
  8112. * @param uniform defines the webGL uniform location where to store the value
  8113. * @param array defines the array of float32 to store
  8114. */
  8115. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8116. /**
  8117. * Set the value of an uniform to an array of float32 (stored as vec4)
  8118. * @param uniform defines the webGL uniform location where to store the value
  8119. * @param array defines the array of float32 to store
  8120. */
  8121. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8122. /**
  8123. * Set the value of an uniform to an array of number
  8124. * @param uniform defines the webGL uniform location where to store the value
  8125. * @param array defines the array of number to store
  8126. */
  8127. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8128. /**
  8129. * Set the value of an uniform to an array of number (stored as vec2)
  8130. * @param uniform defines the webGL uniform location where to store the value
  8131. * @param array defines the array of number to store
  8132. */
  8133. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8134. /**
  8135. * Set the value of an uniform to an array of number (stored as vec3)
  8136. * @param uniform defines the webGL uniform location where to store the value
  8137. * @param array defines the array of number to store
  8138. */
  8139. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8140. /**
  8141. * Set the value of an uniform to an array of number (stored as vec4)
  8142. * @param uniform defines the webGL uniform location where to store the value
  8143. * @param array defines the array of number to store
  8144. */
  8145. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8146. /**
  8147. * Set the value of an uniform to an array of float32 (stored as matrices)
  8148. * @param uniform defines the webGL uniform location where to store the value
  8149. * @param matrices defines the array of float32 to store
  8150. */
  8151. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8152. /**
  8153. * Set the value of an uniform to a matrix
  8154. * @param uniform defines the webGL uniform location where to store the value
  8155. * @param matrix defines the matrix to store
  8156. */
  8157. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8158. /**
  8159. * Set the value of an uniform to a matrix (3x3)
  8160. * @param uniform defines the webGL uniform location where to store the value
  8161. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8162. */
  8163. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8164. /**
  8165. * Set the value of an uniform to a matrix (2x2)
  8166. * @param uniform defines the webGL uniform location where to store the value
  8167. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8168. */
  8169. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8170. /**
  8171. * Set the value of an uniform to a number (int)
  8172. * @param uniform defines the webGL uniform location where to store the value
  8173. * @param value defines the int number to store
  8174. */
  8175. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8176. /**
  8177. * Set the value of an uniform to a number (float)
  8178. * @param uniform defines the webGL uniform location where to store the value
  8179. * @param value defines the float number to store
  8180. */
  8181. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8182. /**
  8183. * Set the value of an uniform to a vec2
  8184. * @param uniform defines the webGL uniform location where to store the value
  8185. * @param x defines the 1st component of the value
  8186. * @param y defines the 2nd component of the value
  8187. */
  8188. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8189. /**
  8190. * Set the value of an uniform to a vec3
  8191. * @param uniform defines the webGL uniform location where to store the value
  8192. * @param x defines the 1st component of the value
  8193. * @param y defines the 2nd component of the value
  8194. * @param z defines the 3rd component of the value
  8195. */
  8196. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8197. /**
  8198. * Set the value of an uniform to a boolean
  8199. * @param uniform defines the webGL uniform location where to store the value
  8200. * @param bool defines the boolean to store
  8201. */
  8202. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8203. /**
  8204. * Set the value of an uniform to a vec4
  8205. * @param uniform defines the webGL uniform location where to store the value
  8206. * @param x defines the 1st component of the value
  8207. * @param y defines the 2nd component of the value
  8208. * @param z defines the 3rd component of the value
  8209. * @param w defines the 4th component of the value
  8210. */
  8211. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8212. /**
  8213. * Set the value of an uniform to a Color3
  8214. * @param uniform defines the webGL uniform location where to store the value
  8215. * @param color3 defines the color to store
  8216. */
  8217. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8218. /**
  8219. * Set the value of an uniform to a Color3 and an alpha value
  8220. * @param uniform defines the webGL uniform location where to store the value
  8221. * @param color3 defines the color to store
  8222. * @param alpha defines the alpha component to store
  8223. */
  8224. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8225. /**
  8226. * Sets a Color4 on a uniform variable
  8227. * @param uniform defines the uniform location
  8228. * @param color4 defines the value to be set
  8229. */
  8230. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8231. /**
  8232. * Set various states to the webGL context
  8233. * @param culling defines backface culling state
  8234. * @param zOffset defines the value to apply to zOffset (0 by default)
  8235. * @param force defines if states must be applied even if cache is up to date
  8236. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8237. */
  8238. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8239. /**
  8240. * Set the z offset to apply to current rendering
  8241. * @param value defines the offset to apply
  8242. */
  8243. setZOffset(value: number): void;
  8244. /**
  8245. * Gets the current value of the zOffset
  8246. * @returns the current zOffset state
  8247. */
  8248. getZOffset(): number;
  8249. /**
  8250. * Enable or disable depth buffering
  8251. * @param enable defines the state to set
  8252. */
  8253. setDepthBuffer(enable: boolean): void;
  8254. /**
  8255. * Gets a boolean indicating if depth writing is enabled
  8256. * @returns the current depth writing state
  8257. */
  8258. getDepthWrite(): boolean;
  8259. /**
  8260. * Enable or disable depth writing
  8261. * @param enable defines the state to set
  8262. */
  8263. setDepthWrite(enable: boolean): void;
  8264. /**
  8265. * Enable or disable color writing
  8266. * @param enable defines the state to set
  8267. */
  8268. setColorWrite(enable: boolean): void;
  8269. /**
  8270. * Gets a boolean indicating if color writing is enabled
  8271. * @returns the current color writing state
  8272. */
  8273. getColorWrite(): boolean;
  8274. /**
  8275. * Sets alpha constants used by some alpha blending modes
  8276. * @param r defines the red component
  8277. * @param g defines the green component
  8278. * @param b defines the blue component
  8279. * @param a defines the alpha component
  8280. */
  8281. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8282. /**
  8283. * Sets the current alpha mode
  8284. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8285. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8287. */
  8288. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8289. /**
  8290. * Gets the current alpha mode
  8291. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8292. * @returns the current alpha mode
  8293. */
  8294. getAlphaMode(): number;
  8295. /**
  8296. * Clears the list of texture accessible through engine.
  8297. * This can help preventing texture load conflict due to name collision.
  8298. */
  8299. clearInternalTexturesCache(): void;
  8300. /**
  8301. * Force the entire cache to be cleared
  8302. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8303. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8304. */
  8305. wipeCaches(bruteForce?: boolean): void;
  8306. /**
  8307. * Set the compressed texture format to use, based on the formats you have, and the formats
  8308. * supported by the hardware / browser.
  8309. *
  8310. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8311. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8312. * to API arguments needed to compressed textures. This puts the burden on the container
  8313. * generator to house the arcane code for determining these for current & future formats.
  8314. *
  8315. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8316. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8317. *
  8318. * Note: The result of this call is not taken into account when a texture is base64.
  8319. *
  8320. * @param formatsAvailable defines the list of those format families you have created
  8321. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8322. *
  8323. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8324. * @returns The extension selected.
  8325. */
  8326. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8327. /** @hidden */
  8328. _createTexture(): WebGLTexture;
  8329. /**
  8330. * Usually called from BABYLON.Texture.ts.
  8331. * Passed information to create a WebGLTexture
  8332. * @param urlArg defines a value which contains one of the following:
  8333. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8334. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8335. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8336. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8337. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8338. * @param scene needed for loading to the correct scene
  8339. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8340. * @param onLoad optional callback to be called upon successful completion
  8341. * @param onError optional callback to be called upon failure
  8342. * @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
  8343. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8344. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8345. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8346. */
  8347. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8348. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8349. /**
  8350. * Update a raw texture
  8351. * @param texture defines the texture to update
  8352. * @param data defines the data to store in the texture
  8353. * @param format defines the format of the data
  8354. * @param invertY defines if data must be stored with Y axis inverted
  8355. * @param compression defines the compression used (null by default)
  8356. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8357. */
  8358. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8359. /**
  8360. * Creates a raw texture
  8361. * @param data defines the data to store in the texture
  8362. * @param width defines the width of the texture
  8363. * @param height defines the height of the texture
  8364. * @param format defines the format of the data
  8365. * @param generateMipMaps defines if the engine should generate the mip levels
  8366. * @param invertY defines if data must be stored with Y axis inverted
  8367. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8368. * @param compression defines the compression used (null by default)
  8369. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8370. * @returns the raw texture inside an InternalTexture
  8371. */
  8372. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8373. private _unpackFlipYCached;
  8374. /** @hidden */
  8375. _unpackFlipY(value: boolean): void;
  8376. /**
  8377. * Creates a dynamic texture
  8378. * @param width defines the width of the texture
  8379. * @param height defines the height of the texture
  8380. * @param generateMipMaps defines if the engine should generate the mip levels
  8381. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8382. * @returns the dynamic texture inside an InternalTexture
  8383. */
  8384. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8385. /**
  8386. * Update the sampling mode of a given texture
  8387. * @param samplingMode defines the required sampling mode
  8388. * @param texture defines the texture to update
  8389. */
  8390. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8391. /**
  8392. * Update the content of a dynamic texture
  8393. * @param texture defines the texture to update
  8394. * @param canvas defines the canvas containing the source
  8395. * @param invertY defines if data must be stored with Y axis inverted
  8396. * @param premulAlpha defines if alpha is stored as premultiplied
  8397. * @param format defines the format of the data
  8398. */
  8399. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8400. /**
  8401. * Update a video texture
  8402. * @param texture defines the texture to update
  8403. * @param video defines the video element to use
  8404. * @param invertY defines if data must be stored with Y axis inverted
  8405. */
  8406. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8407. /**
  8408. * Updates a depth texture Comparison Mode and Function.
  8409. * If the comparison Function is equal to 0, the mode will be set to none.
  8410. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8411. * @param texture The texture to set the comparison function for
  8412. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8413. */
  8414. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8415. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8416. /**
  8417. * Creates a depth stencil texture.
  8418. * This is only available in WebGL 2 or with the depth texture extension available.
  8419. * @param size The size of face edge in the texture.
  8420. * @param options The options defining the texture.
  8421. * @returns The texture
  8422. */
  8423. createDepthStencilTexture(size: number | {
  8424. width: number;
  8425. height: number;
  8426. }, options: DepthTextureCreationOptions): InternalTexture;
  8427. /**
  8428. * Creates a depth stencil texture.
  8429. * This is only available in WebGL 2 or with the depth texture extension available.
  8430. * @param size The size of face edge in the texture.
  8431. * @param options The options defining the texture.
  8432. * @returns The texture
  8433. */
  8434. private _createDepthStencilTexture(size, options);
  8435. /**
  8436. * Creates a depth stencil cube texture.
  8437. * This is only available in WebGL 2.
  8438. * @param size The size of face edge in the cube texture.
  8439. * @param options The options defining the cube texture.
  8440. * @returns The cube texture
  8441. */
  8442. private _createDepthStencilCubeTexture(size, options);
  8443. /**
  8444. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8445. * @param renderTarget The render target to set the frame buffer for
  8446. */
  8447. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8448. /**
  8449. * Creates a new render target texture
  8450. * @param size defines the size of the texture
  8451. * @param options defines the options used to create the texture
  8452. * @returns a new render target texture stored in an InternalTexture
  8453. */
  8454. createRenderTargetTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8458. /**
  8459. * Create a multi render target texture
  8460. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8461. * @param size defines the size of the texture
  8462. * @param options defines the creation options
  8463. * @returns the cube texture as an InternalTexture
  8464. */
  8465. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8466. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8467. /**
  8468. * Updates the sample count of a render target texture
  8469. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8470. * @param texture defines the texture to update
  8471. * @param samples defines the sample count to set
  8472. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8473. */
  8474. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8475. /**
  8476. * Update the sample count for a given multiple render target texture
  8477. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8478. * @param textures defines the textures to update
  8479. * @param samples defines the sample count to set
  8480. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8481. */
  8482. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8483. /** @hidden */
  8484. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8485. /** @hidden */
  8486. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8487. /** @hidden */
  8488. _uploadImageToTexture(texture: InternalTexture, faceIndex: number, lod: number, image: HTMLImageElement): void;
  8489. /**
  8490. * Creates a new render target cube texture
  8491. * @param size defines the size of the texture
  8492. * @param options defines the options used to create the texture
  8493. * @returns a new render target cube texture stored in an InternalTexture
  8494. */
  8495. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8496. /**
  8497. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8498. * @param rootUrl defines the url where the file to load is located
  8499. * @param scene defines the current scene
  8500. * @param lodScale defines scale to apply to the mip map selection
  8501. * @param lodOffset defines offset to apply to the mip map selection
  8502. * @param onLoad defines an optional callback raised when the texture is loaded
  8503. * @param onError defines an optional callback raised if there is an issue to load the texture
  8504. * @param format defines the format of the data
  8505. * @param forcedExtension defines the extension to use to pick the right loader
  8506. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8507. * @returns the cube texture as an InternalTexture
  8508. */
  8509. 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;
  8510. /**
  8511. * Creates a cube texture
  8512. * @param rootUrl defines the url where the files to load is located
  8513. * @param scene defines the current scene
  8514. * @param files defines the list of files to load (1 per face)
  8515. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8516. * @param onLoad defines an optional callback raised when the texture is loaded
  8517. * @param onError defines an optional callback raised if there is an issue to load the texture
  8518. * @param format defines the format of the data
  8519. * @param forcedExtension defines the extension to use to pick the right loader
  8520. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8521. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8522. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8523. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8524. * @returns the cube texture as an InternalTexture
  8525. */
  8526. 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;
  8527. private setCubeMapTextureParams(gl, loadMipmap);
  8528. /**
  8529. * Update a raw cube texture
  8530. * @param texture defines the texture to udpdate
  8531. * @param data defines the data to store
  8532. * @param format defines the data format
  8533. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8534. * @param invertY defines if data must be stored with Y axis inverted
  8535. * @param compression defines the compression used (null by default)
  8536. * @param level defines which level of the texture to update
  8537. */
  8538. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8539. /**
  8540. * Creates a new raw cube texture
  8541. * @param data defines the array of data to use to create each face
  8542. * @param size defines the size of the textures
  8543. * @param format defines the format of the data
  8544. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8545. * @param generateMipMaps defines if the engine should generate the mip levels
  8546. * @param invertY defines if data must be stored with Y axis inverted
  8547. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8548. * @param compression defines the compression used (null by default)
  8549. * @returns the cube texture as an InternalTexture
  8550. */
  8551. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8552. /**
  8553. * Creates a new raw cube texture from a specified url
  8554. * @param url defines the url where the data is located
  8555. * @param scene defines the current scene
  8556. * @param size defines the size of the textures
  8557. * @param format defines the format of the data
  8558. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8559. * @param noMipmap defines if the engine should avoid generating the mip levels
  8560. * @param callback defines a callback used to extract texture data from loaded data
  8561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8562. * @param onLoad defines a callback called when texture is loaded
  8563. * @param onError defines a callback called if there is an error
  8564. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8565. * @param invertY defines if data must be stored with Y axis inverted
  8566. * @returns the cube texture as an InternalTexture
  8567. */
  8568. 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;
  8569. /**
  8570. * Update a raw 3D texture
  8571. * @param texture defines the texture to update
  8572. * @param data defines the data to store
  8573. * @param format defines the data format
  8574. * @param invertY defines if data must be stored with Y axis inverted
  8575. * @param compression defines the used compression (can be null)
  8576. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8577. */
  8578. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8579. /**
  8580. * Creates a new raw 3D texture
  8581. * @param data defines the data used to create the texture
  8582. * @param width defines the width of the texture
  8583. * @param height defines the height of the texture
  8584. * @param depth defines the depth of the texture
  8585. * @param format defines the format of the texture
  8586. * @param generateMipMaps defines if the engine must generate mip levels
  8587. * @param invertY defines if data must be stored with Y axis inverted
  8588. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8589. * @param compression defines the compressed used (can be null)
  8590. * @param textureType defines the compressed used (can be null)
  8591. * @returns a new raw 3D texture (stored in an InternalTexture)
  8592. */
  8593. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8594. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8595. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8596. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8597. /** @hidden */
  8598. _releaseFramebufferObjects(texture: InternalTexture): void;
  8599. /** @hidden */
  8600. _releaseTexture(texture: InternalTexture): void;
  8601. private setProgram(program);
  8602. private _boundUniforms;
  8603. /**
  8604. * Binds an effect to the webGL context
  8605. * @param effect defines the effect to bind
  8606. */
  8607. bindSamplers(effect: Effect): void;
  8608. private _moveBoundTextureOnTop(internalTexture);
  8609. private _getCorrectTextureChannel(channel, internalTexture);
  8610. private _linkTrackers(previous, next);
  8611. private _removeDesignatedSlot(internalTexture);
  8612. private _activateCurrentTexture();
  8613. /** @hidden */
  8614. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8615. /** @hidden */
  8616. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8617. /**
  8618. * Sets a texture to the webGL context from a postprocess
  8619. * @param channel defines the channel to use
  8620. * @param postProcess defines the source postprocess
  8621. */
  8622. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8623. /**
  8624. * Binds the output of the passed in post process to the texture channel specified
  8625. * @param channel The channel the texture should be bound to
  8626. * @param postProcess The post process which's output should be bound
  8627. */
  8628. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8629. /**
  8630. * Unbind all textures from the webGL context
  8631. */
  8632. unbindAllTextures(): void;
  8633. /**
  8634. * Sets a texture to the according uniform.
  8635. * @param channel The texture channel
  8636. * @param uniform The uniform to set
  8637. * @param texture The texture to apply
  8638. */
  8639. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8640. /**
  8641. * Sets a depth stencil texture from a render target to the according uniform.
  8642. * @param channel The texture channel
  8643. * @param uniform The uniform to set
  8644. * @param texture The render target texture containing the depth stencil texture to apply
  8645. */
  8646. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8647. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8648. private _getTextureWrapMode(mode);
  8649. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8650. /**
  8651. * Sets an array of texture to the webGL context
  8652. * @param channel defines the channel where the texture array must be set
  8653. * @param uniform defines the associated uniform location
  8654. * @param textures defines the array of textures to bind
  8655. */
  8656. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8657. /** @hidden */
  8658. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8659. private _setTextureParameterFloat(target, parameter, value, texture);
  8660. private _setTextureParameterInteger(target, parameter, value, texture?);
  8661. /**
  8662. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8663. * @param x defines the x coordinate of the rectangle where pixels must be read
  8664. * @param y defines the y coordinate of the rectangle where pixels must be read
  8665. * @param width defines the width of the rectangle where pixels must be read
  8666. * @param height defines the height of the rectangle where pixels must be read
  8667. * @returns a Uint8Array containing RGBA colors
  8668. */
  8669. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8670. /**
  8671. * Add an externaly attached data from its key.
  8672. * This method call will fail and return false, if such key already exists.
  8673. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8674. * @param key the unique key that identifies the data
  8675. * @param data the data object to associate to the key for this Engine instance
  8676. * @return true if no such key were already present and the data was added successfully, false otherwise
  8677. */
  8678. addExternalData<T>(key: string, data: T): boolean;
  8679. /**
  8680. * Get an externaly attached data from its key
  8681. * @param key the unique key that identifies the data
  8682. * @return the associated data, if present (can be null), or undefined if not present
  8683. */
  8684. getExternalData<T>(key: string): T;
  8685. /**
  8686. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8687. * @param key the unique key that identifies the data
  8688. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8689. * @return the associated data, can be null if the factory returned null.
  8690. */
  8691. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8692. /**
  8693. * Remove an externaly attached data from the Engine instance
  8694. * @param key the unique key that identifies the data
  8695. * @return true if the data was successfully removed, false if it doesn't exist
  8696. */
  8697. removeExternalData(key: string): boolean;
  8698. /**
  8699. * Unbind all vertex attributes from the webGL context
  8700. */
  8701. unbindAllAttributes(): void;
  8702. /**
  8703. * 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
  8704. */
  8705. releaseEffects(): void;
  8706. /**
  8707. * Dispose and release all associated resources
  8708. */
  8709. dispose(): void;
  8710. /**
  8711. * Display the loading screen
  8712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8713. */
  8714. displayLoadingUI(): void;
  8715. /**
  8716. * Hide the loading screen
  8717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8718. */
  8719. hideLoadingUI(): void;
  8720. /**
  8721. * Gets the current loading screen object
  8722. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8723. */
  8724. /**
  8725. * Sets the current loading screen object
  8726. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8727. */
  8728. loadingScreen: ILoadingScreen;
  8729. /**
  8730. * Sets the current loading screen text
  8731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8732. */
  8733. loadingUIText: string;
  8734. /**
  8735. * Sets the current loading screen background color
  8736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8737. */
  8738. loadingUIBackgroundColor: string;
  8739. /**
  8740. * Attach a new callback raised when context lost event is fired
  8741. * @param callback defines the callback to call
  8742. */
  8743. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8744. /**
  8745. * Attach a new callback raised when context restored event is fired
  8746. * @param callback defines the callback to call
  8747. */
  8748. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8749. /**
  8750. * Gets the source code of the vertex shader associated with a specific webGL program
  8751. * @param program defines the program to use
  8752. * @returns a string containing the source code of the vertex shader associated with the program
  8753. */
  8754. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8755. /**
  8756. * Gets the source code of the fragment shader associated with a specific webGL program
  8757. * @param program defines the program to use
  8758. * @returns a string containing the source code of the fragment shader associated with the program
  8759. */
  8760. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8761. /**
  8762. * Get the current error code of the webGL context
  8763. * @returns the error code
  8764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8765. */
  8766. getError(): number;
  8767. /**
  8768. * Gets the current framerate
  8769. * @returns a number representing the framerate
  8770. */
  8771. getFps(): number;
  8772. /**
  8773. * Gets the time spent between current and previous frame
  8774. * @returns a number representing the delta time in ms
  8775. */
  8776. getDeltaTime(): number;
  8777. private _measureFps();
  8778. /** @hidden */
  8779. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  8780. private _canRenderToFloatFramebuffer();
  8781. private _canRenderToHalfFloatFramebuffer();
  8782. private _canRenderToFramebuffer(type);
  8783. /** @hidden */
  8784. _getWebGLTextureType(type: number): number;
  8785. private _getInternalFormat(format);
  8786. /** @hidden */
  8787. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8788. /** @hidden */
  8789. _getRGBAMultiSampleBufferFormat(type: number): number;
  8790. /**
  8791. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8792. * @return the new query
  8793. */
  8794. createQuery(): WebGLQuery;
  8795. /**
  8796. * Delete and release a webGL query
  8797. * @param query defines the query to delete
  8798. * @return the current engine
  8799. */
  8800. deleteQuery(query: WebGLQuery): Engine;
  8801. /**
  8802. * Check if a given query has resolved and got its value
  8803. * @param query defines the query to check
  8804. * @returns true if the query got its value
  8805. */
  8806. isQueryResultAvailable(query: WebGLQuery): boolean;
  8807. /**
  8808. * Gets the value of a given query
  8809. * @param query defines the query to check
  8810. * @returns the value of the query
  8811. */
  8812. getQueryResult(query: WebGLQuery): number;
  8813. /**
  8814. * Initiates an occlusion query
  8815. * @param algorithmType defines the algorithm to use
  8816. * @param query defines the query to use
  8817. * @returns the current engine
  8818. * @see http://doc.babylonjs.com/features/occlusionquery
  8819. */
  8820. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8821. /**
  8822. * Ends an occlusion query
  8823. * @see http://doc.babylonjs.com/features/occlusionquery
  8824. * @param algorithmType defines the algorithm to use
  8825. * @returns the current engine
  8826. */
  8827. endOcclusionQuery(algorithmType: number): Engine;
  8828. private _createTimeQuery();
  8829. private _deleteTimeQuery(query);
  8830. private _getTimeQueryResult(query);
  8831. private _getTimeQueryAvailability(query);
  8832. private _currentNonTimestampToken;
  8833. /**
  8834. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8835. * Please note that only one query can be issued at a time
  8836. * @returns a time token used to track the time span
  8837. */
  8838. startTimeQuery(): Nullable<_TimeToken>;
  8839. /**
  8840. * Ends a time query
  8841. * @param token defines the token used to measure the time span
  8842. * @returns the time spent (in ns)
  8843. */
  8844. endTimeQuery(token: _TimeToken): int;
  8845. private getGlAlgorithmType(algorithmType);
  8846. /**
  8847. * Creates a webGL transform feedback object
  8848. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8849. * @returns the webGL transform feedback object
  8850. */
  8851. createTransformFeedback(): WebGLTransformFeedback;
  8852. /**
  8853. * Delete a webGL transform feedback object
  8854. * @param value defines the webGL transform feedback object to delete
  8855. */
  8856. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8857. /**
  8858. * Bind a webGL transform feedback object to the webgl context
  8859. * @param value defines the webGL transform feedback object to bind
  8860. */
  8861. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8862. /**
  8863. * Begins a transform feedback operation
  8864. * @param usePoints defines if points or triangles must be used
  8865. */
  8866. beginTransformFeedback(usePoints?: boolean): void;
  8867. /**
  8868. * Ends a transform feedback operation
  8869. */
  8870. endTransformFeedback(): void;
  8871. /**
  8872. * Specify the varyings to use with transform feedback
  8873. * @param program defines the associated webGL program
  8874. * @param value defines the list of strings representing the varying names
  8875. */
  8876. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8877. /**
  8878. * Bind a webGL buffer for a transform feedback operation
  8879. * @param value defines the webGL buffer to bind
  8880. */
  8881. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8882. /** @hidden */
  8883. _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;
  8884. /** @hidden */
  8885. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8886. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8887. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8888. /**
  8889. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8890. * @returns true if the engine can be created
  8891. * @ignorenaming
  8892. */
  8893. static isSupported(): boolean;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. class NullEngineOptions {
  8898. renderWidth: number;
  8899. renderHeight: number;
  8900. textureSize: number;
  8901. deterministicLockstep: boolean;
  8902. lockstepMaxSteps: number;
  8903. }
  8904. /**
  8905. * The null engine class provides support for headless version of babylon.js.
  8906. * This can be used in server side scenario or for testing purposes
  8907. */
  8908. class NullEngine extends Engine {
  8909. private _options;
  8910. isDeterministicLockStep(): boolean;
  8911. getLockstepMaxSteps(): number;
  8912. getHardwareScalingLevel(): number;
  8913. constructor(options?: NullEngineOptions);
  8914. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8915. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8916. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8917. getRenderWidth(useScreen?: boolean): number;
  8918. getRenderHeight(useScreen?: boolean): number;
  8919. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8920. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8921. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8922. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8923. bindSamplers(effect: Effect): void;
  8924. enableEffect(effect: Effect): void;
  8925. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8926. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8927. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8928. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8929. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8930. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8931. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8932. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8933. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8934. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8935. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8936. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8937. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8938. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8939. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8940. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8941. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8942. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8943. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8944. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8945. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8946. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8947. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8948. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8949. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8950. bindBuffers(vertexBuffers: {
  8951. [key: string]: VertexBuffer;
  8952. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8953. wipeCaches(bruteForce?: boolean): void;
  8954. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8955. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8956. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8957. _createTexture(): WebGLTexture;
  8958. _releaseTexture(texture: InternalTexture): void;
  8959. 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;
  8960. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8961. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8962. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8963. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8964. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8965. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8966. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8967. /**
  8968. * Updates a dynamic vertex buffer.
  8969. * @param vertexBuffer the vertex buffer to update
  8970. * @param data the data used to update the vertex buffer
  8971. * @param byteOffset the byte offset of the data (optional)
  8972. * @param byteLength the byte length of the data (optional)
  8973. */
  8974. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8975. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  8976. _bindTexture(channel: number, texture: InternalTexture): void;
  8977. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8978. releaseEffects(): void;
  8979. displayLoadingUI(): void;
  8980. hideLoadingUI(): void;
  8981. }
  8982. }
  8983. interface WebGLRenderingContext {
  8984. readonly RASTERIZER_DISCARD: number;
  8985. readonly DEPTH_COMPONENT24: number;
  8986. readonly TEXTURE_3D: number;
  8987. readonly TEXTURE_2D_ARRAY: number;
  8988. readonly TEXTURE_COMPARE_FUNC: number;
  8989. readonly TEXTURE_COMPARE_MODE: number;
  8990. readonly COMPARE_REF_TO_TEXTURE: number;
  8991. readonly TEXTURE_WRAP_R: number;
  8992. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8993. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8994. 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;
  8995. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8996. readonly TRANSFORM_FEEDBACK: number;
  8997. readonly INTERLEAVED_ATTRIBS: number;
  8998. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8999. createTransformFeedback(): WebGLTransformFeedback;
  9000. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9001. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9002. beginTransformFeedback(primitiveMode: number): void;
  9003. endTransformFeedback(): void;
  9004. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9005. }
  9006. interface ImageBitmap {
  9007. readonly width: number;
  9008. readonly height: number;
  9009. close(): void;
  9010. }
  9011. interface WebGLQuery extends WebGLObject {
  9012. }
  9013. declare var WebGLQuery: {
  9014. prototype: WebGLQuery;
  9015. new (): WebGLQuery;
  9016. };
  9017. interface WebGLSampler extends WebGLObject {
  9018. }
  9019. declare var WebGLSampler: {
  9020. prototype: WebGLSampler;
  9021. new (): WebGLSampler;
  9022. };
  9023. interface WebGLSync extends WebGLObject {
  9024. }
  9025. declare var WebGLSync: {
  9026. prototype: WebGLSync;
  9027. new (): WebGLSync;
  9028. };
  9029. interface WebGLTransformFeedback extends WebGLObject {
  9030. }
  9031. declare var WebGLTransformFeedback: {
  9032. prototype: WebGLTransformFeedback;
  9033. new (): WebGLTransformFeedback;
  9034. };
  9035. interface WebGLVertexArrayObject extends WebGLObject {
  9036. }
  9037. declare var WebGLVertexArrayObject: {
  9038. prototype: WebGLVertexArrayObject;
  9039. new (): WebGLVertexArrayObject;
  9040. };
  9041. declare module BABYLON {
  9042. class Collider {
  9043. /** Define if a collision was found */
  9044. collisionFound: boolean;
  9045. /**
  9046. * Define last intersection point in local space
  9047. */
  9048. intersectionPoint: Vector3;
  9049. /**
  9050. * Define last collided mesh
  9051. */
  9052. collidedMesh: Nullable<AbstractMesh>;
  9053. private _collisionPoint;
  9054. private _planeIntersectionPoint;
  9055. private _tempVector;
  9056. private _tempVector2;
  9057. private _tempVector3;
  9058. private _tempVector4;
  9059. private _edge;
  9060. private _baseToVertex;
  9061. private _destinationPoint;
  9062. private _slidePlaneNormal;
  9063. private _displacementVector;
  9064. _radius: Vector3;
  9065. _retry: number;
  9066. private _velocity;
  9067. private _basePoint;
  9068. private _epsilon;
  9069. _velocityWorldLength: number;
  9070. _basePointWorld: Vector3;
  9071. private _velocityWorld;
  9072. private _normalizedVelocity;
  9073. _initialVelocity: Vector3;
  9074. _initialPosition: Vector3;
  9075. private _nearestDistance;
  9076. private _collisionMask;
  9077. collisionMask: number;
  9078. /**
  9079. * Gets the plane normal used to compute the sliding response (in local space)
  9080. */
  9081. readonly slidePlaneNormal: Vector3;
  9082. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9083. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9084. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9086. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9087. _getResponse(pos: Vector3, vel: Vector3): void;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. var CollisionWorker: string;
  9092. interface ICollisionCoordinator {
  9093. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9094. init(scene: Scene): void;
  9095. destroy(): void;
  9096. onMeshAdded(mesh: AbstractMesh): void;
  9097. onMeshUpdated(mesh: AbstractMesh): void;
  9098. onMeshRemoved(mesh: AbstractMesh): void;
  9099. onGeometryAdded(geometry: Geometry): void;
  9100. onGeometryUpdated(geometry: Geometry): void;
  9101. onGeometryDeleted(geometry: Geometry): void;
  9102. }
  9103. interface SerializedMesh {
  9104. id: string;
  9105. name: string;
  9106. uniqueId: number;
  9107. geometryId: Nullable<string>;
  9108. sphereCenter: Array<number>;
  9109. sphereRadius: number;
  9110. boxMinimum: Array<number>;
  9111. boxMaximum: Array<number>;
  9112. worldMatrixFromCache: any;
  9113. subMeshes: Array<SerializedSubMesh>;
  9114. checkCollisions: boolean;
  9115. }
  9116. interface SerializedSubMesh {
  9117. position: number;
  9118. verticesStart: number;
  9119. verticesCount: number;
  9120. indexStart: number;
  9121. indexCount: number;
  9122. hasMaterial: boolean;
  9123. sphereCenter: Array<number>;
  9124. sphereRadius: number;
  9125. boxMinimum: Array<number>;
  9126. boxMaximum: Array<number>;
  9127. }
  9128. /**
  9129. * Interface describing the value associated with a geometry
  9130. */
  9131. interface SerializedGeometry {
  9132. /**
  9133. * Defines the unique ID of the geometry
  9134. */
  9135. id: string;
  9136. /**
  9137. * Defines the array containing the positions
  9138. */
  9139. positions: Float32Array;
  9140. /**
  9141. * Defines the array containing the indices
  9142. */
  9143. indices: Uint32Array;
  9144. /**
  9145. * Defines the array containing the normals
  9146. */
  9147. normals: Float32Array;
  9148. }
  9149. interface BabylonMessage {
  9150. taskType: WorkerTaskType;
  9151. payload: InitPayload | CollidePayload | UpdatePayload;
  9152. }
  9153. interface SerializedColliderToWorker {
  9154. position: Array<number>;
  9155. velocity: Array<number>;
  9156. radius: Array<number>;
  9157. }
  9158. /** Defines supported task for worker process */
  9159. enum WorkerTaskType {
  9160. /** Initialization */
  9161. INIT = 0,
  9162. /** Update of geometry */
  9163. UPDATE = 1,
  9164. /** Evaluate collision */
  9165. COLLIDE = 2,
  9166. }
  9167. interface WorkerReply {
  9168. error: WorkerReplyType;
  9169. taskType: WorkerTaskType;
  9170. payload?: any;
  9171. }
  9172. interface CollisionReplyPayload {
  9173. newPosition: Array<number>;
  9174. collisionId: number;
  9175. collidedMeshUniqueId: number;
  9176. }
  9177. interface InitPayload {
  9178. }
  9179. interface CollidePayload {
  9180. collisionId: number;
  9181. collider: SerializedColliderToWorker;
  9182. maximumRetry: number;
  9183. excludedMeshUniqueId: Nullable<number>;
  9184. }
  9185. interface UpdatePayload {
  9186. updatedMeshes: {
  9187. [n: number]: SerializedMesh;
  9188. };
  9189. updatedGeometries: {
  9190. [s: string]: SerializedGeometry;
  9191. };
  9192. removedMeshes: Array<number>;
  9193. removedGeometries: Array<string>;
  9194. }
  9195. /** Defines kind of replies returned by worker */
  9196. enum WorkerReplyType {
  9197. /** Success */
  9198. SUCCESS = 0,
  9199. /** Unkown error */
  9200. UNKNOWN_ERROR = 1,
  9201. }
  9202. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9203. private _scene;
  9204. private _scaledPosition;
  9205. private _scaledVelocity;
  9206. private _collisionsCallbackArray;
  9207. private _init;
  9208. private _runningUpdated;
  9209. private _worker;
  9210. private _addUpdateMeshesList;
  9211. private _addUpdateGeometriesList;
  9212. private _toRemoveMeshesArray;
  9213. private _toRemoveGeometryArray;
  9214. constructor();
  9215. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9216. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9217. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9218. init(scene: Scene): void;
  9219. destroy(): void;
  9220. onMeshAdded(mesh: AbstractMesh): void;
  9221. onMeshUpdated: (transformNode: TransformNode) => void;
  9222. onMeshRemoved(mesh: AbstractMesh): void;
  9223. onGeometryAdded(geometry: Geometry): void;
  9224. onGeometryUpdated: (geometry: Geometry) => void;
  9225. onGeometryDeleted(geometry: Geometry): void;
  9226. private _afterRender;
  9227. private _onMessageFromWorker;
  9228. }
  9229. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9230. private _scene;
  9231. private _scaledPosition;
  9232. private _scaledVelocity;
  9233. private _finalPosition;
  9234. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9235. init(scene: Scene): void;
  9236. destroy(): void;
  9237. onMeshAdded(mesh: AbstractMesh): void;
  9238. onMeshUpdated(mesh: AbstractMesh): void;
  9239. onMeshRemoved(mesh: AbstractMesh): void;
  9240. onGeometryAdded(geometry: Geometry): void;
  9241. onGeometryUpdated(geometry: Geometry): void;
  9242. onGeometryDeleted(geometry: Geometry): void;
  9243. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  9244. }
  9245. }
  9246. declare function importScripts(...urls: string[]): void;
  9247. declare const safePostMessage: any;
  9248. declare module BABYLON {
  9249. var WorkerIncluded: boolean;
  9250. class CollisionCache {
  9251. private _meshes;
  9252. private _geometries;
  9253. getMeshes(): {
  9254. [n: number]: SerializedMesh;
  9255. };
  9256. getGeometries(): {
  9257. [s: number]: SerializedGeometry;
  9258. };
  9259. getMesh(id: any): SerializedMesh;
  9260. addMesh(mesh: SerializedMesh): void;
  9261. removeMesh(uniqueId: number): void;
  9262. getGeometry(id: string): SerializedGeometry;
  9263. addGeometry(geometry: SerializedGeometry): void;
  9264. removeGeometry(id: string): void;
  9265. }
  9266. class CollideWorker {
  9267. collider: Collider;
  9268. private _collisionCache;
  9269. private finalPosition;
  9270. private collisionsScalingMatrix;
  9271. private collisionTranformationMatrix;
  9272. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9273. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9274. private checkCollision(mesh);
  9275. private processCollisionsForSubMeshes(transformMatrix, mesh);
  9276. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  9277. private checkSubmeshCollision(subMesh);
  9278. }
  9279. interface ICollisionDetector {
  9280. onInit(payload: InitPayload): void;
  9281. onUpdate(payload: UpdatePayload): void;
  9282. onCollision(payload: CollidePayload): void;
  9283. }
  9284. class CollisionDetectorTransferable implements ICollisionDetector {
  9285. private _collisionCache;
  9286. onInit(payload: InitPayload): void;
  9287. onUpdate(payload: UpdatePayload): void;
  9288. onCollision(payload: CollidePayload): void;
  9289. }
  9290. }
  9291. declare module BABYLON {
  9292. class IntersectionInfo {
  9293. bu: Nullable<number>;
  9294. bv: Nullable<number>;
  9295. distance: number;
  9296. faceId: number;
  9297. subMeshId: number;
  9298. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9299. }
  9300. /**
  9301. * Information about the result of picking within a scene
  9302. * See https://doc.babylonjs.com/babylon101/picking_collisions
  9303. */
  9304. class PickingInfo {
  9305. /**
  9306. * If the pick collided with an object
  9307. */
  9308. hit: boolean;
  9309. /**
  9310. * Distance away where the pick collided
  9311. */
  9312. distance: number;
  9313. /**
  9314. * The location of pick collision
  9315. */
  9316. pickedPoint: Nullable<Vector3>;
  9317. /**
  9318. * The mesh corrisponding the the pick collision
  9319. */
  9320. pickedMesh: Nullable<AbstractMesh>;
  9321. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9322. bu: number;
  9323. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9324. bv: number;
  9325. /** The id of the face on the mesh that was picked */
  9326. faceId: number;
  9327. /** Id of the the submesh that was picked */
  9328. subMeshId: number;
  9329. /** If a sprite was picked, this will be the sprite the pick collided with */
  9330. pickedSprite: Nullable<Sprite>;
  9331. /**
  9332. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9333. */
  9334. originMesh: Nullable<AbstractMesh>;
  9335. /**
  9336. * The ray that was used to perform the picking.
  9337. */
  9338. ray: Nullable<Ray>;
  9339. /**
  9340. * Gets the normal corrispodning to the face the pick collided with
  9341. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9342. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9343. * @returns The normal corrispodning to the face the pick collided with
  9344. */
  9345. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9346. /**
  9347. * Gets the texture coordinates of where the pick occured
  9348. * @returns the vector containing the coordnates of the texture
  9349. */
  9350. getTextureCoordinates(): Nullable<Vector2>;
  9351. }
  9352. }
  9353. declare module BABYLON {
  9354. class KeyboardEventTypes {
  9355. static _KEYDOWN: number;
  9356. static _KEYUP: number;
  9357. static readonly KEYDOWN: number;
  9358. static readonly KEYUP: number;
  9359. }
  9360. class KeyboardInfo {
  9361. type: number;
  9362. event: KeyboardEvent;
  9363. constructor(type: number, event: KeyboardEvent);
  9364. }
  9365. /**
  9366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9367. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9368. */
  9369. class KeyboardInfoPre extends KeyboardInfo {
  9370. constructor(type: number, event: KeyboardEvent);
  9371. skipOnPointerObservable: boolean;
  9372. }
  9373. }
  9374. declare module BABYLON {
  9375. class PointerEventTypes {
  9376. static _POINTERDOWN: number;
  9377. static _POINTERUP: number;
  9378. static _POINTERMOVE: number;
  9379. static _POINTERWHEEL: number;
  9380. static _POINTERPICK: number;
  9381. static _POINTERTAP: number;
  9382. static _POINTERDOUBLETAP: number;
  9383. static readonly POINTERDOWN: number;
  9384. static readonly POINTERUP: number;
  9385. static readonly POINTERMOVE: number;
  9386. static readonly POINTERWHEEL: number;
  9387. static readonly POINTERPICK: number;
  9388. static readonly POINTERTAP: number;
  9389. static readonly POINTERDOUBLETAP: number;
  9390. }
  9391. class PointerInfoBase {
  9392. type: number;
  9393. event: PointerEvent | MouseWheelEvent;
  9394. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9395. }
  9396. /**
  9397. * This class is used to store pointer related info for the onPrePointerObservable event.
  9398. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9399. */
  9400. class PointerInfoPre extends PointerInfoBase {
  9401. /**
  9402. * Ray from a pointer if availible (eg. 6dof controller)
  9403. */
  9404. ray: Nullable<Ray>;
  9405. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9406. localPosition: Vector2;
  9407. skipOnPointerObservable: boolean;
  9408. }
  9409. /**
  9410. * This type contains all the data related to a pointer event in Babylon.js.
  9411. * 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.
  9412. */
  9413. class PointerInfo extends PointerInfoBase {
  9414. pickInfo: Nullable<PickingInfo>;
  9415. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9416. }
  9417. }
  9418. declare module BABYLON {
  9419. class StickValues {
  9420. x: number;
  9421. y: number;
  9422. constructor(x: number, y: number);
  9423. }
  9424. interface GamepadButtonChanges {
  9425. changed: boolean;
  9426. pressChanged: boolean;
  9427. touchChanged: boolean;
  9428. valueChanged: boolean;
  9429. }
  9430. class Gamepad {
  9431. id: string;
  9432. index: number;
  9433. browserGamepad: any;
  9434. type: number;
  9435. private _leftStick;
  9436. private _rightStick;
  9437. _isConnected: boolean;
  9438. private _leftStickAxisX;
  9439. private _leftStickAxisY;
  9440. private _rightStickAxisX;
  9441. private _rightStickAxisY;
  9442. private _onleftstickchanged;
  9443. private _onrightstickchanged;
  9444. static GAMEPAD: number;
  9445. static GENERIC: number;
  9446. static XBOX: number;
  9447. static POSE_ENABLED: number;
  9448. protected _invertLeftStickY: boolean;
  9449. readonly isConnected: boolean;
  9450. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9451. onleftstickchanged(callback: (values: StickValues) => void): void;
  9452. onrightstickchanged(callback: (values: StickValues) => void): void;
  9453. leftStick: StickValues;
  9454. rightStick: StickValues;
  9455. update(): void;
  9456. dispose(): void;
  9457. }
  9458. class GenericPad extends Gamepad {
  9459. private _buttons;
  9460. private _onbuttondown;
  9461. private _onbuttonup;
  9462. onButtonDownObservable: Observable<number>;
  9463. onButtonUpObservable: Observable<number>;
  9464. onbuttondown(callback: (buttonPressed: number) => void): void;
  9465. onbuttonup(callback: (buttonReleased: number) => void): void;
  9466. constructor(id: string, index: number, browserGamepad: any);
  9467. private _setButtonValue(newValue, currentValue, buttonIndex);
  9468. update(): void;
  9469. dispose(): void;
  9470. }
  9471. }
  9472. declare module BABYLON {
  9473. class GamepadManager {
  9474. private _scene;
  9475. private _babylonGamepads;
  9476. private _oneGamepadConnected;
  9477. _isMonitoring: boolean;
  9478. private _gamepadEventSupported;
  9479. private _gamepadSupport;
  9480. onGamepadConnectedObservable: Observable<Gamepad>;
  9481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9482. private _onGamepadConnectedEvent;
  9483. private _onGamepadDisconnectedEvent;
  9484. constructor(_scene?: Scene | undefined);
  9485. readonly gamepads: Gamepad[];
  9486. getGamepadByType(type?: number): Nullable<Gamepad>;
  9487. dispose(): void;
  9488. private _addNewGamepad(gamepad);
  9489. private _startMonitoringGamepads();
  9490. private _stopMonitoringGamepads();
  9491. _checkGamepadsStatus(): void;
  9492. private _updateGamepadObjects();
  9493. }
  9494. }
  9495. declare module BABYLON {
  9496. /**
  9497. * Defines supported buttons for XBox360 compatible gamepads
  9498. */
  9499. enum Xbox360Button {
  9500. /** A */
  9501. A = 0,
  9502. /** B */
  9503. B = 1,
  9504. /** X */
  9505. X = 2,
  9506. /** Y */
  9507. Y = 3,
  9508. /** Start */
  9509. Start = 4,
  9510. /** Back */
  9511. Back = 5,
  9512. /** Left button */
  9513. LB = 6,
  9514. /** Right button */
  9515. RB = 7,
  9516. /** Left stick */
  9517. LeftStick = 8,
  9518. /** Right stick */
  9519. RightStick = 9,
  9520. }
  9521. /** Defines values for XBox360 DPad */
  9522. enum Xbox360Dpad {
  9523. /** Up */
  9524. Up = 0,
  9525. /** Down */
  9526. Down = 1,
  9527. /** Left */
  9528. Left = 2,
  9529. /** Right */
  9530. Right = 3,
  9531. }
  9532. /**
  9533. * Defines a XBox360 gamepad
  9534. */
  9535. class Xbox360Pad extends Gamepad {
  9536. private _leftTrigger;
  9537. private _rightTrigger;
  9538. private _onlefttriggerchanged;
  9539. private _onrighttriggerchanged;
  9540. private _onbuttondown;
  9541. private _onbuttonup;
  9542. private _ondpaddown;
  9543. private _ondpadup;
  9544. /** Observable raised when a button is pressed */
  9545. onButtonDownObservable: Observable<Xbox360Button>;
  9546. /** Observable raised when a button is released */
  9547. onButtonUpObservable: Observable<Xbox360Button>;
  9548. /** Observable raised when a pad is pressed */
  9549. onPadDownObservable: Observable<Xbox360Dpad>;
  9550. /** Observable raised when a pad is released */
  9551. onPadUpObservable: Observable<Xbox360Dpad>;
  9552. private _buttonA;
  9553. private _buttonB;
  9554. private _buttonX;
  9555. private _buttonY;
  9556. private _buttonBack;
  9557. private _buttonStart;
  9558. private _buttonLB;
  9559. private _buttonRB;
  9560. private _buttonLeftStick;
  9561. private _buttonRightStick;
  9562. private _dPadUp;
  9563. private _dPadDown;
  9564. private _dPadLeft;
  9565. private _dPadRight;
  9566. private _isXboxOnePad;
  9567. /**
  9568. * Creates a new XBox360 gamepad object
  9569. * @param id defines the id of this gamepad
  9570. * @param index defines its index
  9571. * @param gamepad defines the internal HTML gamepad object
  9572. * @param xboxOne defines if it is a XBox One gamepad
  9573. */
  9574. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9575. /**
  9576. * Defines the callback to call when left trigger is pressed
  9577. * @param callback defines the callback to use
  9578. */
  9579. onlefttriggerchanged(callback: (value: number) => void): void;
  9580. /**
  9581. * Defines the callback to call when right trigger is pressed
  9582. * @param callback defines the callback to use
  9583. */
  9584. onrighttriggerchanged(callback: (value: number) => void): void;
  9585. /**
  9586. * Gets or sets left trigger value
  9587. */
  9588. leftTrigger: number;
  9589. /**
  9590. * Gets or sets right trigger value
  9591. */
  9592. rightTrigger: number;
  9593. /**
  9594. * Defines the callback to call when a button is pressed
  9595. * @param callback defines the callback to use
  9596. */
  9597. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9598. /**
  9599. * Defines the callback to call when a button is released
  9600. * @param callback defines the callback to use
  9601. */
  9602. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9603. /**
  9604. * Defines the callback to call when a pad is pressed
  9605. * @param callback defines the callback to use
  9606. */
  9607. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9608. /**
  9609. * Defines the callback to call when a pad is released
  9610. * @param callback defines the callback to use
  9611. */
  9612. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9613. private _setButtonValue(newValue, currentValue, buttonType);
  9614. private _setDPadValue(newValue, currentValue, buttonType);
  9615. /** Gets or sets value of A button */
  9616. buttonA: number;
  9617. /** Gets or sets value of B button */
  9618. buttonB: number;
  9619. /** Gets or sets value of X button */
  9620. buttonX: number;
  9621. /** Gets or sets value of Y button */
  9622. buttonY: number;
  9623. /** Gets or sets value of Start button */
  9624. buttonStart: number;
  9625. /** Gets or sets value of Back button */
  9626. buttonBack: number;
  9627. /** Gets or sets value of Left button */
  9628. buttonLB: number;
  9629. /** Gets or sets value of Right button */
  9630. buttonRB: number;
  9631. /** Gets or sets value of left stick */
  9632. buttonLeftStick: number;
  9633. /** Gets or sets value of right stick */
  9634. buttonRightStick: number;
  9635. /** Gets or sets value of DPad up */
  9636. dPadUp: number;
  9637. /** Gets or sets value of DPad down */
  9638. dPadDown: number;
  9639. /** Gets or sets value of DPad left */
  9640. dPadLeft: number;
  9641. /** Gets or sets value of DPad right */
  9642. dPadRight: number;
  9643. /**
  9644. * Force the gamepad to synchronize with device values
  9645. */
  9646. update(): void;
  9647. dispose(): void;
  9648. }
  9649. }
  9650. declare module BABYLON {
  9651. /**
  9652. * Single axis drag gizmo
  9653. */
  9654. class AxisDragGizmo extends Gizmo {
  9655. /**
  9656. * Drag behavior responsible for the gizmos dragging interactions
  9657. */
  9658. dragBehavior: PointerDragBehavior;
  9659. private _pointerObserver;
  9660. /**
  9661. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9662. */
  9663. snapDistance: number;
  9664. /**
  9665. * Event that fires each time the gizmo snaps to a new location.
  9666. * * snapDistance is the the change in distance
  9667. */
  9668. onSnapObservable: Observable<{
  9669. snapDistance: number;
  9670. }>;
  9671. /**
  9672. * Creates an AxisDragGizmo
  9673. * @param gizmoLayer The utility layer the gizmo will be added to
  9674. * @param dragAxis The axis which the gizmo will be able to drag on
  9675. * @param color The color of the gizmo
  9676. */
  9677. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9679. /**
  9680. * Disposes of the gizmo
  9681. */
  9682. dispose(): void;
  9683. }
  9684. }
  9685. declare module BABYLON {
  9686. /**
  9687. * Single axis scale gizmo
  9688. */
  9689. class AxisScaleGizmo extends Gizmo {
  9690. /**
  9691. * Drag behavior responsible for the gizmos dragging interactions
  9692. */
  9693. dragBehavior: PointerDragBehavior;
  9694. private _pointerObserver;
  9695. /**
  9696. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9697. */
  9698. snapDistance: number;
  9699. /**
  9700. * Event that fires each time the gizmo snaps to a new location.
  9701. * * snapDistance is the the change in distance
  9702. */
  9703. onSnapObservable: Observable<{
  9704. snapDistance: number;
  9705. }>;
  9706. /**
  9707. * Creates an AxisScaleGizmo
  9708. * @param gizmoLayer The utility layer the gizmo will be added to
  9709. * @param dragAxis The axis which the gizmo will be able to scale on
  9710. * @param color The color of the gizmo
  9711. */
  9712. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9714. /**
  9715. * Disposes of the gizmo
  9716. */
  9717. dispose(): void;
  9718. }
  9719. }
  9720. declare module BABYLON {
  9721. /**
  9722. * Bounding box gizmo
  9723. */
  9724. class BoundingBoxGizmo extends Gizmo {
  9725. private _lineBoundingBox;
  9726. private _rotateSpheresParent;
  9727. private _scaleBoxesParent;
  9728. private _boundingDimensions;
  9729. private _renderObserver;
  9730. private _pointerObserver;
  9731. private _scaleDragSpeed;
  9732. private _tmpQuaternion;
  9733. private _tmpVector;
  9734. /**
  9735. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9736. */
  9737. rotationSphereSize: number;
  9738. /**
  9739. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9740. */
  9741. scaleBoxSize: number;
  9742. /**
  9743. * 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)
  9744. */
  9745. fixedDragMeshScreenSize: boolean;
  9746. /**
  9747. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9748. */
  9749. fixedDragMeshScreenSizeDistanceFactor: number;
  9750. /**
  9751. * Fired when a rotation sphere or scale box is dragged
  9752. */
  9753. onDragStartObservable: Observable<{}>;
  9754. /**
  9755. * Fired when a rotation sphere or scale box drag is started
  9756. */
  9757. onDragObservable: Observable<{}>;
  9758. /**
  9759. * Fired when a rotation sphere or scale box drag is needed
  9760. */
  9761. onDragEndObservable: Observable<{}>;
  9762. /**
  9763. * Creates an BoundingBoxGizmo
  9764. * @param gizmoLayer The utility layer the gizmo will be added to
  9765. * @param color The color of the gizmo
  9766. */
  9767. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9768. private _selectNode(selectedMesh);
  9769. private _updateBoundingBox();
  9770. /**
  9771. * Enables rotation on the specified axis and disables rotation on the others
  9772. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9773. */
  9774. setEnabledRotationAxis(axis: string): void;
  9775. /**
  9776. * Disposes of the gizmo
  9777. */
  9778. dispose(): void;
  9779. }
  9780. }
  9781. declare module BABYLON {
  9782. /**
  9783. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9784. */
  9785. class Gizmo implements IDisposable {
  9786. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9787. /**
  9788. * The root mesh of the gizmo
  9789. */
  9790. protected _rootMesh: Mesh;
  9791. private _attachedMesh;
  9792. private _scaleFactor;
  9793. /**
  9794. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9795. * * When set, interactions will be enabled
  9796. */
  9797. attachedMesh: Nullable<AbstractMesh>;
  9798. /**
  9799. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9800. */
  9801. updateGizmoRotationToMatchAttachedMesh: boolean;
  9802. /**
  9803. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9804. */
  9805. updateGizmoPositionToMatchAttachedMesh: boolean;
  9806. /**
  9807. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9808. */
  9809. protected _updateScale: boolean;
  9810. protected _interactionsEnabled: boolean;
  9811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9812. private _beforeRenderObserver;
  9813. /**
  9814. * Creates a gizmo
  9815. * @param gizmoLayer The utility layer the gizmo will be added to
  9816. */
  9817. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer?: UtilityLayerRenderer);
  9818. /**
  9819. * Disposes of the gizmo
  9820. */
  9821. dispose(): void;
  9822. }
  9823. }
  9824. declare module BABYLON {
  9825. /**
  9826. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9827. */
  9828. class GizmoManager implements IDisposable {
  9829. private scene;
  9830. private _gizmoLayer;
  9831. private _gizmoSet;
  9832. private _pointerObserver;
  9833. /**
  9834. * Instatiates a gizmo manager
  9835. * @param scene the scene to overlay the gizmos on top of
  9836. * @param options If only a single gizmo should exist at one time
  9837. */
  9838. constructor(scene: Scene, options?: {
  9839. singleGizmo?: boolean;
  9840. });
  9841. /**
  9842. * Disposes of the gizmo manager
  9843. */
  9844. dispose(): void;
  9845. private _clearGizmos();
  9846. }
  9847. }
  9848. declare module BABYLON {
  9849. /**
  9850. * Single plane rotation gizmo
  9851. */
  9852. class PlaneRotationGizmo extends Gizmo {
  9853. /**
  9854. * Drag behavior responsible for the gizmos dragging interactions
  9855. */
  9856. dragBehavior: PointerDragBehavior;
  9857. private _pointerObserver;
  9858. /**
  9859. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  9860. */
  9861. snapDistance: number;
  9862. /**
  9863. * Event that fires each time the gizmo snaps to a new location.
  9864. * * snapDistance is the the change in distance
  9865. */
  9866. onSnapObservable: Observable<{
  9867. snapDistance: number;
  9868. }>;
  9869. /**
  9870. * Creates a PlaneRotationGizmo
  9871. * @param gizmoLayer The utility layer the gizmo will be added to
  9872. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9873. * @param color The color of the gizmo
  9874. */
  9875. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9876. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9877. /**
  9878. * Disposes of the gizmo
  9879. */
  9880. dispose(): void;
  9881. }
  9882. }
  9883. declare module BABYLON {
  9884. /**
  9885. * Gizmo that enables dragging a mesh along 3 axis
  9886. */
  9887. class PositionGizmo extends Gizmo {
  9888. /**
  9889. * Internal gizmo used for interactions on the x axis
  9890. */
  9891. xGizmo: AxisDragGizmo;
  9892. /**
  9893. * Internal gizmo used for interactions on the y axis
  9894. */
  9895. yGizmo: AxisDragGizmo;
  9896. /**
  9897. * Internal gizmo used for interactions on the z axis
  9898. */
  9899. zGizmo: AxisDragGizmo;
  9900. attachedMesh: Nullable<AbstractMesh>;
  9901. /**
  9902. * Creates a PositionGizmo
  9903. * @param gizmoLayer The utility layer the gizmo will be added to
  9904. */
  9905. constructor(gizmoLayer?: UtilityLayerRenderer);
  9906. updateGizmoRotationToMatchAttachedMesh: boolean;
  9907. /**
  9908. * Disposes of the gizmo
  9909. */
  9910. dispose(): void;
  9911. }
  9912. }
  9913. declare module BABYLON {
  9914. /**
  9915. * Gizmo that enables rotating a mesh along 3 axis
  9916. */
  9917. class RotationGizmo extends Gizmo {
  9918. /**
  9919. * Internal gizmo used for interactions on the x axis
  9920. */
  9921. xGizmo: PlaneRotationGizmo;
  9922. /**
  9923. * Internal gizmo used for interactions on the y axis
  9924. */
  9925. yGizmo: PlaneRotationGizmo;
  9926. /**
  9927. * Internal gizmo used for interactions on the z axis
  9928. */
  9929. zGizmo: PlaneRotationGizmo;
  9930. attachedMesh: Nullable<AbstractMesh>;
  9931. /**
  9932. * Creates a RotationGizmo
  9933. * @param gizmoLayer The utility layer the gizmo will be added to
  9934. */
  9935. constructor(gizmoLayer?: UtilityLayerRenderer);
  9936. updateGizmoRotationToMatchAttachedMesh: boolean;
  9937. /**
  9938. * Disposes of the gizmo
  9939. */
  9940. dispose(): void;
  9941. }
  9942. }
  9943. declare module BABYLON {
  9944. /**
  9945. * Gizmo that enables scaling a mesh along 3 axis
  9946. */
  9947. class ScaleGizmo extends Gizmo {
  9948. /**
  9949. * Internal gizmo used for interactions on the x axis
  9950. */
  9951. xGizmo: AxisScaleGizmo;
  9952. /**
  9953. * Internal gizmo used for interactions on the y axis
  9954. */
  9955. yGizmo: AxisScaleGizmo;
  9956. /**
  9957. * Internal gizmo used for interactions on the z axis
  9958. */
  9959. zGizmo: AxisScaleGizmo;
  9960. attachedMesh: Nullable<AbstractMesh>;
  9961. /**
  9962. * Creates a ScaleGizmo
  9963. * @param gizmoLayer The utility layer the gizmo will be added to
  9964. */
  9965. constructor(gizmoLayer?: UtilityLayerRenderer);
  9966. updateGizmoRotationToMatchAttachedMesh: boolean;
  9967. /**
  9968. * Disposes of the gizmo
  9969. */
  9970. dispose(): void;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * This class can be used to get instrumentation data from a Babylon engine
  9976. */
  9977. class EngineInstrumentation implements IDisposable {
  9978. engine: Engine;
  9979. private _captureGPUFrameTime;
  9980. private _gpuFrameTimeToken;
  9981. private _gpuFrameTime;
  9982. private _captureShaderCompilationTime;
  9983. private _shaderCompilationTime;
  9984. private _onBeginFrameObserver;
  9985. private _onEndFrameObserver;
  9986. private _onBeforeShaderCompilationObserver;
  9987. private _onAfterShaderCompilationObserver;
  9988. /**
  9989. * Gets the perf counter used for GPU frame time
  9990. */
  9991. readonly gpuFrameTimeCounter: PerfCounter;
  9992. /**
  9993. * Gets the GPU frame time capture status
  9994. */
  9995. /**
  9996. * Enable or disable the GPU frame time capture
  9997. */
  9998. captureGPUFrameTime: boolean;
  9999. /**
  10000. * Gets the perf counter used for shader compilation time
  10001. */
  10002. readonly shaderCompilationTimeCounter: PerfCounter;
  10003. /**
  10004. * Gets the shader compilation time capture status
  10005. */
  10006. /**
  10007. * Enable or disable the shader compilation time capture
  10008. */
  10009. captureShaderCompilationTime: boolean;
  10010. constructor(engine: Engine);
  10011. dispose(): void;
  10012. }
  10013. }
  10014. declare module BABYLON {
  10015. /**
  10016. * This class can be used to get instrumentation data from a Babylon engine
  10017. */
  10018. class SceneInstrumentation implements IDisposable {
  10019. scene: Scene;
  10020. private _captureActiveMeshesEvaluationTime;
  10021. private _activeMeshesEvaluationTime;
  10022. private _captureRenderTargetsRenderTime;
  10023. private _renderTargetsRenderTime;
  10024. private _captureFrameTime;
  10025. private _frameTime;
  10026. private _captureRenderTime;
  10027. private _renderTime;
  10028. private _captureInterFrameTime;
  10029. private _interFrameTime;
  10030. private _captureParticlesRenderTime;
  10031. private _particlesRenderTime;
  10032. private _captureSpritesRenderTime;
  10033. private _spritesRenderTime;
  10034. private _capturePhysicsTime;
  10035. private _physicsTime;
  10036. private _captureAnimationsTime;
  10037. private _animationsTime;
  10038. private _captureCameraRenderTime;
  10039. private _cameraRenderTime;
  10040. private _onBeforeActiveMeshesEvaluationObserver;
  10041. private _onAfterActiveMeshesEvaluationObserver;
  10042. private _onBeforeRenderTargetsRenderObserver;
  10043. private _onAfterRenderTargetsRenderObserver;
  10044. private _onAfterRenderObserver;
  10045. private _onBeforeDrawPhaseObserver;
  10046. private _onAfterDrawPhaseObserver;
  10047. private _onBeforeAnimationsObserver;
  10048. private _onBeforeParticlesRenderingObserver;
  10049. private _onAfterParticlesRenderingObserver;
  10050. private _onBeforeSpritesRenderingObserver;
  10051. private _onAfterSpritesRenderingObserver;
  10052. private _onBeforePhysicsObserver;
  10053. private _onAfterPhysicsObserver;
  10054. private _onAfterAnimationsObserver;
  10055. private _onBeforeCameraRenderObserver;
  10056. private _onAfterCameraRenderObserver;
  10057. /**
  10058. * Gets the perf counter used for active meshes evaluation time
  10059. */
  10060. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10061. /**
  10062. * Gets the active meshes evaluation time capture status
  10063. */
  10064. /**
  10065. * Enable or disable the active meshes evaluation time capture
  10066. */
  10067. captureActiveMeshesEvaluationTime: boolean;
  10068. /**
  10069. * Gets the perf counter used for render targets render time
  10070. */
  10071. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10072. /**
  10073. * Gets the render targets render time capture status
  10074. */
  10075. /**
  10076. * Enable or disable the render targets render time capture
  10077. */
  10078. captureRenderTargetsRenderTime: boolean;
  10079. /**
  10080. * Gets the perf counter used for particles render time
  10081. */
  10082. readonly particlesRenderTimeCounter: PerfCounter;
  10083. /**
  10084. * Gets the particles render time capture status
  10085. */
  10086. /**
  10087. * Enable or disable the particles render time capture
  10088. */
  10089. captureParticlesRenderTime: boolean;
  10090. /**
  10091. * Gets the perf counter used for sprites render time
  10092. */
  10093. readonly spritesRenderTimeCounter: PerfCounter;
  10094. /**
  10095. * Gets the sprites render time capture status
  10096. */
  10097. /**
  10098. * Enable or disable the sprites render time capture
  10099. */
  10100. captureSpritesRenderTime: boolean;
  10101. /**
  10102. * Gets the perf counter used for physics time
  10103. */
  10104. readonly physicsTimeCounter: PerfCounter;
  10105. /**
  10106. * Gets the physics time capture status
  10107. */
  10108. /**
  10109. * Enable or disable the physics time capture
  10110. */
  10111. capturePhysicsTime: boolean;
  10112. /**
  10113. * Gets the perf counter used for animations time
  10114. */
  10115. readonly animationsTimeCounter: PerfCounter;
  10116. /**
  10117. * Gets the animations time capture status
  10118. */
  10119. /**
  10120. * Enable or disable the animations time capture
  10121. */
  10122. captureAnimationsTime: boolean;
  10123. /**
  10124. * Gets the perf counter used for frame time capture
  10125. */
  10126. readonly frameTimeCounter: PerfCounter;
  10127. /**
  10128. * Gets the frame time capture status
  10129. */
  10130. /**
  10131. * Enable or disable the frame time capture
  10132. */
  10133. captureFrameTime: boolean;
  10134. /**
  10135. * Gets the perf counter used for inter-frames time capture
  10136. */
  10137. readonly interFrameTimeCounter: PerfCounter;
  10138. /**
  10139. * Gets the inter-frames time capture status
  10140. */
  10141. /**
  10142. * Enable or disable the inter-frames time capture
  10143. */
  10144. captureInterFrameTime: boolean;
  10145. /**
  10146. * Gets the perf counter used for render time capture
  10147. */
  10148. readonly renderTimeCounter: PerfCounter;
  10149. /**
  10150. * Gets the render time capture status
  10151. */
  10152. /**
  10153. * Enable or disable the render time capture
  10154. */
  10155. captureRenderTime: boolean;
  10156. /**
  10157. * Gets the perf counter used for camera render time capture
  10158. */
  10159. readonly cameraRenderTimeCounter: PerfCounter;
  10160. /**
  10161. * Gets the camera render time capture status
  10162. */
  10163. /**
  10164. * Enable or disable the camera render time capture
  10165. */
  10166. captureCameraRenderTime: boolean;
  10167. /**
  10168. * Gets the perf counter used for draw calls
  10169. */
  10170. readonly drawCallsCounter: PerfCounter;
  10171. /**
  10172. * Gets the perf counter used for texture collisions
  10173. */
  10174. readonly textureCollisionsCounter: PerfCounter;
  10175. constructor(scene: Scene);
  10176. dispose(): void;
  10177. }
  10178. }
  10179. declare module BABYLON {
  10180. /**
  10181. * @hidden
  10182. **/
  10183. class _TimeToken {
  10184. _startTimeQuery: Nullable<WebGLQuery>;
  10185. _endTimeQuery: Nullable<WebGLQuery>;
  10186. _timeElapsedQuery: Nullable<WebGLQuery>;
  10187. _timeElapsedQueryEnded: boolean;
  10188. }
  10189. }
  10190. declare module BABYLON {
  10191. /**
  10192. * Represents the different options available during the creation of
  10193. * a Environment helper.
  10194. *
  10195. * This can control the default ground, skybox and image processing setup of your scene.
  10196. */
  10197. interface IEnvironmentHelperOptions {
  10198. /**
  10199. * Specifies wether or not to create a ground.
  10200. * True by default.
  10201. */
  10202. createGround: boolean;
  10203. /**
  10204. * Specifies the ground size.
  10205. * 15 by default.
  10206. */
  10207. groundSize: number;
  10208. /**
  10209. * The texture used on the ground for the main color.
  10210. * Comes from the BabylonJS CDN by default.
  10211. *
  10212. * Remarks: Can be either a texture or a url.
  10213. */
  10214. groundTexture: string | BaseTexture;
  10215. /**
  10216. * The color mixed in the ground texture by default.
  10217. * BabylonJS clearColor by default.
  10218. */
  10219. groundColor: Color3;
  10220. /**
  10221. * Specifies the ground opacity.
  10222. * 1 by default.
  10223. */
  10224. groundOpacity: number;
  10225. /**
  10226. * Enables the ground to receive shadows.
  10227. * True by default.
  10228. */
  10229. enableGroundShadow: boolean;
  10230. /**
  10231. * Helps preventing the shadow to be fully black on the ground.
  10232. * 0.5 by default.
  10233. */
  10234. groundShadowLevel: number;
  10235. /**
  10236. * Creates a mirror texture attach to the ground.
  10237. * false by default.
  10238. */
  10239. enableGroundMirror: boolean;
  10240. /**
  10241. * Specifies the ground mirror size ratio.
  10242. * 0.3 by default as the default kernel is 64.
  10243. */
  10244. groundMirrorSizeRatio: number;
  10245. /**
  10246. * Specifies the ground mirror blur kernel size.
  10247. * 64 by default.
  10248. */
  10249. groundMirrorBlurKernel: number;
  10250. /**
  10251. * Specifies the ground mirror visibility amount.
  10252. * 1 by default
  10253. */
  10254. groundMirrorAmount: number;
  10255. /**
  10256. * Specifies the ground mirror reflectance weight.
  10257. * This uses the standard weight of the background material to setup the fresnel effect
  10258. * of the mirror.
  10259. * 1 by default.
  10260. */
  10261. groundMirrorFresnelWeight: number;
  10262. /**
  10263. * Specifies the ground mirror Falloff distance.
  10264. * This can helps reducing the size of the reflection.
  10265. * 0 by Default.
  10266. */
  10267. groundMirrorFallOffDistance: number;
  10268. /**
  10269. * Specifies the ground mirror texture type.
  10270. * Unsigned Int by Default.
  10271. */
  10272. groundMirrorTextureType: number;
  10273. /**
  10274. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10275. * the shown objects.
  10276. */
  10277. groundYBias: number;
  10278. /**
  10279. * Specifies wether or not to create a skybox.
  10280. * True by default.
  10281. */
  10282. createSkybox: boolean;
  10283. /**
  10284. * Specifies the skybox size.
  10285. * 20 by default.
  10286. */
  10287. skyboxSize: number;
  10288. /**
  10289. * The texture used on the skybox for the main color.
  10290. * Comes from the BabylonJS CDN by default.
  10291. *
  10292. * Remarks: Can be either a texture or a url.
  10293. */
  10294. skyboxTexture: string | BaseTexture;
  10295. /**
  10296. * The color mixed in the skybox texture by default.
  10297. * BabylonJS clearColor by default.
  10298. */
  10299. skyboxColor: Color3;
  10300. /**
  10301. * The background rotation around the Y axis of the scene.
  10302. * This helps aligning the key lights of your scene with the background.
  10303. * 0 by default.
  10304. */
  10305. backgroundYRotation: number;
  10306. /**
  10307. * Compute automatically the size of the elements to best fit with the scene.
  10308. */
  10309. sizeAuto: boolean;
  10310. /**
  10311. * Default position of the rootMesh if autoSize is not true.
  10312. */
  10313. rootPosition: Vector3;
  10314. /**
  10315. * Sets up the image processing in the scene.
  10316. * true by default.
  10317. */
  10318. setupImageProcessing: boolean;
  10319. /**
  10320. * The texture used as your environment texture in the scene.
  10321. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10322. *
  10323. * Remarks: Can be either a texture or a url.
  10324. */
  10325. environmentTexture: string | BaseTexture;
  10326. /**
  10327. * The value of the exposure to apply to the scene.
  10328. * 0.6 by default if setupImageProcessing is true.
  10329. */
  10330. cameraExposure: number;
  10331. /**
  10332. * The value of the contrast to apply to the scene.
  10333. * 1.6 by default if setupImageProcessing is true.
  10334. */
  10335. cameraContrast: number;
  10336. /**
  10337. * Specifies wether or not tonemapping should be enabled in the scene.
  10338. * true by default if setupImageProcessing is true.
  10339. */
  10340. toneMappingEnabled: boolean;
  10341. }
  10342. /**
  10343. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10344. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10345. * It also helps with the default setup of your imageProcessing configuration.
  10346. */
  10347. class EnvironmentHelper {
  10348. /**
  10349. * Default ground texture URL.
  10350. */
  10351. private static _groundTextureCDNUrl;
  10352. /**
  10353. * Default skybox texture URL.
  10354. */
  10355. private static _skyboxTextureCDNUrl;
  10356. /**
  10357. * Default environment texture URL.
  10358. */
  10359. private static _environmentTextureCDNUrl;
  10360. /**
  10361. * Creates the default options for the helper.
  10362. */
  10363. private static _getDefaultOptions();
  10364. private _rootMesh;
  10365. /**
  10366. * Gets the root mesh created by the helper.
  10367. */
  10368. readonly rootMesh: Mesh;
  10369. private _skybox;
  10370. /**
  10371. * Gets the skybox created by the helper.
  10372. */
  10373. readonly skybox: Nullable<Mesh>;
  10374. private _skyboxTexture;
  10375. /**
  10376. * Gets the skybox texture created by the helper.
  10377. */
  10378. readonly skyboxTexture: Nullable<BaseTexture>;
  10379. private _skyboxMaterial;
  10380. /**
  10381. * Gets the skybox material created by the helper.
  10382. */
  10383. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10384. private _ground;
  10385. /**
  10386. * Gets the ground mesh created by the helper.
  10387. */
  10388. readonly ground: Nullable<Mesh>;
  10389. private _groundTexture;
  10390. /**
  10391. * Gets the ground texture created by the helper.
  10392. */
  10393. readonly groundTexture: Nullable<BaseTexture>;
  10394. private _groundMirror;
  10395. /**
  10396. * Gets the ground mirror created by the helper.
  10397. */
  10398. readonly groundMirror: Nullable<MirrorTexture>;
  10399. /**
  10400. * Gets the ground mirror render list to helps pushing the meshes
  10401. * you wish in the ground reflection.
  10402. */
  10403. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10404. private _groundMaterial;
  10405. /**
  10406. * Gets the ground material created by the helper.
  10407. */
  10408. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10409. /**
  10410. * Stores the creation options.
  10411. */
  10412. private readonly _scene;
  10413. private _options;
  10414. /**
  10415. * This observable will be notified with any error during the creation of the environment,
  10416. * mainly texture creation errors.
  10417. */
  10418. onErrorObservable: Observable<{
  10419. message?: string;
  10420. exception?: any;
  10421. }>;
  10422. /**
  10423. * constructor
  10424. * @param options
  10425. * @param scene The scene to add the material to
  10426. */
  10427. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10428. /**
  10429. * Updates the background according to the new options
  10430. * @param options
  10431. */
  10432. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10433. /**
  10434. * Sets the primary color of all the available elements.
  10435. * @param color the main color to affect to the ground and the background
  10436. */
  10437. setMainColor(color: Color3): void;
  10438. /**
  10439. * Setup the image processing according to the specified options.
  10440. */
  10441. private _setupImageProcessing();
  10442. /**
  10443. * Setup the environment texture according to the specified options.
  10444. */
  10445. private _setupEnvironmentTexture();
  10446. /**
  10447. * Setup the background according to the specified options.
  10448. */
  10449. private _setupBackground();
  10450. /**
  10451. * Get the scene sizes according to the setup.
  10452. */
  10453. private _getSceneSize();
  10454. /**
  10455. * Setup the ground according to the specified options.
  10456. */
  10457. private _setupGround(sceneSize);
  10458. /**
  10459. * Setup the ground material according to the specified options.
  10460. */
  10461. private _setupGroundMaterial();
  10462. /**
  10463. * Setup the ground diffuse texture according to the specified options.
  10464. */
  10465. private _setupGroundDiffuseTexture();
  10466. /**
  10467. * Setup the ground mirror texture according to the specified options.
  10468. */
  10469. private _setupGroundMirrorTexture(sceneSize);
  10470. /**
  10471. * Setup the ground to receive the mirror texture.
  10472. */
  10473. private _setupMirrorInGroundMaterial();
  10474. /**
  10475. * Setup the skybox according to the specified options.
  10476. */
  10477. private _setupSkybox(sceneSize);
  10478. /**
  10479. * Setup the skybox material according to the specified options.
  10480. */
  10481. private _setupSkyboxMaterial();
  10482. /**
  10483. * Setup the skybox reflection texture according to the specified options.
  10484. */
  10485. private _setupSkyboxReflectionTexture();
  10486. private _errorHandler;
  10487. /**
  10488. * Dispose all the elements created by the Helper.
  10489. */
  10490. dispose(): void;
  10491. }
  10492. }
  10493. declare module BABYLON {
  10494. /**
  10495. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10496. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10497. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10498. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10499. */
  10500. class PhotoDome extends Node {
  10501. private _useDirectMapping;
  10502. /**
  10503. * The texture being displayed on the sphere
  10504. */
  10505. protected _photoTexture: Texture;
  10506. /**
  10507. * Gets or sets the texture being displayed on the sphere
  10508. */
  10509. photoTexture: Texture;
  10510. /**
  10511. * The skybox material
  10512. */
  10513. protected _material: BackgroundMaterial;
  10514. /**
  10515. * The surface used for the skybox
  10516. */
  10517. protected _mesh: Mesh;
  10518. /**
  10519. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10520. * Also see the options.resolution property.
  10521. */
  10522. fovMultiplier: number;
  10523. /**
  10524. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10525. * @param name Element's name, child elements will append suffixes for their own names.
  10526. * @param urlsOfPhoto define the url of the photo to display
  10527. * @param options An object containing optional or exposed sub element properties
  10528. */
  10529. constructor(name: string, urlOfPhoto: string, options: {
  10530. resolution?: number;
  10531. size?: number;
  10532. useDirectMapping?: boolean;
  10533. }, scene: Scene);
  10534. /**
  10535. * Releases resources associated with this node.
  10536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10538. */
  10539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10540. }
  10541. }
  10542. declare module BABYLON {
  10543. /**
  10544. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10545. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10546. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10547. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10548. */
  10549. class VideoDome extends Node {
  10550. private _useDirectMapping;
  10551. /**
  10552. * The video texture being displayed on the sphere
  10553. */
  10554. protected _videoTexture: VideoTexture;
  10555. /**
  10556. * Gets the video texture being displayed on the sphere
  10557. */
  10558. readonly videoTexture: VideoTexture;
  10559. /**
  10560. * The skybox material
  10561. */
  10562. protected _material: BackgroundMaterial;
  10563. /**
  10564. * The surface used for the skybox
  10565. */
  10566. protected _mesh: Mesh;
  10567. /**
  10568. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10569. * Also see the options.resolution property.
  10570. */
  10571. fovMultiplier: number;
  10572. /**
  10573. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10574. * @param name Element's name, child elements will append suffixes for their own names.
  10575. * @param urlsOrVideo defines the url(s) or the video element to use
  10576. * @param options An object containing optional or exposed sub element properties
  10577. */
  10578. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10579. resolution?: number;
  10580. clickToPlay?: boolean;
  10581. autoPlay?: boolean;
  10582. loop?: boolean;
  10583. size?: number;
  10584. poster?: string;
  10585. useDirectMapping?: boolean;
  10586. }, scene: Scene);
  10587. /**
  10588. * Releases resources associated with this node.
  10589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10591. */
  10592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10593. }
  10594. }
  10595. declare module BABYLON {
  10596. /**
  10597. * Effect layer options. This helps customizing the behaviour
  10598. * of the effect layer.
  10599. */
  10600. interface IEffectLayerOptions {
  10601. /**
  10602. * Multiplication factor apply to the canvas size to compute the render target size
  10603. * used to generated the objects (the smaller the faster).
  10604. */
  10605. mainTextureRatio: number;
  10606. /**
  10607. * Enforces a fixed size texture to ensure effect stability across devices.
  10608. */
  10609. mainTextureFixedSize?: number;
  10610. /**
  10611. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10612. */
  10613. alphaBlendingMode: number;
  10614. /**
  10615. * The camera attached to the layer.
  10616. */
  10617. camera: Nullable<Camera>;
  10618. /**
  10619. * The rendering group to draw the layer in.
  10620. */
  10621. renderingGroupId: number;
  10622. }
  10623. /**
  10624. * The effect layer Helps adding post process effect blended with the main pass.
  10625. *
  10626. * This can be for instance use to generate glow or higlight effects on the scene.
  10627. *
  10628. * The effect layer class can not be used directly and is intented to inherited from to be
  10629. * customized per effects.
  10630. */
  10631. abstract class EffectLayer {
  10632. private _vertexBuffers;
  10633. private _indexBuffer;
  10634. private _cachedDefines;
  10635. private _effectLayerMapGenerationEffect;
  10636. private _effectLayerOptions;
  10637. private _mergeEffect;
  10638. protected _scene: Scene;
  10639. protected _engine: Engine;
  10640. protected _maxSize: number;
  10641. protected _mainTextureDesiredSize: ISize;
  10642. protected _mainTexture: RenderTargetTexture;
  10643. protected _shouldRender: boolean;
  10644. protected _postProcesses: PostProcess[];
  10645. protected _textures: BaseTexture[];
  10646. protected _emissiveTextureAndColor: {
  10647. texture: Nullable<BaseTexture>;
  10648. color: Color4;
  10649. };
  10650. /**
  10651. * The name of the layer
  10652. */
  10653. name: string;
  10654. /**
  10655. * The clear color of the texture used to generate the glow map.
  10656. */
  10657. neutralColor: Color4;
  10658. /**
  10659. * Specifies wether the highlight layer is enabled or not.
  10660. */
  10661. isEnabled: boolean;
  10662. /**
  10663. * Gets the camera attached to the layer.
  10664. */
  10665. readonly camera: Nullable<Camera>;
  10666. /**
  10667. * Gets the rendering group id the layer should render in.
  10668. */
  10669. readonly renderingGroupId: number;
  10670. /**
  10671. * An event triggered when the effect layer has been disposed.
  10672. */
  10673. onDisposeObservable: Observable<EffectLayer>;
  10674. /**
  10675. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10676. */
  10677. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10678. /**
  10679. * An event triggered when the generated texture is being merged in the scene.
  10680. */
  10681. onBeforeComposeObservable: Observable<EffectLayer>;
  10682. /**
  10683. * An event triggered when the generated texture has been merged in the scene.
  10684. */
  10685. onAfterComposeObservable: Observable<EffectLayer>;
  10686. /**
  10687. * An event triggered when the efffect layer changes its size.
  10688. */
  10689. onSizeChangedObservable: Observable<EffectLayer>;
  10690. /**
  10691. * Instantiates a new effect Layer and references it in the scene.
  10692. * @param name The name of the layer
  10693. * @param scene The scene to use the layer in
  10694. */
  10695. constructor(
  10696. /** The Friendly of the effect in the scene */
  10697. name: string, scene: Scene);
  10698. /**
  10699. * Get the effect name of the layer.
  10700. * @return The effect name
  10701. */
  10702. abstract getEffectName(): string;
  10703. /**
  10704. * Checks for the readiness of the element composing the layer.
  10705. * @param subMesh the mesh to check for
  10706. * @param useInstances specify wether or not to use instances to render the mesh
  10707. * @return true if ready otherwise, false
  10708. */
  10709. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10710. /**
  10711. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10712. * @returns true if the effect requires stencil during the main canvas render pass.
  10713. */
  10714. abstract needStencil(): boolean;
  10715. /**
  10716. * Create the merge effect. This is the shader use to blit the information back
  10717. * to the main canvas at the end of the scene rendering.
  10718. * @returns The effect containing the shader used to merge the effect on the main canvas
  10719. */
  10720. protected abstract _createMergeEffect(): Effect;
  10721. /**
  10722. * Creates the render target textures and post processes used in the effect layer.
  10723. */
  10724. protected abstract _createTextureAndPostProcesses(): void;
  10725. /**
  10726. * Implementation specific of rendering the generating effect on the main canvas.
  10727. * @param effect The effect used to render through
  10728. */
  10729. protected abstract _internalRender(effect: Effect): void;
  10730. /**
  10731. * Sets the required values for both the emissive texture and and the main color.
  10732. */
  10733. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10734. /**
  10735. * Free any resources and references associated to a mesh.
  10736. * Internal use
  10737. * @param mesh The mesh to free.
  10738. */
  10739. abstract _disposeMesh(mesh: Mesh): void;
  10740. /**
  10741. * Serializes this layer (Glow or Highlight for example)
  10742. * @returns a serialized layer object
  10743. */
  10744. abstract serialize?(): any;
  10745. /**
  10746. * Initializes the effect layer with the required options.
  10747. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10748. */
  10749. protected _init(options: Partial<IEffectLayerOptions>): void;
  10750. /**
  10751. * Generates the index buffer of the full screen quad blending to the main canvas.
  10752. */
  10753. private _generateIndexBuffer();
  10754. /**
  10755. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10756. */
  10757. private _genrateVertexBuffer();
  10758. /**
  10759. * Sets the main texture desired size which is the closest power of two
  10760. * of the engine canvas size.
  10761. */
  10762. private _setMainTextureSize();
  10763. /**
  10764. * Creates the main texture for the effect layer.
  10765. */
  10766. protected _createMainTexture(): void;
  10767. /**
  10768. * Checks for the readiness of the element composing the layer.
  10769. * @param subMesh the mesh to check for
  10770. * @param useInstances specify wether or not to use instances to render the mesh
  10771. * @param emissiveTexture the associated emissive texture used to generate the glow
  10772. * @return true if ready otherwise, false
  10773. */
  10774. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10775. /**
  10776. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10777. */
  10778. render(): void;
  10779. /**
  10780. * Determine if a given mesh will be used in the current effect.
  10781. * @param mesh mesh to test
  10782. * @returns true if the mesh will be used
  10783. */
  10784. hasMesh(mesh: AbstractMesh): boolean;
  10785. /**
  10786. * Returns true if the layer contains information to display, otherwise false.
  10787. * @returns true if the glow layer should be rendered
  10788. */
  10789. shouldRender(): boolean;
  10790. /**
  10791. * Returns true if the mesh should render, otherwise false.
  10792. * @param mesh The mesh to render
  10793. * @returns true if it should render otherwise false
  10794. */
  10795. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10796. /**
  10797. * Returns true if the mesh should render, otherwise false.
  10798. * @param mesh The mesh to render
  10799. * @returns true if it should render otherwise false
  10800. */
  10801. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10802. /**
  10803. * Renders the submesh passed in parameter to the generation map.
  10804. */
  10805. protected _renderSubMesh(subMesh: SubMesh): void;
  10806. /**
  10807. * Rebuild the required buffers.
  10808. * @hidden Internal use only.
  10809. */
  10810. _rebuild(): void;
  10811. /**
  10812. * Dispose only the render target textures and post process.
  10813. */
  10814. private _disposeTextureAndPostProcesses();
  10815. /**
  10816. * Dispose the highlight layer and free resources.
  10817. */
  10818. dispose(): void;
  10819. /**
  10820. * Gets the class name of the effect layer
  10821. * @returns the string with the class name of the effect layer
  10822. */
  10823. getClassName(): string;
  10824. /**
  10825. * Creates an effect layer from parsed effect layer data
  10826. * @param parsedEffectLayer defines effect layer data
  10827. * @param scene defines the current scene
  10828. * @param rootUrl defines the root URL containing the effect layer information
  10829. * @returns a parsed effect Layer
  10830. */
  10831. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10832. }
  10833. }
  10834. declare module BABYLON {
  10835. interface AbstractScene {
  10836. /**
  10837. * The list of effect layers (highlights/glow) added to the scene
  10838. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10839. * @see http://doc.babylonjs.com/how_to/glow_layer
  10840. */
  10841. effectLayers: Array<EffectLayer>;
  10842. /**
  10843. * Removes the given effect layer from this scene.
  10844. * @param toRemove defines the effect layer to remove
  10845. * @returns the index of the removed effect layer
  10846. */
  10847. removeEffectLayer(toRemove: EffectLayer): number;
  10848. /**
  10849. * Adds the given effect layer to this scene
  10850. * @param newEffectLayer defines the effect layer to add
  10851. */
  10852. addEffectLayer(newEffectLayer: EffectLayer): void;
  10853. }
  10854. /**
  10855. * Defines the layer scene component responsible to manage any effect layers
  10856. * in a given scene.
  10857. */
  10858. class EffectLayerSceneComponent implements ISceneComponent {
  10859. /**
  10860. * The component name helpfull to identify the component in the list of scene components.
  10861. */
  10862. readonly name: string;
  10863. /**
  10864. * The scene the component belongs to.
  10865. */
  10866. scene: Scene;
  10867. private _engine;
  10868. private _effectLayers;
  10869. private _renderEffects;
  10870. private _needStencil;
  10871. private _previousStencilState;
  10872. /**
  10873. * Creates a new instance of the component for the given scene
  10874. * @param scene Defines the scene to register the component in
  10875. */
  10876. constructor(scene: Scene);
  10877. /**
  10878. * Registers the component in a given scene
  10879. */
  10880. register(): void;
  10881. /**
  10882. * Rebuilds the elements related to this component in case of
  10883. * context lost for instance.
  10884. */
  10885. rebuild(): void;
  10886. /**
  10887. * Serializes the component data to the specified json object
  10888. * @param serializationObject The object to serialize to
  10889. */
  10890. serialize(serializationObject: any): void;
  10891. /**
  10892. * Adds all the element from the container to the scene
  10893. * @param container the container holding the elements
  10894. */
  10895. addFromContainer(container: AbstractScene): void;
  10896. /**
  10897. * Removes all the elements in the container from the scene
  10898. * @param container contains the elements to remove
  10899. */
  10900. removeFromContainer(container: AbstractScene): void;
  10901. /**
  10902. * Disposes the component and the associated ressources.
  10903. */
  10904. dispose(): void;
  10905. private _isReadyForMesh(mesh, hardwareInstancedRendering);
  10906. private _renderMainTexture(camera);
  10907. private _setStencil(camera);
  10908. private _setStencilBack(camera);
  10909. private _draw(renderingGroupId);
  10910. private _drawCamera(camera);
  10911. private _drawRenderingGroup(index);
  10912. }
  10913. }
  10914. declare module BABYLON {
  10915. interface AbstractScene {
  10916. /**
  10917. * Return a the first highlight layer of the scene with a given name.
  10918. * @param name The name of the highlight layer to look for.
  10919. * @return The highlight layer if found otherwise null.
  10920. */
  10921. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  10922. }
  10923. /**
  10924. * Glow layer options. This helps customizing the behaviour
  10925. * of the glow layer.
  10926. */
  10927. interface IGlowLayerOptions {
  10928. /**
  10929. * Multiplication factor apply to the canvas size to compute the render target size
  10930. * used to generated the glowing objects (the smaller the faster).
  10931. */
  10932. mainTextureRatio: number;
  10933. /**
  10934. * Enforces a fixed size texture to ensure resize independant blur.
  10935. */
  10936. mainTextureFixedSize?: number;
  10937. /**
  10938. * How big is the kernel of the blur texture.
  10939. */
  10940. blurKernelSize: number;
  10941. /**
  10942. * The camera attached to the layer.
  10943. */
  10944. camera: Nullable<Camera>;
  10945. /**
  10946. * Enable MSAA by chosing the number of samples.
  10947. */
  10948. mainTextureSamples?: number;
  10949. /**
  10950. * The rendering group to draw the layer in.
  10951. */
  10952. renderingGroupId: number;
  10953. }
  10954. /**
  10955. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10956. *
  10957. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10958. * glowy meshes to your scene.
  10959. *
  10960. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10961. */
  10962. class GlowLayer extends EffectLayer {
  10963. /**
  10964. * Effect Name of the layer.
  10965. */
  10966. static readonly EffectName: string;
  10967. /**
  10968. * The default blur kernel size used for the glow.
  10969. */
  10970. static DefaultBlurKernelSize: number;
  10971. /**
  10972. * The default texture size ratio used for the glow.
  10973. */
  10974. static DefaultTextureRatio: number;
  10975. /**
  10976. * Gets the kernel size of the blur.
  10977. */
  10978. /**
  10979. * Sets the kernel size of the blur.
  10980. */
  10981. blurKernelSize: number;
  10982. /**
  10983. * Gets the glow intensity.
  10984. */
  10985. /**
  10986. * Sets the glow intensity.
  10987. */
  10988. intensity: number;
  10989. private _options;
  10990. private _intensity;
  10991. private _horizontalBlurPostprocess1;
  10992. private _verticalBlurPostprocess1;
  10993. private _horizontalBlurPostprocess2;
  10994. private _verticalBlurPostprocess2;
  10995. private _blurTexture1;
  10996. private _blurTexture2;
  10997. private _postProcesses1;
  10998. private _postProcesses2;
  10999. private _includedOnlyMeshes;
  11000. private _excludedMeshes;
  11001. /**
  11002. * Callback used to let the user override the color selection on a per mesh basis
  11003. */
  11004. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11005. /**
  11006. * Callback used to let the user override the texture selection on a per mesh basis
  11007. */
  11008. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11009. /**
  11010. * Instantiates a new glow Layer and references it to the scene.
  11011. * @param name The name of the layer
  11012. * @param scene The scene to use the layer in
  11013. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11014. */
  11015. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11016. /**
  11017. * Get the effect name of the layer.
  11018. * @return The effect name
  11019. */
  11020. getEffectName(): string;
  11021. /**
  11022. * Create the merge effect. This is the shader use to blit the information back
  11023. * to the main canvas at the end of the scene rendering.
  11024. */
  11025. protected _createMergeEffect(): Effect;
  11026. /**
  11027. * Creates the render target textures and post processes used in the glow layer.
  11028. */
  11029. protected _createTextureAndPostProcesses(): void;
  11030. /**
  11031. * Checks for the readiness of the element composing the layer.
  11032. * @param subMesh the mesh to check for
  11033. * @param useInstances specify wether or not to use instances to render the mesh
  11034. * @param emissiveTexture the associated emissive texture used to generate the glow
  11035. * @return true if ready otherwise, false
  11036. */
  11037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11038. /**
  11039. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11040. */
  11041. needStencil(): boolean;
  11042. /**
  11043. * Implementation specific of rendering the generating effect on the main canvas.
  11044. * @param effect The effect used to render through
  11045. */
  11046. protected _internalRender(effect: Effect): void;
  11047. /**
  11048. * Sets the required values for both the emissive texture and and the main color.
  11049. */
  11050. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11051. /**
  11052. * Returns true if the mesh should render, otherwise false.
  11053. * @param mesh The mesh to render
  11054. * @returns true if it should render otherwise false
  11055. */
  11056. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11057. /**
  11058. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11059. * @param mesh The mesh to exclude from the glow layer
  11060. */
  11061. addExcludedMesh(mesh: Mesh): void;
  11062. /**
  11063. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11064. * @param mesh The mesh to remove
  11065. */
  11066. removeExcludedMesh(mesh: Mesh): void;
  11067. /**
  11068. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11069. * @param mesh The mesh to include in the glow layer
  11070. */
  11071. addIncludedOnlyMesh(mesh: Mesh): void;
  11072. /**
  11073. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11074. * @param mesh The mesh to remove
  11075. */
  11076. removeIncludedOnlyMesh(mesh: Mesh): void;
  11077. /**
  11078. * Determine if a given mesh will be used in the glow layer
  11079. * @param mesh The mesh to test
  11080. * @returns true if the mesh will be highlighted by the current glow layer
  11081. */
  11082. hasMesh(mesh: AbstractMesh): boolean;
  11083. /**
  11084. * Free any resources and references associated to a mesh.
  11085. * Internal use
  11086. * @param mesh The mesh to free.
  11087. */
  11088. _disposeMesh(mesh: Mesh): void;
  11089. /**
  11090. * Gets the class name of the effect layer
  11091. * @returns the string with the class name of the effect layer
  11092. */
  11093. getClassName(): string;
  11094. /**
  11095. * Serializes this glow layer
  11096. * @returns a serialized glow layer object
  11097. */
  11098. serialize(): any;
  11099. /**
  11100. * Creates a Glow Layer from parsed glow layer data
  11101. * @param parsedGlowLayer defines glow layer data
  11102. * @param scene defines the current scene
  11103. * @param rootUrl defines the root URL containing the glow layer information
  11104. * @returns a parsed Glow Layer
  11105. */
  11106. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11107. }
  11108. }
  11109. declare module BABYLON {
  11110. interface AbstractScene {
  11111. /**
  11112. * Return a the first highlight layer of the scene with a given name.
  11113. * @param name The name of the highlight layer to look for.
  11114. * @return The highlight layer if found otherwise null.
  11115. */
  11116. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11117. }
  11118. /**
  11119. * Highlight layer options. This helps customizing the behaviour
  11120. * of the highlight layer.
  11121. */
  11122. interface IHighlightLayerOptions {
  11123. /**
  11124. * Multiplication factor apply to the canvas size to compute the render target size
  11125. * used to generated the glowing objects (the smaller the faster).
  11126. */
  11127. mainTextureRatio: number;
  11128. /**
  11129. * Enforces a fixed size texture to ensure resize independant blur.
  11130. */
  11131. mainTextureFixedSize?: number;
  11132. /**
  11133. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11134. * of the picture to blur (the smaller the faster).
  11135. */
  11136. blurTextureSizeRatio: number;
  11137. /**
  11138. * How big in texel of the blur texture is the vertical blur.
  11139. */
  11140. blurVerticalSize: number;
  11141. /**
  11142. * How big in texel of the blur texture is the horizontal blur.
  11143. */
  11144. blurHorizontalSize: number;
  11145. /**
  11146. * Alpha blending mode used to apply the blur. Default is combine.
  11147. */
  11148. alphaBlendingMode: number;
  11149. /**
  11150. * The camera attached to the layer.
  11151. */
  11152. camera: Nullable<Camera>;
  11153. /**
  11154. * Should we display highlight as a solid stroke?
  11155. */
  11156. isStroke?: boolean;
  11157. /**
  11158. * The rendering group to draw the layer in.
  11159. */
  11160. renderingGroupId: number;
  11161. }
  11162. /**
  11163. * The highlight layer Helps adding a glow effect around a mesh.
  11164. *
  11165. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11166. * glowy meshes to your scene.
  11167. *
  11168. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11169. */
  11170. class HighlightLayer extends EffectLayer {
  11171. name: string;
  11172. /**
  11173. * Effect Name of the highlight layer.
  11174. */
  11175. static readonly EffectName: string;
  11176. /**
  11177. * The neutral color used during the preparation of the glow effect.
  11178. * This is black by default as the blend operation is a blend operation.
  11179. */
  11180. static NeutralColor: Color4;
  11181. /**
  11182. * Stencil value used for glowing meshes.
  11183. */
  11184. static GlowingMeshStencilReference: number;
  11185. /**
  11186. * Stencil value used for the other meshes in the scene.
  11187. */
  11188. static NormalMeshStencilReference: number;
  11189. /**
  11190. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11191. */
  11192. innerGlow: boolean;
  11193. /**
  11194. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11195. */
  11196. outerGlow: boolean;
  11197. /**
  11198. * Gets the horizontal size of the blur.
  11199. */
  11200. /**
  11201. * Specifies the horizontal size of the blur.
  11202. */
  11203. blurHorizontalSize: number;
  11204. /**
  11205. * Gets the vertical size of the blur.
  11206. */
  11207. /**
  11208. * Specifies the vertical size of the blur.
  11209. */
  11210. blurVerticalSize: number;
  11211. /**
  11212. * An event triggered when the highlight layer is being blurred.
  11213. */
  11214. onBeforeBlurObservable: Observable<HighlightLayer>;
  11215. /**
  11216. * An event triggered when the highlight layer has been blurred.
  11217. */
  11218. onAfterBlurObservable: Observable<HighlightLayer>;
  11219. private _instanceGlowingMeshStencilReference;
  11220. private _options;
  11221. private _downSamplePostprocess;
  11222. private _horizontalBlurPostprocess;
  11223. private _verticalBlurPostprocess;
  11224. private _blurTexture;
  11225. private _meshes;
  11226. private _excludedMeshes;
  11227. /**
  11228. * Instantiates a new highlight Layer and references it to the scene..
  11229. * @param name The name of the layer
  11230. * @param scene The scene to use the layer in
  11231. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11232. */
  11233. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11234. /**
  11235. * Get the effect name of the layer.
  11236. * @return The effect name
  11237. */
  11238. getEffectName(): string;
  11239. /**
  11240. * Create the merge effect. This is the shader use to blit the information back
  11241. * to the main canvas at the end of the scene rendering.
  11242. */
  11243. protected _createMergeEffect(): Effect;
  11244. /**
  11245. * Creates the render target textures and post processes used in the highlight layer.
  11246. */
  11247. protected _createTextureAndPostProcesses(): void;
  11248. /**
  11249. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11250. */
  11251. needStencil(): boolean;
  11252. /**
  11253. * Checks for the readiness of the element composing the layer.
  11254. * @param subMesh the mesh to check for
  11255. * @param useInstances specify wether or not to use instances to render the mesh
  11256. * @param emissiveTexture the associated emissive texture used to generate the glow
  11257. * @return true if ready otherwise, false
  11258. */
  11259. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11260. /**
  11261. * Implementation specific of rendering the generating effect on the main canvas.
  11262. * @param effect The effect used to render through
  11263. */
  11264. protected _internalRender(effect: Effect): void;
  11265. /**
  11266. * Returns true if the layer contains information to display, otherwise false.
  11267. */
  11268. shouldRender(): boolean;
  11269. /**
  11270. * Returns true if the mesh should render, otherwise false.
  11271. * @param mesh The mesh to render
  11272. * @returns true if it should render otherwise false
  11273. */
  11274. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11275. /**
  11276. * Sets the required values for both the emissive texture and and the main color.
  11277. */
  11278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11279. /**
  11280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11281. * @param mesh The mesh to exclude from the highlight layer
  11282. */
  11283. addExcludedMesh(mesh: Mesh): void;
  11284. /**
  11285. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11286. * @param mesh The mesh to highlight
  11287. */
  11288. removeExcludedMesh(mesh: Mesh): void;
  11289. /**
  11290. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11291. * @param mesh mesh to test
  11292. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11293. */
  11294. hasMesh(mesh: AbstractMesh): boolean;
  11295. /**
  11296. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11297. * @param mesh The mesh to highlight
  11298. * @param color The color of the highlight
  11299. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11300. */
  11301. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11302. /**
  11303. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11304. * @param mesh The mesh to highlight
  11305. */
  11306. removeMesh(mesh: Mesh): void;
  11307. /**
  11308. * Force the stencil to the normal expected value for none glowing parts
  11309. */
  11310. private _defaultStencilReference(mesh);
  11311. /**
  11312. * Free any resources and references associated to a mesh.
  11313. * Internal use
  11314. * @param mesh The mesh to free.
  11315. */
  11316. _disposeMesh(mesh: Mesh): void;
  11317. /**
  11318. * Dispose the highlight layer and free resources.
  11319. */
  11320. dispose(): void;
  11321. /**
  11322. * Gets the class name of the effect layer
  11323. * @returns the string with the class name of the effect layer
  11324. */
  11325. getClassName(): string;
  11326. /**
  11327. * Serializes this Highlight layer
  11328. * @returns a serialized Highlight layer object
  11329. */
  11330. serialize(): any;
  11331. /**
  11332. * Creates a Highlight layer from parsed Highlight layer data
  11333. * @param parsedHightlightLayer defines the Highlight layer data
  11334. * @param scene defines the current scene
  11335. * @param rootUrl defines the root URL containing the Highlight layer information
  11336. * @returns a parsed Highlight layer
  11337. */
  11338. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11339. }
  11340. }
  11341. declare module BABYLON {
  11342. class Layer {
  11343. name: string;
  11344. texture: Nullable<Texture>;
  11345. isBackground: boolean;
  11346. color: Color4;
  11347. scale: Vector2;
  11348. offset: Vector2;
  11349. alphaBlendingMode: number;
  11350. alphaTest: boolean;
  11351. layerMask: number;
  11352. private _scene;
  11353. private _vertexBuffers;
  11354. private _indexBuffer;
  11355. private _effect;
  11356. private _alphaTestEffect;
  11357. /**
  11358. * An event triggered when the layer is disposed.
  11359. */
  11360. onDisposeObservable: Observable<Layer>;
  11361. private _onDisposeObserver;
  11362. onDispose: () => void;
  11363. /**
  11364. * An event triggered before rendering the scene
  11365. */
  11366. onBeforeRenderObservable: Observable<Layer>;
  11367. private _onBeforeRenderObserver;
  11368. onBeforeRender: () => void;
  11369. /**
  11370. * An event triggered after rendering the scene
  11371. */
  11372. onAfterRenderObservable: Observable<Layer>;
  11373. private _onAfterRenderObserver;
  11374. onAfterRender: () => void;
  11375. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11376. private _createIndexBuffer();
  11377. _rebuild(): void;
  11378. render(): void;
  11379. dispose(): void;
  11380. }
  11381. }
  11382. declare module BABYLON {
  11383. interface AbstractScene {
  11384. /**
  11385. * The list of layers (background and foreground) of the scene
  11386. */
  11387. layers: Array<Layer>;
  11388. }
  11389. /**
  11390. * Defines the layer scene component responsible to manage any layers
  11391. * in a given scene.
  11392. */
  11393. class LayerSceneComponent implements ISceneComponent {
  11394. /**
  11395. * The component name helpfull to identify the component in the list of scene components.
  11396. */
  11397. readonly name: string;
  11398. /**
  11399. * The scene the component belongs to.
  11400. */
  11401. scene: Scene;
  11402. private _engine;
  11403. private _layers;
  11404. /**
  11405. * Creates a new instance of the component for the given scene
  11406. * @param scene Defines the scene to register the component in
  11407. */
  11408. constructor(scene: Scene);
  11409. /**
  11410. * Registers the component in a given scene
  11411. */
  11412. register(): void;
  11413. /**
  11414. * Rebuilds the elements related to this component in case of
  11415. * context lost for instance.
  11416. */
  11417. rebuild(): void;
  11418. /**
  11419. * Serializes the component data to the specified json object
  11420. * @param serializationObject The object to serialize to
  11421. */
  11422. serialize(serializationObject: any): void;
  11423. /**
  11424. * Adds all the element from the container to the scene
  11425. * @param container the container holding the elements
  11426. */
  11427. addFromContainer(container: AbstractScene): void;
  11428. /**
  11429. * Removes all the elements in the container from the scene
  11430. * @param container contains the elements to remove
  11431. */
  11432. removeFromContainer(container: AbstractScene): void;
  11433. /**
  11434. * Disposes the component and the associated ressources.
  11435. */
  11436. dispose(): void;
  11437. private _draw(camera, isBackground);
  11438. private _drawBackground(camera);
  11439. private _drawForeground(camera);
  11440. }
  11441. }
  11442. declare module BABYLON {
  11443. class LensFlare {
  11444. size: number;
  11445. position: number;
  11446. color: Color3;
  11447. texture: Nullable<Texture>;
  11448. alphaMode: number;
  11449. private _system;
  11450. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11451. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11452. dispose(): void;
  11453. }
  11454. }
  11455. declare module BABYLON {
  11456. class LensFlareSystem {
  11457. name: string;
  11458. lensFlares: LensFlare[];
  11459. borderLimit: number;
  11460. viewportBorder: number;
  11461. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11462. layerMask: number;
  11463. id: string;
  11464. private _scene;
  11465. private _emitter;
  11466. private _vertexBuffers;
  11467. private _indexBuffer;
  11468. private _effect;
  11469. private _positionX;
  11470. private _positionY;
  11471. private _isEnabled;
  11472. constructor(name: string, emitter: any, scene: Scene);
  11473. isEnabled: boolean;
  11474. getScene(): Scene;
  11475. getEmitter(): any;
  11476. setEmitter(newEmitter: any): void;
  11477. getEmitterPosition(): Vector3;
  11478. computeEffectivePosition(globalViewport: Viewport): boolean;
  11479. _isVisible(): boolean;
  11480. render(): boolean;
  11481. dispose(): void;
  11482. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11483. serialize(): any;
  11484. }
  11485. }
  11486. declare module BABYLON {
  11487. interface AbstractScene {
  11488. /**
  11489. * The list of lens flare system added to the scene
  11490. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11491. */
  11492. lensFlareSystems: Array<LensFlareSystem>;
  11493. /**
  11494. * Removes the given lens flare system from this scene.
  11495. * @param toRemove The lens flare system to remove
  11496. * @returns The index of the removed lens flare system
  11497. */
  11498. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11499. /**
  11500. * Adds the given lens flare system to this scene
  11501. * @param newLensFlareSystem The lens flare system to add
  11502. */
  11503. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11504. /**
  11505. * Gets a lens flare system using its name
  11506. * @param name defines the name to look for
  11507. * @returns the lens flare system or null if not found
  11508. */
  11509. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11510. /**
  11511. * Gets a lens flare system using its id
  11512. * @param id defines the id to look for
  11513. * @returns the lens flare system or null if not found
  11514. */
  11515. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11516. }
  11517. /**
  11518. * Defines the layer scene component responsible to manage any layers
  11519. * in a given scene.
  11520. */
  11521. class LensFlareSystemSceneComponent implements ISceneComponent {
  11522. /**
  11523. * The component name helpfull to identify the component in the list of scene components.
  11524. */
  11525. readonly name: string;
  11526. /**
  11527. * The scene the component belongs to.
  11528. */
  11529. scene: Scene;
  11530. private _lensFlareSystems;
  11531. /**
  11532. * Creates a new instance of the component for the given scene
  11533. * @param scene Defines the scene to register the component in
  11534. */
  11535. constructor(scene: Scene);
  11536. /**
  11537. * Registers the component in a given scene
  11538. */
  11539. register(): void;
  11540. /**
  11541. * Rebuilds the elements related to this component in case of
  11542. * context lost for instance.
  11543. */
  11544. rebuild(): void;
  11545. /**
  11546. * Adds all the element from the container to the scene
  11547. * @param container the container holding the elements
  11548. */
  11549. addFromContainer(container: AbstractScene): void;
  11550. /**
  11551. * Removes all the elements in the container from the scene
  11552. * @param container contains the elements to remove
  11553. */
  11554. removeFromContainer(container: AbstractScene): void;
  11555. /**
  11556. * Serializes the component data to the specified json object
  11557. * @param serializationObject The object to serialize to
  11558. */
  11559. serialize(serializationObject: any): void;
  11560. /**
  11561. * Disposes the component and the associated ressources.
  11562. */
  11563. dispose(): void;
  11564. private _draw(camera);
  11565. }
  11566. }
  11567. declare module BABYLON {
  11568. /**
  11569. * A directional light is defined by a direction (what a surprise!).
  11570. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11571. * 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.
  11572. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11573. */
  11574. class DirectionalLight extends ShadowLight {
  11575. private _shadowFrustumSize;
  11576. /**
  11577. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11578. */
  11579. /**
  11580. * Specifies a fix frustum size for the shadow generation.
  11581. */
  11582. shadowFrustumSize: number;
  11583. private _shadowOrthoScale;
  11584. /**
  11585. * Gets the shadow projection scale against the optimal computed one.
  11586. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11587. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11588. */
  11589. /**
  11590. * Sets the shadow projection scale against the optimal computed one.
  11591. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11592. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11593. */
  11594. shadowOrthoScale: number;
  11595. /**
  11596. * Automatically compute the projection matrix to best fit (including all the casters)
  11597. * on each frame.
  11598. */
  11599. autoUpdateExtends: boolean;
  11600. private _orthoLeft;
  11601. private _orthoRight;
  11602. private _orthoTop;
  11603. private _orthoBottom;
  11604. /**
  11605. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11606. * The directional light is emitted from everywhere in the given direction.
  11607. * It can cast shawdows.
  11608. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11609. * @param name The friendly name of the light
  11610. * @param direction The direction of the light
  11611. * @param scene The scene the light belongs to
  11612. */
  11613. constructor(name: string, direction: Vector3, scene: Scene);
  11614. /**
  11615. * Returns the string "DirectionalLight".
  11616. * @return The class name
  11617. */
  11618. getClassName(): string;
  11619. /**
  11620. * Returns the integer 1.
  11621. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11622. */
  11623. getTypeID(): number;
  11624. /**
  11625. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11626. * Returns the DirectionalLight Shadow projection matrix.
  11627. */
  11628. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11629. /**
  11630. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11631. * Returns the DirectionalLight Shadow projection matrix.
  11632. */
  11633. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11634. /**
  11635. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11636. * Returns the DirectionalLight Shadow projection matrix.
  11637. */
  11638. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11639. protected _buildUniformLayout(): void;
  11640. /**
  11641. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11642. * @param effect The effect to update
  11643. * @param lightIndex The index of the light in the effect to update
  11644. * @returns The directional light
  11645. */
  11646. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11647. /**
  11648. * Gets the minZ used for shadow according to both the scene and the light.
  11649. *
  11650. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11651. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11652. * @param activeCamera The camera we are returning the min for
  11653. * @returns the depth min z
  11654. */
  11655. getDepthMinZ(activeCamera: Camera): number;
  11656. /**
  11657. * Gets the maxZ used for shadow according to both the scene and the light.
  11658. *
  11659. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11660. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11661. * @param activeCamera The camera we are returning the max for
  11662. * @returns the depth max z
  11663. */
  11664. getDepthMaxZ(activeCamera: Camera): number;
  11665. }
  11666. }
  11667. declare module BABYLON {
  11668. /**
  11669. * The HemisphericLight simulates the ambient environment light,
  11670. * so the passed direction is the light reflection direction, not the incoming direction.
  11671. */
  11672. class HemisphericLight extends Light {
  11673. /**
  11674. * The groundColor is the light in the opposite direction to the one specified during creation.
  11675. * 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.
  11676. */
  11677. groundColor: Color3;
  11678. /**
  11679. * The light reflection direction, not the incoming direction.
  11680. */
  11681. direction: Vector3;
  11682. private _worldMatrix;
  11683. /**
  11684. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11685. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11686. * The HemisphericLight can't cast shadows.
  11687. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11688. * @param name The friendly name of the light
  11689. * @param direction The direction of the light reflection
  11690. * @param scene The scene the light belongs to
  11691. */
  11692. constructor(name: string, direction: Vector3, scene: Scene);
  11693. protected _buildUniformLayout(): void;
  11694. /**
  11695. * Returns the string "HemisphericLight".
  11696. * @return The class name
  11697. */
  11698. getClassName(): string;
  11699. /**
  11700. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11701. * Returns the updated direction.
  11702. * @param target The target the direction should point to
  11703. * @return The computed direction
  11704. */
  11705. setDirectionToTarget(target: Vector3): Vector3;
  11706. /**
  11707. * Returns the shadow generator associated to the light.
  11708. * @returns Always null for hemispheric lights because it does not support shadows.
  11709. */
  11710. getShadowGenerator(): Nullable<ShadowGenerator>;
  11711. /**
  11712. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11713. * @param effect The effect to update
  11714. * @param lightIndex The index of the light in the effect to update
  11715. * @returns The hemispheric light
  11716. */
  11717. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11718. /**
  11719. * @hidden internal use only.
  11720. */
  11721. _getWorldMatrix(): Matrix;
  11722. /**
  11723. * Returns the integer 3.
  11724. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11725. */
  11726. getTypeID(): number;
  11727. }
  11728. }
  11729. declare module BABYLON {
  11730. /**
  11731. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11732. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11733. * 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.
  11734. */
  11735. abstract class Light extends Node {
  11736. private static _LIGHTMAP_DEFAULT;
  11737. private static _LIGHTMAP_SPECULAR;
  11738. private static _LIGHTMAP_SHADOWSONLY;
  11739. /**
  11740. * If every light affecting the material is in this lightmapMode,
  11741. * material.lightmapTexture adds or multiplies
  11742. * (depends on material.useLightmapAsShadowmap)
  11743. * after every other light calculations.
  11744. */
  11745. static readonly LIGHTMAP_DEFAULT: number;
  11746. /**
  11747. * material.lightmapTexture as only diffuse lighting from this light
  11748. * adds only specular lighting from this light
  11749. * adds dynamic shadows
  11750. */
  11751. static readonly LIGHTMAP_SPECULAR: number;
  11752. /**
  11753. * material.lightmapTexture as only lighting
  11754. * no light calculation from this light
  11755. * only adds dynamic shadows from this light
  11756. */
  11757. static readonly LIGHTMAP_SHADOWSONLY: number;
  11758. private static _INTENSITYMODE_AUTOMATIC;
  11759. private static _INTENSITYMODE_LUMINOUSPOWER;
  11760. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11761. private static _INTENSITYMODE_ILLUMINANCE;
  11762. private static _INTENSITYMODE_LUMINANCE;
  11763. /**
  11764. * Each light type uses the default quantity according to its type:
  11765. * point/spot lights use luminous intensity
  11766. * directional lights use illuminance
  11767. */
  11768. static readonly INTENSITYMODE_AUTOMATIC: number;
  11769. /**
  11770. * lumen (lm)
  11771. */
  11772. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11773. /**
  11774. * candela (lm/sr)
  11775. */
  11776. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11777. /**
  11778. * lux (lm/m^2)
  11779. */
  11780. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11781. /**
  11782. * nit (cd/m^2)
  11783. */
  11784. static readonly INTENSITYMODE_LUMINANCE: number;
  11785. private static _LIGHTTYPEID_POINTLIGHT;
  11786. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11787. private static _LIGHTTYPEID_SPOTLIGHT;
  11788. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11789. /**
  11790. * Light type const id of the point light.
  11791. */
  11792. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11793. /**
  11794. * Light type const id of the directional light.
  11795. */
  11796. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11797. /**
  11798. * Light type const id of the spot light.
  11799. */
  11800. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11801. /**
  11802. * Light type const id of the hemispheric light.
  11803. */
  11804. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11805. /**
  11806. * Diffuse gives the basic color to an object.
  11807. */
  11808. diffuse: Color3;
  11809. /**
  11810. * Specular produces a highlight color on an object.
  11811. * Note: This is note affecting PBR materials.
  11812. */
  11813. specular: Color3;
  11814. /**
  11815. * Strength of the light.
  11816. * Note: By default it is define in the framework own unit.
  11817. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11818. */
  11819. intensity: number;
  11820. /**
  11821. * Defines how far from the source the light is impacting in scene units.
  11822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11823. */
  11824. range: number;
  11825. /**
  11826. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11827. * of light.
  11828. */
  11829. private _photometricScale;
  11830. private _intensityMode;
  11831. /**
  11832. * Gets the photometric scale used to interpret the intensity.
  11833. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11834. */
  11835. /**
  11836. * Sets the photometric scale used to interpret the intensity.
  11837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11838. */
  11839. intensityMode: number;
  11840. private _radius;
  11841. /**
  11842. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11843. */
  11844. /**
  11845. * sets the light radius used by PBR Materials to simulate soft area lights.
  11846. */
  11847. radius: number;
  11848. private _renderPriority;
  11849. /**
  11850. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11851. * exceeding the number allowed of the materials.
  11852. */
  11853. renderPriority: number;
  11854. private _shadowEnabled;
  11855. /**
  11856. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11857. * the current shadow generator.
  11858. */
  11859. /**
  11860. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11861. * the current shadow generator.
  11862. */
  11863. shadowEnabled: boolean;
  11864. private _includedOnlyMeshes;
  11865. /**
  11866. * Gets the only meshes impacted by this light.
  11867. */
  11868. /**
  11869. * Sets the only meshes impacted by this light.
  11870. */
  11871. includedOnlyMeshes: AbstractMesh[];
  11872. private _excludedMeshes;
  11873. /**
  11874. * Gets the meshes not impacted by this light.
  11875. */
  11876. /**
  11877. * Sets the meshes not impacted by this light.
  11878. */
  11879. excludedMeshes: AbstractMesh[];
  11880. private _excludeWithLayerMask;
  11881. /**
  11882. * Gets the layer id use to find what meshes are not impacted by the light.
  11883. * Inactive if 0
  11884. */
  11885. /**
  11886. * Sets the layer id use to find what meshes are not impacted by the light.
  11887. * Inactive if 0
  11888. */
  11889. excludeWithLayerMask: number;
  11890. private _includeOnlyWithLayerMask;
  11891. /**
  11892. * Gets the layer id use to find what meshes are impacted by the light.
  11893. * Inactive if 0
  11894. */
  11895. /**
  11896. * Sets the layer id use to find what meshes are impacted by the light.
  11897. * Inactive if 0
  11898. */
  11899. includeOnlyWithLayerMask: number;
  11900. private _lightmapMode;
  11901. /**
  11902. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11903. */
  11904. /**
  11905. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11906. */
  11907. lightmapMode: number;
  11908. private _parentedWorldMatrix;
  11909. /**
  11910. * Shadow generator associted to the light.
  11911. * Internal use only.
  11912. */
  11913. _shadowGenerator: Nullable<IShadowGenerator>;
  11914. /**
  11915. * @hidden Internal use only.
  11916. */
  11917. _excludedMeshesIds: string[];
  11918. /**
  11919. * @hidden Internal use only.
  11920. */
  11921. _includedOnlyMeshesIds: string[];
  11922. /**
  11923. * The current light unifom buffer.
  11924. * @hidden Internal use only.
  11925. */
  11926. _uniformBuffer: UniformBuffer;
  11927. /**
  11928. * Creates a Light object in the scene.
  11929. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11930. * @param name The firendly name of the light
  11931. * @param scene The scene the light belongs too
  11932. */
  11933. constructor(name: string, scene: Scene);
  11934. protected abstract _buildUniformLayout(): void;
  11935. /**
  11936. * Sets the passed Effect "effect" with the Light information.
  11937. * @param effect The effect to update
  11938. * @param lightIndex The index of the light in the effect to update
  11939. * @returns The light
  11940. */
  11941. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11942. /**
  11943. * @hidden internal use only.
  11944. */
  11945. abstract _getWorldMatrix(): Matrix;
  11946. /**
  11947. * Returns the string "Light".
  11948. * @returns the class name
  11949. */
  11950. getClassName(): string;
  11951. /**
  11952. * Converts the light information to a readable string for debug purpose.
  11953. * @param fullDetails Supports for multiple levels of logging within scene loading
  11954. * @returns the human readable light info
  11955. */
  11956. toString(fullDetails?: boolean): string;
  11957. /**
  11958. * Set the enabled state of this node.
  11959. * @param value - the new enabled state
  11960. */
  11961. setEnabled(value: boolean): void;
  11962. /**
  11963. * Returns the Light associated shadow generator if any.
  11964. * @return the associated shadow generator.
  11965. */
  11966. getShadowGenerator(): Nullable<IShadowGenerator>;
  11967. /**
  11968. * Returns a Vector3, the absolute light position in the World.
  11969. * @returns the world space position of the light
  11970. */
  11971. getAbsolutePosition(): Vector3;
  11972. /**
  11973. * Specifies if the light will affect the passed mesh.
  11974. * @param mesh The mesh to test against the light
  11975. * @return true the mesh is affected otherwise, false.
  11976. */
  11977. canAffectMesh(mesh: AbstractMesh): boolean;
  11978. /**
  11979. * Computes and Returns the light World matrix.
  11980. * @returns the world matrix
  11981. */
  11982. getWorldMatrix(): Matrix;
  11983. /**
  11984. * Sort function to order lights for rendering.
  11985. * @param a First Light object to compare to second.
  11986. * @param b Second Light object to compare first.
  11987. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11988. */
  11989. static CompareLightsPriority(a: Light, b: Light): number;
  11990. /**
  11991. * Releases resources associated with this node.
  11992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11994. */
  11995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11996. /**
  11997. * Returns the light type ID (integer).
  11998. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11999. */
  12000. getTypeID(): number;
  12001. /**
  12002. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12003. * @returns the scaled intensity in intensity mode unit
  12004. */
  12005. getScaledIntensity(): number;
  12006. /**
  12007. * Returns a new Light object, named "name", from the current one.
  12008. * @param name The name of the cloned light
  12009. * @returns the new created light
  12010. */
  12011. clone(name: string): Nullable<Light>;
  12012. /**
  12013. * Serializes the current light into a Serialization object.
  12014. * @returns the serialized object.
  12015. */
  12016. serialize(): any;
  12017. /**
  12018. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12019. * This new light is named "name" and added to the passed scene.
  12020. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12021. * @param name The friendly name of the light
  12022. * @param scene The scene the new light will belong to
  12023. * @returns the constructor function
  12024. */
  12025. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12026. /**
  12027. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12028. * @param parsedLight The JSON representation of the light
  12029. * @param scene The scene to create the parsed light in
  12030. * @returns the created light after parsing
  12031. */
  12032. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12033. private _hookArrayForExcluded(array);
  12034. private _hookArrayForIncludedOnly(array);
  12035. private _resyncMeshes();
  12036. /**
  12037. * Forces the meshes to update their light related information in their rendering used effects
  12038. * @hidden Internal Use Only
  12039. */
  12040. _markMeshesAsLightDirty(): void;
  12041. /**
  12042. * Recomputes the cached photometric scale if needed.
  12043. */
  12044. private _computePhotometricScale();
  12045. /**
  12046. * Returns the Photometric Scale according to the light type and intensity mode.
  12047. */
  12048. private _getPhotometricScale();
  12049. /**
  12050. * Reorder the light in the scene according to their defined priority.
  12051. * @hidden Internal Use Only
  12052. */
  12053. _reorderLightsInScene(): void;
  12054. }
  12055. }
  12056. declare module BABYLON {
  12057. /**
  12058. * A point light is a light defined by an unique point in world space.
  12059. * The light is emitted in every direction from this point.
  12060. * A good example of a point light is a standard light bulb.
  12061. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12062. */
  12063. class PointLight extends ShadowLight {
  12064. private _shadowAngle;
  12065. /**
  12066. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12067. * This specifies what angle the shadow will use to be created.
  12068. *
  12069. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12070. */
  12071. /**
  12072. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12073. * This specifies what angle the shadow will use to be created.
  12074. *
  12075. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12076. */
  12077. shadowAngle: number;
  12078. /**
  12079. * Gets the direction if it has been set.
  12080. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12081. */
  12082. /**
  12083. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12084. */
  12085. direction: Vector3;
  12086. /**
  12087. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12088. * A PointLight emits the light in every direction.
  12089. * It can cast shadows.
  12090. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12091. * ```javascript
  12092. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12093. * ```
  12094. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12095. * @param name The light friendly name
  12096. * @param position The position of the point light in the scene
  12097. * @param scene The scene the lights belongs to
  12098. */
  12099. constructor(name: string, position: Vector3, scene: Scene);
  12100. /**
  12101. * Returns the string "PointLight"
  12102. * @returns the class name
  12103. */
  12104. getClassName(): string;
  12105. /**
  12106. * Returns the integer 0.
  12107. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12108. */
  12109. getTypeID(): number;
  12110. /**
  12111. * Specifies wether or not the shadowmap should be a cube texture.
  12112. * @returns true if the shadowmap needs to be a cube texture.
  12113. */
  12114. needCube(): boolean;
  12115. /**
  12116. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12117. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12118. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12119. */
  12120. getShadowDirection(faceIndex?: number): Vector3;
  12121. /**
  12122. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12123. * - fov = PI / 2
  12124. * - aspect ratio : 1.0
  12125. * - z-near and far equal to the active camera minZ and maxZ.
  12126. * Returns the PointLight.
  12127. */
  12128. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12129. protected _buildUniformLayout(): void;
  12130. /**
  12131. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12132. * @param effect The effect to update
  12133. * @param lightIndex The index of the light in the effect to update
  12134. * @returns The point light
  12135. */
  12136. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12137. }
  12138. }
  12139. declare module BABYLON {
  12140. /**
  12141. * Interface describing all the common properties and methods a shadow light needs to implement.
  12142. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12143. * as well as binding the different shadow properties to the effects.
  12144. */
  12145. interface IShadowLight extends Light {
  12146. /**
  12147. * The light id in the scene (used in scene.findLighById for instance)
  12148. */
  12149. id: string;
  12150. /**
  12151. * The position the shdow will be casted from.
  12152. */
  12153. position: Vector3;
  12154. /**
  12155. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12156. */
  12157. direction: Vector3;
  12158. /**
  12159. * The transformed position. Position of the light in world space taking parenting in account.
  12160. */
  12161. transformedPosition: Vector3;
  12162. /**
  12163. * The transformed direction. Direction of the light in world space taking parenting in account.
  12164. */
  12165. transformedDirection: Vector3;
  12166. /**
  12167. * The friendly name of the light in the scene.
  12168. */
  12169. name: string;
  12170. /**
  12171. * Defines the shadow projection clipping minimum z value.
  12172. */
  12173. shadowMinZ: number;
  12174. /**
  12175. * Defines the shadow projection clipping maximum z value.
  12176. */
  12177. shadowMaxZ: number;
  12178. /**
  12179. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12180. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12181. */
  12182. computeTransformedInformation(): boolean;
  12183. /**
  12184. * Gets the scene the light belongs to.
  12185. * @returns The scene
  12186. */
  12187. getScene(): Scene;
  12188. /**
  12189. * Callback defining a custom Projection Matrix Builder.
  12190. * This can be used to override the default projection matrix computation.
  12191. */
  12192. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12193. /**
  12194. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12195. * @param matrix The materix to updated with the projection information
  12196. * @param viewMatrix The transform matrix of the light
  12197. * @param renderList The list of mesh to render in the map
  12198. * @returns The current light
  12199. */
  12200. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12201. /**
  12202. * Gets the current depth scale used in ESM.
  12203. * @returns The scale
  12204. */
  12205. getDepthScale(): number;
  12206. /**
  12207. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12208. * @returns true if a cube texture needs to be use
  12209. */
  12210. needCube(): boolean;
  12211. /**
  12212. * Detects if the projection matrix requires to be recomputed this frame.
  12213. * @returns true if it requires to be recomputed otherwise, false.
  12214. */
  12215. needProjectionMatrixCompute(): boolean;
  12216. /**
  12217. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12218. */
  12219. forceProjectionMatrixCompute(): void;
  12220. /**
  12221. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12222. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12223. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12224. */
  12225. getShadowDirection(faceIndex?: number): Vector3;
  12226. /**
  12227. * Gets the minZ used for shadow according to both the scene and the light.
  12228. * @param activeCamera The camera we are returning the min for
  12229. * @returns the depth min z
  12230. */
  12231. getDepthMinZ(activeCamera: Camera): number;
  12232. /**
  12233. * Gets the maxZ used for shadow according to both the scene and the light.
  12234. * @param activeCamera The camera we are returning the max for
  12235. * @returns the depth max z
  12236. */
  12237. getDepthMaxZ(activeCamera: Camera): number;
  12238. }
  12239. /**
  12240. * Base implementation IShadowLight
  12241. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12242. */
  12243. abstract class ShadowLight extends Light implements IShadowLight {
  12244. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12245. protected _position: Vector3;
  12246. protected _setPosition(value: Vector3): void;
  12247. /**
  12248. * Sets the position the shadow will be casted from. Also use as the light position for both
  12249. * point and spot lights.
  12250. */
  12251. /**
  12252. * Sets the position the shadow will be casted from. Also use as the light position for both
  12253. * point and spot lights.
  12254. */
  12255. position: Vector3;
  12256. protected _direction: Vector3;
  12257. protected _setDirection(value: Vector3): void;
  12258. /**
  12259. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12260. * Also use as the light direction on spot and directional lights.
  12261. */
  12262. /**
  12263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12264. * Also use as the light direction on spot and directional lights.
  12265. */
  12266. direction: Vector3;
  12267. private _shadowMinZ;
  12268. /**
  12269. * Gets the shadow projection clipping minimum z value.
  12270. */
  12271. /**
  12272. * Sets the shadow projection clipping minimum z value.
  12273. */
  12274. shadowMinZ: number;
  12275. private _shadowMaxZ;
  12276. /**
  12277. * Sets the shadow projection clipping maximum z value.
  12278. */
  12279. /**
  12280. * Gets the shadow projection clipping maximum z value.
  12281. */
  12282. shadowMaxZ: number;
  12283. /**
  12284. * Callback defining a custom Projection Matrix Builder.
  12285. * This can be used to override the default projection matrix computation.
  12286. */
  12287. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12288. /**
  12289. * The transformed position. Position of the light in world space taking parenting in account.
  12290. */
  12291. transformedPosition: Vector3;
  12292. /**
  12293. * The transformed direction. Direction of the light in world space taking parenting in account.
  12294. */
  12295. transformedDirection: Vector3;
  12296. private _worldMatrix;
  12297. private _needProjectionMatrixCompute;
  12298. /**
  12299. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12300. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12301. */
  12302. computeTransformedInformation(): boolean;
  12303. /**
  12304. * Return the depth scale used for the shadow map.
  12305. * @returns the depth scale.
  12306. */
  12307. getDepthScale(): number;
  12308. /**
  12309. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12310. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12311. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12312. */
  12313. getShadowDirection(faceIndex?: number): Vector3;
  12314. /**
  12315. * Returns the ShadowLight absolute position in the World.
  12316. * @returns the position vector in world space
  12317. */
  12318. getAbsolutePosition(): Vector3;
  12319. /**
  12320. * Sets the ShadowLight direction toward the passed target.
  12321. * @param target The point tot target in local space
  12322. * @returns the updated ShadowLight direction
  12323. */
  12324. setDirectionToTarget(target: Vector3): Vector3;
  12325. /**
  12326. * Returns the light rotation in euler definition.
  12327. * @returns the x y z rotation in local space.
  12328. */
  12329. getRotation(): Vector3;
  12330. /**
  12331. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12332. * @returns true if a cube texture needs to be use
  12333. */
  12334. needCube(): boolean;
  12335. /**
  12336. * Detects if the projection matrix requires to be recomputed this frame.
  12337. * @returns true if it requires to be recomputed otherwise, false.
  12338. */
  12339. needProjectionMatrixCompute(): boolean;
  12340. /**
  12341. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12342. */
  12343. forceProjectionMatrixCompute(): void;
  12344. /**
  12345. * Get the world matrix of the sahdow lights.
  12346. * @hidden Internal Use Only
  12347. */
  12348. _getWorldMatrix(): Matrix;
  12349. /**
  12350. * Gets the minZ used for shadow according to both the scene and the light.
  12351. * @param activeCamera The camera we are returning the min for
  12352. * @returns the depth min z
  12353. */
  12354. getDepthMinZ(activeCamera: Camera): number;
  12355. /**
  12356. * Gets the maxZ used for shadow according to both the scene and the light.
  12357. * @param activeCamera The camera we are returning the max for
  12358. * @returns the depth max z
  12359. */
  12360. getDepthMaxZ(activeCamera: Camera): number;
  12361. /**
  12362. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12363. * @param matrix The materix to updated with the projection information
  12364. * @param viewMatrix The transform matrix of the light
  12365. * @param renderList The list of mesh to render in the map
  12366. * @returns The current light
  12367. */
  12368. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12369. }
  12370. }
  12371. declare module BABYLON {
  12372. /**
  12373. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12374. * These values define a cone of light starting from the position, emitting toward the direction.
  12375. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12376. * and the exponent defines the speed of the decay of the light with distance (reach).
  12377. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12378. */
  12379. class SpotLight extends ShadowLight {
  12380. private _angle;
  12381. /**
  12382. * Gets the cone angle of the spot light in Radians.
  12383. */
  12384. /**
  12385. * Sets the cone angle of the spot light in Radians.
  12386. */
  12387. angle: number;
  12388. private _shadowAngleScale;
  12389. /**
  12390. * Allows scaling the angle of the light for shadow generation only.
  12391. */
  12392. /**
  12393. * Allows scaling the angle of the light for shadow generation only.
  12394. */
  12395. shadowAngleScale: number;
  12396. /**
  12397. * The light decay speed with the distance from the emission spot.
  12398. */
  12399. exponent: number;
  12400. private _projectionTextureMatrix;
  12401. /**
  12402. * Allows reading the projecton texture
  12403. */
  12404. readonly projectionTextureMatrix: Matrix;
  12405. protected _projectionTextureLightNear: number;
  12406. /**
  12407. * Gets the near clip of the Spotlight for texture projection.
  12408. */
  12409. /**
  12410. * Sets the near clip of the Spotlight for texture projection.
  12411. */
  12412. projectionTextureLightNear: number;
  12413. protected _projectionTextureLightFar: number;
  12414. /**
  12415. * Gets the far clip of the Spotlight for texture projection.
  12416. */
  12417. /**
  12418. * Sets the far clip of the Spotlight for texture projection.
  12419. */
  12420. projectionTextureLightFar: number;
  12421. protected _projectionTextureUpDirection: Vector3;
  12422. /**
  12423. * Gets the Up vector of the Spotlight for texture projection.
  12424. */
  12425. /**
  12426. * Sets the Up vector of the Spotlight for texture projection.
  12427. */
  12428. projectionTextureUpDirection: Vector3;
  12429. private _projectionTexture;
  12430. /**
  12431. * Gets the projection texture of the light.
  12432. */
  12433. /**
  12434. * Sets the projection texture of the light.
  12435. */
  12436. projectionTexture: Nullable<BaseTexture>;
  12437. private _projectionTextureViewLightDirty;
  12438. private _projectionTextureProjectionLightDirty;
  12439. private _projectionTextureDirty;
  12440. private _projectionTextureViewTargetVector;
  12441. private _projectionTextureViewLightMatrix;
  12442. private _projectionTextureProjectionLightMatrix;
  12443. private _projectionTextureScalingMatrix;
  12444. /**
  12445. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12446. * It can cast shadows.
  12447. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12448. * @param name The light friendly name
  12449. * @param position The position of the spot light in the scene
  12450. * @param direction The direction of the light in the scene
  12451. * @param angle The cone angle of the light in Radians
  12452. * @param exponent The light decay speed with the distance from the emission spot
  12453. * @param scene The scene the lights belongs to
  12454. */
  12455. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12456. /**
  12457. * Returns the string "SpotLight".
  12458. * @returns the class name
  12459. */
  12460. getClassName(): string;
  12461. /**
  12462. * Returns the integer 2.
  12463. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12464. */
  12465. getTypeID(): number;
  12466. /**
  12467. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12468. */
  12469. protected _setDirection(value: Vector3): void;
  12470. /**
  12471. * Overrides the position setter to recompute the projection texture view light Matrix.
  12472. */
  12473. protected _setPosition(value: Vector3): void;
  12474. /**
  12475. * 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.
  12476. * Returns the SpotLight.
  12477. */
  12478. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12479. protected _computeProjectionTextureViewLightMatrix(): void;
  12480. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12481. /**
  12482. * Main function for light texture projection matrix computing.
  12483. */
  12484. protected _computeProjectionTextureMatrix(): void;
  12485. protected _buildUniformLayout(): void;
  12486. /**
  12487. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12488. * @param effect The effect to update
  12489. * @param lightIndex The index of the light in the effect to update
  12490. * @returns The spot light
  12491. */
  12492. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12493. /**
  12494. * Disposes the light and the associated resources.
  12495. */
  12496. dispose(): void;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. interface ILoadingScreen {
  12501. displayLoadingUI: () => void;
  12502. hideLoadingUI: () => void;
  12503. loadingUIBackgroundColor: string;
  12504. loadingUIText: string;
  12505. }
  12506. class DefaultLoadingScreen implements ILoadingScreen {
  12507. private _renderingCanvas;
  12508. private _loadingText;
  12509. private _loadingDivBackgroundColor;
  12510. private _loadingDiv;
  12511. private _loadingTextDiv;
  12512. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12513. displayLoadingUI(): void;
  12514. hideLoadingUI(): void;
  12515. loadingUIText: string;
  12516. loadingUIBackgroundColor: string;
  12517. private _resizeLoadingUI;
  12518. }
  12519. }
  12520. declare module BABYLON {
  12521. class SceneLoaderProgressEvent {
  12522. readonly lengthComputable: boolean;
  12523. readonly loaded: number;
  12524. readonly total: number;
  12525. constructor(lengthComputable: boolean, loaded: number, total: number);
  12526. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12527. }
  12528. interface ISceneLoaderPluginExtensions {
  12529. [extension: string]: {
  12530. isBinary: boolean;
  12531. };
  12532. }
  12533. interface ISceneLoaderPluginFactory {
  12534. name: string;
  12535. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12536. canDirectLoad?: (data: string) => boolean;
  12537. }
  12538. interface ISceneLoaderPlugin {
  12539. /**
  12540. * The friendly name of this plugin.
  12541. */
  12542. name: string;
  12543. /**
  12544. * The file extensions supported by this plugin.
  12545. */
  12546. extensions: string | ISceneLoaderPluginExtensions;
  12547. /**
  12548. * Import meshes into a scene.
  12549. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12550. * @param scene The scene to import into
  12551. * @param data The data to import
  12552. * @param rootUrl The root url for scene and resources
  12553. * @param meshes The meshes array to import into
  12554. * @param particleSystems The particle systems array to import into
  12555. * @param skeletons The skeletons array to import into
  12556. * @param onError The callback when import fails
  12557. * @returns True if successful or false otherwise
  12558. */
  12559. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12560. /**
  12561. * Load into a scene.
  12562. * @param scene The scene to load into
  12563. * @param data The data to import
  12564. * @param rootUrl The root url for scene and resources
  12565. * @param onError The callback when import fails
  12566. * @returns true if successful or false otherwise
  12567. */
  12568. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12569. /**
  12570. * The callback that returns true if the data can be directly loaded.
  12571. */
  12572. canDirectLoad?: (data: string) => boolean;
  12573. /**
  12574. * The callback that allows custom handling of the root url based on the response url.
  12575. */
  12576. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12577. /**
  12578. * Load into an asset container.
  12579. * @param scene The scene to load into
  12580. * @param data The data to import
  12581. * @param rootUrl The root url for scene and resources
  12582. * @param onError The callback when import fails
  12583. * @returns The loaded asset container
  12584. */
  12585. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12586. }
  12587. interface ISceneLoaderPluginAsync {
  12588. /**
  12589. * The friendly name of this plugin.
  12590. */
  12591. name: string;
  12592. /**
  12593. * The file extensions supported by this plugin.
  12594. */
  12595. extensions: string | ISceneLoaderPluginExtensions;
  12596. /**
  12597. * Import meshes into a scene.
  12598. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12599. * @param scene The scene to import into
  12600. * @param data The data to import
  12601. * @param rootUrl The root url for scene and resources
  12602. * @param onProgress The callback when the load progresses
  12603. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12604. */
  12605. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12606. meshes: AbstractMesh[];
  12607. particleSystems: ParticleSystem[];
  12608. skeletons: Skeleton[];
  12609. animationGroups: AnimationGroup[];
  12610. }>;
  12611. /**
  12612. * Load into a scene.
  12613. * @param scene The scene to load into
  12614. * @param data The data to import
  12615. * @param rootUrl The root url for scene and resources
  12616. * @param onProgress The callback when the load progresses
  12617. * @returns Nothing
  12618. */
  12619. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12620. /**
  12621. * The callback that returns true if the data can be directly loaded.
  12622. */
  12623. canDirectLoad?: (data: string) => boolean;
  12624. /**
  12625. * The callback that allows custom handling of the root url based on the response url.
  12626. */
  12627. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12628. /**
  12629. * Load into an asset container.
  12630. * @param scene The scene to load into
  12631. * @param data The data to import
  12632. * @param rootUrl The root url for scene and resources
  12633. * @param onProgress The callback when the load progresses
  12634. * @returns The loaded asset container
  12635. */
  12636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12637. }
  12638. class SceneLoader {
  12639. private static _ForceFullSceneLoadingForIncremental;
  12640. private static _ShowLoadingScreen;
  12641. private static _CleanBoneMatrixWeights;
  12642. static readonly NO_LOGGING: number;
  12643. static readonly MINIMAL_LOGGING: number;
  12644. static readonly SUMMARY_LOGGING: number;
  12645. static readonly DETAILED_LOGGING: number;
  12646. private static _loggingLevel;
  12647. static ForceFullSceneLoadingForIncremental: boolean;
  12648. static ShowLoadingScreen: boolean;
  12649. static loggingLevel: number;
  12650. static CleanBoneMatrixWeights: boolean;
  12651. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12652. private static _registeredPlugins;
  12653. private static _getDefaultPlugin();
  12654. private static _getPluginForExtension(extension);
  12655. private static _getPluginForDirectLoad(data);
  12656. private static _getPluginForFilename(sceneFilename);
  12657. private static _getDirectLoad(sceneFilename);
  12658. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12659. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12660. static IsPluginForExtensionAvailable(extension: string): boolean;
  12661. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12662. /**
  12663. * Import meshes into a scene
  12664. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12665. * @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)
  12666. * @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)
  12667. * @param scene the instance of BABYLON.Scene to append to
  12668. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12669. * @param onProgress a callback with a progress event for each file being loaded
  12670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12671. * @param pluginExtension the extension used to determine the plugin
  12672. * @returns The loaded plugin
  12673. */
  12674. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12675. /**
  12676. * Import meshes into a scene
  12677. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12678. * @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)
  12679. * @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)
  12680. * @param scene the instance of BABYLON.Scene to append to
  12681. * @param onProgress a callback with a progress event for each file being loaded
  12682. * @param pluginExtension the extension used to determine the plugin
  12683. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12684. */
  12685. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12686. meshes: AbstractMesh[];
  12687. particleSystems: ParticleSystem[];
  12688. skeletons: Skeleton[];
  12689. animationGroups: AnimationGroup[];
  12690. }>;
  12691. /**
  12692. * Load a scene
  12693. * @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)
  12694. * @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)
  12695. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12696. * @param onSuccess a callback with the scene when import succeeds
  12697. * @param onProgress a callback with a progress event for each file being loaded
  12698. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12699. * @param pluginExtension the extension used to determine the plugin
  12700. * @returns The loaded plugin
  12701. */
  12702. 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>;
  12703. /**
  12704. * Load a scene
  12705. * @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)
  12706. * @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)
  12707. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12708. * @param onProgress a callback with a progress event for each file being loaded
  12709. * @param pluginExtension the extension used to determine the plugin
  12710. * @returns The loaded scene
  12711. */
  12712. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12713. /**
  12714. * Append a scene
  12715. * @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)
  12716. * @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)
  12717. * @param scene is the instance of BABYLON.Scene to append to
  12718. * @param onSuccess a callback with the scene when import succeeds
  12719. * @param onProgress a callback with a progress event for each file being loaded
  12720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12721. * @param pluginExtension the extension used to determine the plugin
  12722. * @returns The loaded plugin
  12723. */
  12724. 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>;
  12725. /**
  12726. * Append a scene
  12727. * @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)
  12728. * @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)
  12729. * @param scene is the instance of BABYLON.Scene to append to
  12730. * @param onProgress a callback with a progress event for each file being loaded
  12731. * @param pluginExtension the extension used to determine the plugin
  12732. * @returns The given scene
  12733. */
  12734. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12735. /**
  12736. * Load a scene into an asset container
  12737. * @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)
  12738. * @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)
  12739. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12740. * @param onSuccess a callback with the scene when import succeeds
  12741. * @param onProgress a callback with a progress event for each file being loaded
  12742. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12743. * @param pluginExtension the extension used to determine the plugin
  12744. * @returns The loaded plugin
  12745. */
  12746. 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>;
  12747. /**
  12748. * Load a scene into an asset container
  12749. * @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)
  12750. * @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)
  12751. * @param scene is the instance of BABYLON.Scene to append to
  12752. * @param onProgress a callback with a progress event for each file being loaded
  12753. * @param pluginExtension the extension used to determine the plugin
  12754. * @returns The loaded asset container
  12755. */
  12756. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12757. }
  12758. }
  12759. declare module BABYLON {
  12760. /**
  12761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12763. * 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;
  12764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12765. */
  12766. class ColorCurves {
  12767. private _dirty;
  12768. private _tempColor;
  12769. private _globalCurve;
  12770. private _highlightsCurve;
  12771. private _midtonesCurve;
  12772. private _shadowsCurve;
  12773. private _positiveCurve;
  12774. private _negativeCurve;
  12775. private _globalHue;
  12776. private _globalDensity;
  12777. private _globalSaturation;
  12778. private _globalExposure;
  12779. /**
  12780. * Gets the global Hue value.
  12781. * 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).
  12782. */
  12783. /**
  12784. * Sets the global Hue value.
  12785. * 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).
  12786. */
  12787. globalHue: number;
  12788. /**
  12789. * Gets the global Density value.
  12790. * 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.
  12791. * Values less than zero provide a filter of opposite hue.
  12792. */
  12793. /**
  12794. * Sets the global Density value.
  12795. * 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.
  12796. * Values less than zero provide a filter of opposite hue.
  12797. */
  12798. globalDensity: number;
  12799. /**
  12800. * Gets the global Saturation value.
  12801. * 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.
  12802. */
  12803. /**
  12804. * Sets the global Saturation value.
  12805. * 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.
  12806. */
  12807. globalSaturation: number;
  12808. /**
  12809. * Gets the global Exposure value.
  12810. * 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.
  12811. */
  12812. /**
  12813. * Sets the global Exposure value.
  12814. * 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.
  12815. */
  12816. globalExposure: number;
  12817. private _highlightsHue;
  12818. private _highlightsDensity;
  12819. private _highlightsSaturation;
  12820. private _highlightsExposure;
  12821. /**
  12822. * Gets the highlights Hue value.
  12823. * 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).
  12824. */
  12825. /**
  12826. * Sets the highlights Hue value.
  12827. * 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).
  12828. */
  12829. highlightsHue: number;
  12830. /**
  12831. * Gets the highlights Density value.
  12832. * 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.
  12833. * Values less than zero provide a filter of opposite hue.
  12834. */
  12835. /**
  12836. * Sets the highlights Density value.
  12837. * 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.
  12838. * Values less than zero provide a filter of opposite hue.
  12839. */
  12840. highlightsDensity: number;
  12841. /**
  12842. * Gets the highlights Saturation value.
  12843. * 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.
  12844. */
  12845. /**
  12846. * Sets the highlights Saturation value.
  12847. * 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.
  12848. */
  12849. highlightsSaturation: number;
  12850. /**
  12851. * Gets the highlights Exposure value.
  12852. * 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.
  12853. */
  12854. /**
  12855. * Sets the highlights Exposure value.
  12856. * 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.
  12857. */
  12858. highlightsExposure: number;
  12859. private _midtonesHue;
  12860. private _midtonesDensity;
  12861. private _midtonesSaturation;
  12862. private _midtonesExposure;
  12863. /**
  12864. * Gets the midtones Hue value.
  12865. * 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).
  12866. */
  12867. /**
  12868. * Sets the midtones Hue value.
  12869. * 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).
  12870. */
  12871. midtonesHue: number;
  12872. /**
  12873. * Gets the midtones Density value.
  12874. * 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.
  12875. * Values less than zero provide a filter of opposite hue.
  12876. */
  12877. /**
  12878. * Sets the midtones Density value.
  12879. * 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.
  12880. * Values less than zero provide a filter of opposite hue.
  12881. */
  12882. midtonesDensity: number;
  12883. /**
  12884. * Gets the midtones Saturation value.
  12885. * 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.
  12886. */
  12887. /**
  12888. * Sets the midtones Saturation value.
  12889. * 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.
  12890. */
  12891. midtonesSaturation: number;
  12892. /**
  12893. * Gets the midtones Exposure value.
  12894. * 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.
  12895. */
  12896. /**
  12897. * Sets the midtones Exposure value.
  12898. * 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.
  12899. */
  12900. midtonesExposure: number;
  12901. private _shadowsHue;
  12902. private _shadowsDensity;
  12903. private _shadowsSaturation;
  12904. private _shadowsExposure;
  12905. /**
  12906. * Gets the shadows Hue value.
  12907. * 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).
  12908. */
  12909. /**
  12910. * Sets the shadows Hue value.
  12911. * 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).
  12912. */
  12913. shadowsHue: number;
  12914. /**
  12915. * Gets the shadows Density value.
  12916. * 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.
  12917. * Values less than zero provide a filter of opposite hue.
  12918. */
  12919. /**
  12920. * Sets the shadows Density value.
  12921. * 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.
  12922. * Values less than zero provide a filter of opposite hue.
  12923. */
  12924. shadowsDensity: number;
  12925. /**
  12926. * Gets the shadows Saturation value.
  12927. * 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.
  12928. */
  12929. /**
  12930. * Sets the shadows Saturation value.
  12931. * 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.
  12932. */
  12933. shadowsSaturation: number;
  12934. /**
  12935. * Gets the shadows Exposure value.
  12936. * 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.
  12937. */
  12938. /**
  12939. * Sets the shadows Exposure value.
  12940. * 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.
  12941. */
  12942. shadowsExposure: number;
  12943. getClassName(): string;
  12944. /**
  12945. * Binds the color curves to the shader.
  12946. * @param colorCurves The color curve to bind
  12947. * @param effect The effect to bind to
  12948. */
  12949. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12950. /**
  12951. * Prepare the list of uniforms associated with the ColorCurves effects.
  12952. * @param uniformsList The list of uniforms used in the effect
  12953. */
  12954. static PrepareUniforms(uniformsList: string[]): void;
  12955. /**
  12956. * Returns color grading data based on a hue, density, saturation and exposure value.
  12957. * @param filterHue The hue of the color filter.
  12958. * @param filterDensity The density of the color filter.
  12959. * @param saturation The saturation.
  12960. * @param exposure The exposure.
  12961. * @param result The result data container.
  12962. */
  12963. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12964. /**
  12965. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12966. * @param value The input slider value in range [-100,100].
  12967. * @returns Adjusted value.
  12968. */
  12969. private static applyColorGradingSliderNonlinear(value);
  12970. /**
  12971. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12972. * @param hue The hue (H) input.
  12973. * @param saturation The saturation (S) input.
  12974. * @param brightness The brightness (B) input.
  12975. * @result An RGBA color represented as Vector4.
  12976. */
  12977. private static fromHSBToRef(hue, saturation, brightness, result);
  12978. /**
  12979. * Returns a value clamped between min and max
  12980. * @param value The value to clamp
  12981. * @param min The minimum of value
  12982. * @param max The maximum of value
  12983. * @returns The clamped value.
  12984. */
  12985. private static clamp(value, min, max);
  12986. /**
  12987. * Clones the current color curve instance.
  12988. * @return The cloned curves
  12989. */
  12990. clone(): ColorCurves;
  12991. /**
  12992. * Serializes the current color curve instance to a json representation.
  12993. * @return a JSON representation
  12994. */
  12995. serialize(): any;
  12996. /**
  12997. * Parses the color curve from a json representation.
  12998. * @param source the JSON source to parse
  12999. * @return The parsed curves
  13000. */
  13001. static Parse(source: any): ColorCurves;
  13002. }
  13003. }
  13004. declare module BABYLON {
  13005. /**
  13006. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13007. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13008. */
  13009. class EffectFallbacks {
  13010. private _defines;
  13011. private _currentRank;
  13012. private _maxRank;
  13013. private _mesh;
  13014. /**
  13015. * Removes the fallback from the bound mesh.
  13016. */
  13017. unBindMesh(): void;
  13018. /**
  13019. * Adds a fallback on the specified property.
  13020. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13021. * @param define The name of the define in the shader
  13022. */
  13023. addFallback(rank: number, define: string): void;
  13024. /**
  13025. * Sets the mesh to use CPU skinning when needing to fallback.
  13026. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13027. * @param mesh The mesh to use the fallbacks.
  13028. */
  13029. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13030. /**
  13031. * Checks to see if more fallbacks are still availible.
  13032. */
  13033. readonly isMoreFallbacks: boolean;
  13034. /**
  13035. * Removes the defines that shoould be removed when falling back.
  13036. * @param currentDefines defines the current define statements for the shader.
  13037. * @param effect defines the current effect we try to compile
  13038. * @returns The resulting defines with defines of the current rank removed.
  13039. */
  13040. reduce(currentDefines: string, effect: Effect): string;
  13041. }
  13042. /**
  13043. * Options to be used when creating an effect.
  13044. */
  13045. class EffectCreationOptions {
  13046. /**
  13047. * Atrributes that will be used in the shader.
  13048. */
  13049. attributes: string[];
  13050. /**
  13051. * Uniform varible names that will be set in the shader.
  13052. */
  13053. uniformsNames: string[];
  13054. /**
  13055. * Uniform buffer varible names that will be set in the shader.
  13056. */
  13057. uniformBuffersNames: string[];
  13058. /**
  13059. * Sampler texture variable names that will be set in the shader.
  13060. */
  13061. samplers: string[];
  13062. /**
  13063. * Define statements that will be set in the shader.
  13064. */
  13065. defines: any;
  13066. /**
  13067. * Possible fallbacks for this effect to improve performance when needed.
  13068. */
  13069. fallbacks: Nullable<EffectFallbacks>;
  13070. /**
  13071. * Callback that will be called when the shader is compiled.
  13072. */
  13073. onCompiled: Nullable<(effect: Effect) => void>;
  13074. /**
  13075. * Callback that will be called if an error occurs during shader compilation.
  13076. */
  13077. onError: Nullable<(effect: Effect, errors: string) => void>;
  13078. /**
  13079. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13080. */
  13081. indexParameters: any;
  13082. /**
  13083. * Max number of lights that can be used in the shader.
  13084. */
  13085. maxSimultaneousLights: number;
  13086. /**
  13087. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13088. */
  13089. transformFeedbackVaryings: Nullable<string[]>;
  13090. }
  13091. /**
  13092. * Effect containing vertex and fragment shader that can be executed on an object.
  13093. */
  13094. class Effect {
  13095. /**
  13096. * Name of the effect.
  13097. */
  13098. name: any;
  13099. /**
  13100. * String container all the define statements that should be set on the shader.
  13101. */
  13102. defines: string;
  13103. /**
  13104. * Callback that will be called when the shader is compiled.
  13105. */
  13106. onCompiled: Nullable<(effect: Effect) => void>;
  13107. /**
  13108. * Callback that will be called if an error occurs during shader compilation.
  13109. */
  13110. onError: Nullable<(effect: Effect, errors: string) => void>;
  13111. /**
  13112. * Callback that will be called when effect is bound.
  13113. */
  13114. onBind: Nullable<(effect: Effect) => void>;
  13115. /**
  13116. * Unique ID of the effect.
  13117. */
  13118. uniqueId: number;
  13119. /**
  13120. * Observable that will be called when the shader is compiled.
  13121. */
  13122. onCompileObservable: Observable<Effect>;
  13123. /**
  13124. * Observable that will be called if an error occurs during shader compilation.
  13125. */
  13126. onErrorObservable: Observable<Effect>;
  13127. /**
  13128. * Observable that will be called when effect is bound.
  13129. */
  13130. onBindObservable: Observable<Effect>;
  13131. /** @hidden */
  13132. _bonesComputationForcedToCPU: boolean;
  13133. private static _uniqueIdSeed;
  13134. private _engine;
  13135. private _uniformBuffersNames;
  13136. private _uniformsNames;
  13137. private _samplers;
  13138. private _isReady;
  13139. private _compilationError;
  13140. private _attributesNames;
  13141. private _attributes;
  13142. private _uniforms;
  13143. /**
  13144. * Key for the effect.
  13145. */
  13146. _key: string;
  13147. private _indexParameters;
  13148. private _fallbacks;
  13149. private _vertexSourceCode;
  13150. private _fragmentSourceCode;
  13151. private _vertexSourceCodeOverride;
  13152. private _fragmentSourceCodeOverride;
  13153. private _transformFeedbackVaryings;
  13154. /**
  13155. * Compiled shader to webGL program.
  13156. */
  13157. _program: WebGLProgram;
  13158. private _valueCache;
  13159. private static _baseCache;
  13160. /**
  13161. * Instantiates an effect.
  13162. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13163. * @param baseName Name of the effect.
  13164. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13165. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13166. * @param samplers List of sampler variables that will be passed to the shader.
  13167. * @param engine Engine to be used to render the effect
  13168. * @param defines Define statements to be added to the shader.
  13169. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13170. * @param onCompiled Callback that will be called when the shader is compiled.
  13171. * @param onError Callback that will be called if an error occurs during shader compilation.
  13172. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13173. */
  13174. 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);
  13175. /**
  13176. * Unique key for this effect
  13177. */
  13178. readonly key: string;
  13179. /**
  13180. * If the effect has been compiled and prepared.
  13181. * @returns if the effect is compiled and prepared.
  13182. */
  13183. isReady(): boolean;
  13184. /**
  13185. * The engine the effect was initialized with.
  13186. * @returns the engine.
  13187. */
  13188. getEngine(): Engine;
  13189. /**
  13190. * The compiled webGL program for the effect
  13191. * @returns the webGL program.
  13192. */
  13193. getProgram(): WebGLProgram;
  13194. /**
  13195. * The set of names of attribute variables for the shader.
  13196. * @returns An array of attribute names.
  13197. */
  13198. getAttributesNames(): string[];
  13199. /**
  13200. * Returns the attribute at the given index.
  13201. * @param index The index of the attribute.
  13202. * @returns The location of the attribute.
  13203. */
  13204. getAttributeLocation(index: number): number;
  13205. /**
  13206. * Returns the attribute based on the name of the variable.
  13207. * @param name of the attribute to look up.
  13208. * @returns the attribute location.
  13209. */
  13210. getAttributeLocationByName(name: string): number;
  13211. /**
  13212. * The number of attributes.
  13213. * @returns the numnber of attributes.
  13214. */
  13215. getAttributesCount(): number;
  13216. /**
  13217. * Gets the index of a uniform variable.
  13218. * @param uniformName of the uniform to look up.
  13219. * @returns the index.
  13220. */
  13221. getUniformIndex(uniformName: string): number;
  13222. /**
  13223. * Returns the attribute based on the name of the variable.
  13224. * @param uniformName of the uniform to look up.
  13225. * @returns the location of the uniform.
  13226. */
  13227. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13228. /**
  13229. * Returns an array of sampler variable names
  13230. * @returns The array of sampler variable neames.
  13231. */
  13232. getSamplers(): string[];
  13233. /**
  13234. * The error from the last compilation.
  13235. * @returns the error string.
  13236. */
  13237. getCompilationError(): string;
  13238. /**
  13239. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13240. * @param func The callback to be used.
  13241. */
  13242. executeWhenCompiled(func: (effect: Effect) => void): void;
  13243. /** @hidden */
  13244. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13245. /** @hidden */
  13246. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13247. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  13248. private _processShaderConversion(sourceCode, isFragment, callback);
  13249. private _processIncludes(sourceCode, callback);
  13250. private _processPrecision(source);
  13251. /**
  13252. * Recompiles the webGL program
  13253. * @param vertexSourceCode The source code for the vertex shader.
  13254. * @param fragmentSourceCode The source code for the fragment shader.
  13255. * @param onCompiled Callback called when completed.
  13256. * @param onError Callback called on error.
  13257. */
  13258. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13259. /**
  13260. * Gets the uniform locations of the the specified variable names
  13261. * @param names THe names of the variables to lookup.
  13262. * @returns Array of locations in the same order as variable names.
  13263. */
  13264. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13265. /**
  13266. * Prepares the effect
  13267. */
  13268. _prepareEffect(): void;
  13269. /**
  13270. * Checks if the effect is supported. (Must be called after compilation)
  13271. */
  13272. readonly isSupported: boolean;
  13273. /**
  13274. * Binds a texture to the engine to be used as output of the shader.
  13275. * @param channel Name of the output variable.
  13276. * @param texture Texture to bind.
  13277. */
  13278. _bindTexture(channel: string, texture: InternalTexture): void;
  13279. /**
  13280. * Sets a texture on the engine to be used in the shader.
  13281. * @param channel Name of the sampler variable.
  13282. * @param texture Texture to set.
  13283. */
  13284. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13285. /**
  13286. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13287. * @param channel Name of the sampler variable.
  13288. * @param texture Texture to set.
  13289. */
  13290. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13291. /**
  13292. * Sets an array of textures on the engine to be used in the shader.
  13293. * @param channel Name of the variable.
  13294. * @param textures Textures to set.
  13295. */
  13296. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13297. /**
  13298. * 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)
  13299. * @param channel Name of the sampler variable.
  13300. * @param postProcess Post process to get the input texture from.
  13301. */
  13302. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13303. /**
  13304. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13305. * 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)
  13306. * @param channel Name of the sampler variable.
  13307. * @param postProcess Post process to get the output texture from.
  13308. */
  13309. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13310. /** @hidden */
  13311. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13312. /** @hidden */
  13313. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13314. /** @hidden */
  13315. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13316. /** @hidden */
  13317. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13318. /**
  13319. * Binds a buffer to a uniform.
  13320. * @param buffer Buffer to bind.
  13321. * @param name Name of the uniform variable to bind to.
  13322. */
  13323. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13324. /**
  13325. * Binds block to a uniform.
  13326. * @param blockName Name of the block to bind.
  13327. * @param index Index to bind.
  13328. */
  13329. bindUniformBlock(blockName: string, index: number): void;
  13330. /**
  13331. * Sets an interger value on a uniform variable.
  13332. * @param uniformName Name of the variable.
  13333. * @param value Value to be set.
  13334. * @returns this effect.
  13335. */
  13336. setInt(uniformName: string, value: number): Effect;
  13337. /**
  13338. * Sets an int array on a uniform variable.
  13339. * @param uniformName Name of the variable.
  13340. * @param array array to be set.
  13341. * @returns this effect.
  13342. */
  13343. setIntArray(uniformName: string, array: Int32Array): Effect;
  13344. /**
  13345. * 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)
  13346. * @param uniformName Name of the variable.
  13347. * @param array array to be set.
  13348. * @returns this effect.
  13349. */
  13350. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13351. /**
  13352. * 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)
  13353. * @param uniformName Name of the variable.
  13354. * @param array array to be set.
  13355. * @returns this effect.
  13356. */
  13357. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13358. /**
  13359. * 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)
  13360. * @param uniformName Name of the variable.
  13361. * @param array array to be set.
  13362. * @returns this effect.
  13363. */
  13364. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13365. /**
  13366. * Sets an float array on a uniform variable.
  13367. * @param uniformName Name of the variable.
  13368. * @param array array to be set.
  13369. * @returns this effect.
  13370. */
  13371. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13372. /**
  13373. * 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)
  13374. * @param uniformName Name of the variable.
  13375. * @param array array to be set.
  13376. * @returns this effect.
  13377. */
  13378. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13379. /**
  13380. * 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)
  13381. * @param uniformName Name of the variable.
  13382. * @param array array to be set.
  13383. * @returns this effect.
  13384. */
  13385. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13386. /**
  13387. * 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)
  13388. * @param uniformName Name of the variable.
  13389. * @param array array to be set.
  13390. * @returns this effect.
  13391. */
  13392. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13393. /**
  13394. * Sets an array on a uniform variable.
  13395. * @param uniformName Name of the variable.
  13396. * @param array array to be set.
  13397. * @returns this effect.
  13398. */
  13399. setArray(uniformName: string, array: number[]): Effect;
  13400. /**
  13401. * 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)
  13402. * @param uniformName Name of the variable.
  13403. * @param array array to be set.
  13404. * @returns this effect.
  13405. */
  13406. setArray2(uniformName: string, array: number[]): Effect;
  13407. /**
  13408. * 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)
  13409. * @param uniformName Name of the variable.
  13410. * @param array array to be set.
  13411. * @returns this effect.
  13412. */
  13413. setArray3(uniformName: string, array: number[]): Effect;
  13414. /**
  13415. * 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)
  13416. * @param uniformName Name of the variable.
  13417. * @param array array to be set.
  13418. * @returns this effect.
  13419. */
  13420. setArray4(uniformName: string, array: number[]): Effect;
  13421. /**
  13422. * Sets matrices on a uniform variable.
  13423. * @param uniformName Name of the variable.
  13424. * @param matrices matrices to be set.
  13425. * @returns this effect.
  13426. */
  13427. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13428. /**
  13429. * Sets matrix on a uniform variable.
  13430. * @param uniformName Name of the variable.
  13431. * @param matrix matrix to be set.
  13432. * @returns this effect.
  13433. */
  13434. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13435. /**
  13436. * 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)
  13437. * @param uniformName Name of the variable.
  13438. * @param matrix matrix to be set.
  13439. * @returns this effect.
  13440. */
  13441. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13442. /**
  13443. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13444. * @param uniformName Name of the variable.
  13445. * @param matrix matrix to be set.
  13446. * @returns this effect.
  13447. */
  13448. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13449. /**
  13450. * Sets a float on a uniform variable.
  13451. * @param uniformName Name of the variable.
  13452. * @param value value to be set.
  13453. * @returns this effect.
  13454. */
  13455. setFloat(uniformName: string, value: number): Effect;
  13456. /**
  13457. * Sets a boolean on a uniform variable.
  13458. * @param uniformName Name of the variable.
  13459. * @param bool value to be set.
  13460. * @returns this effect.
  13461. */
  13462. setBool(uniformName: string, bool: boolean): Effect;
  13463. /**
  13464. * Sets a Vector2 on a uniform variable.
  13465. * @param uniformName Name of the variable.
  13466. * @param vector2 vector2 to be set.
  13467. * @returns this effect.
  13468. */
  13469. setVector2(uniformName: string, vector2: Vector2): Effect;
  13470. /**
  13471. * Sets a float2 on a uniform variable.
  13472. * @param uniformName Name of the variable.
  13473. * @param x First float in float2.
  13474. * @param y Second float in float2.
  13475. * @returns this effect.
  13476. */
  13477. setFloat2(uniformName: string, x: number, y: number): Effect;
  13478. /**
  13479. * Sets a Vector3 on a uniform variable.
  13480. * @param uniformName Name of the variable.
  13481. * @param vector3 Value to be set.
  13482. * @returns this effect.
  13483. */
  13484. setVector3(uniformName: string, vector3: Vector3): Effect;
  13485. /**
  13486. * Sets a float3 on a uniform variable.
  13487. * @param uniformName Name of the variable.
  13488. * @param x First float in float3.
  13489. * @param y Second float in float3.
  13490. * @param z Third float in float3.
  13491. * @returns this effect.
  13492. */
  13493. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13494. /**
  13495. * Sets a Vector4 on a uniform variable.
  13496. * @param uniformName Name of the variable.
  13497. * @param vector4 Value to be set.
  13498. * @returns this effect.
  13499. */
  13500. setVector4(uniformName: string, vector4: Vector4): Effect;
  13501. /**
  13502. * Sets a float4 on a uniform variable.
  13503. * @param uniformName Name of the variable.
  13504. * @param x First float in float4.
  13505. * @param y Second float in float4.
  13506. * @param z Third float in float4.
  13507. * @param w Fourth float in float4.
  13508. * @returns this effect.
  13509. */
  13510. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13511. /**
  13512. * Sets a Color3 on a uniform variable.
  13513. * @param uniformName Name of the variable.
  13514. * @param color3 Value to be set.
  13515. * @returns this effect.
  13516. */
  13517. setColor3(uniformName: string, color3: Color3): Effect;
  13518. /**
  13519. * Sets a Color4 on a uniform variable.
  13520. * @param uniformName Name of the variable.
  13521. * @param color3 Value to be set.
  13522. * @param alpha Alpha value to be set.
  13523. * @returns this effect.
  13524. */
  13525. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13526. /**
  13527. * Sets a Color4 on a uniform variable
  13528. * @param uniformName defines the name of the variable
  13529. * @param color4 defines the value to be set
  13530. * @returns this effect.
  13531. */
  13532. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13533. /**
  13534. * Store of each shader (The can be looked up using effect.key)
  13535. */
  13536. static ShadersStore: {
  13537. [key: string]: string;
  13538. };
  13539. /**
  13540. * Store of each included file for a shader (The can be looked up using effect.key)
  13541. */
  13542. static IncludesShadersStore: {
  13543. [key: string]: string;
  13544. };
  13545. /**
  13546. * Resets the cache of effects.
  13547. */
  13548. static ResetCache(): void;
  13549. }
  13550. }
  13551. declare module BABYLON {
  13552. class FresnelParameters {
  13553. private _isEnabled;
  13554. isEnabled: boolean;
  13555. leftColor: Color3;
  13556. rightColor: Color3;
  13557. bias: number;
  13558. power: number;
  13559. clone(): FresnelParameters;
  13560. serialize(): any;
  13561. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. /**
  13566. * Interface to follow in your material defines to integrate easily the
  13567. * Image proccessing functions.
  13568. * @hidden
  13569. */
  13570. interface IImageProcessingConfigurationDefines {
  13571. IMAGEPROCESSING: boolean;
  13572. VIGNETTE: boolean;
  13573. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13574. VIGNETTEBLENDMODEOPAQUE: boolean;
  13575. TONEMAPPING: boolean;
  13576. CONTRAST: boolean;
  13577. EXPOSURE: boolean;
  13578. COLORCURVES: boolean;
  13579. COLORGRADING: boolean;
  13580. COLORGRADING3D: boolean;
  13581. SAMPLER3DGREENDEPTH: boolean;
  13582. SAMPLER3DBGRMAP: boolean;
  13583. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13584. }
  13585. /**
  13586. * This groups together the common properties used for image processing either in direct forward pass
  13587. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13588. * or not.
  13589. */
  13590. class ImageProcessingConfiguration {
  13591. /**
  13592. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13593. */
  13594. colorCurves: Nullable<ColorCurves>;
  13595. private _colorCurvesEnabled;
  13596. /**
  13597. * Gets wether the color curves effect is enabled.
  13598. */
  13599. /**
  13600. * Sets wether the color curves effect is enabled.
  13601. */
  13602. colorCurvesEnabled: boolean;
  13603. /**
  13604. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13605. */
  13606. colorGradingTexture: Nullable<BaseTexture>;
  13607. private _colorGradingEnabled;
  13608. /**
  13609. * Gets wether the color grading effect is enabled.
  13610. */
  13611. /**
  13612. * Sets wether the color grading effect is enabled.
  13613. */
  13614. colorGradingEnabled: boolean;
  13615. private _colorGradingWithGreenDepth;
  13616. /**
  13617. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13618. */
  13619. /**
  13620. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13621. */
  13622. colorGradingWithGreenDepth: boolean;
  13623. private _colorGradingBGR;
  13624. /**
  13625. * Gets wether the color grading texture contains BGR values.
  13626. */
  13627. /**
  13628. * Sets wether the color grading texture contains BGR values.
  13629. */
  13630. colorGradingBGR: boolean;
  13631. _exposure: number;
  13632. /**
  13633. * Gets the Exposure used in the effect.
  13634. */
  13635. /**
  13636. * Sets the Exposure used in the effect.
  13637. */
  13638. exposure: number;
  13639. private _toneMappingEnabled;
  13640. /**
  13641. * Gets wether the tone mapping effect is enabled.
  13642. */
  13643. /**
  13644. * Sets wether the tone mapping effect is enabled.
  13645. */
  13646. toneMappingEnabled: boolean;
  13647. protected _contrast: number;
  13648. /**
  13649. * Gets the contrast used in the effect.
  13650. */
  13651. /**
  13652. * Sets the contrast used in the effect.
  13653. */
  13654. contrast: number;
  13655. /**
  13656. * Vignette stretch size.
  13657. */
  13658. vignetteStretch: number;
  13659. /**
  13660. * Vignette centre X Offset.
  13661. */
  13662. vignetteCentreX: number;
  13663. /**
  13664. * Vignette centre Y Offset.
  13665. */
  13666. vignetteCentreY: number;
  13667. /**
  13668. * Vignette weight or intensity of the vignette effect.
  13669. */
  13670. vignetteWeight: number;
  13671. /**
  13672. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13673. * if vignetteEnabled is set to true.
  13674. */
  13675. vignetteColor: Color4;
  13676. /**
  13677. * Camera field of view used by the Vignette effect.
  13678. */
  13679. vignetteCameraFov: number;
  13680. private _vignetteBlendMode;
  13681. /**
  13682. * Gets the vignette blend mode allowing different kind of effect.
  13683. */
  13684. /**
  13685. * Sets the vignette blend mode allowing different kind of effect.
  13686. */
  13687. vignetteBlendMode: number;
  13688. private _vignetteEnabled;
  13689. /**
  13690. * Gets wether the vignette effect is enabled.
  13691. */
  13692. /**
  13693. * Sets wether the vignette effect is enabled.
  13694. */
  13695. vignetteEnabled: boolean;
  13696. private _applyByPostProcess;
  13697. /**
  13698. * Gets wether the image processing is applied through a post process or not.
  13699. */
  13700. /**
  13701. * Sets wether the image processing is applied through a post process or not.
  13702. */
  13703. applyByPostProcess: boolean;
  13704. private _isEnabled;
  13705. /**
  13706. * Gets wether the image processing is enabled or not.
  13707. */
  13708. /**
  13709. * Sets wether the image processing is enabled or not.
  13710. */
  13711. isEnabled: boolean;
  13712. /**
  13713. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13714. */
  13715. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13716. /**
  13717. * Method called each time the image processing information changes requires to recompile the effect.
  13718. */
  13719. protected _updateParameters(): void;
  13720. getClassName(): string;
  13721. /**
  13722. * Prepare the list of uniforms associated with the Image Processing effects.
  13723. * @param uniformsList The list of uniforms used in the effect
  13724. * @param defines the list of defines currently in use
  13725. */
  13726. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13727. /**
  13728. * Prepare the list of samplers associated with the Image Processing effects.
  13729. * @param uniformsList The list of uniforms used in the effect
  13730. * @param defines the list of defines currently in use
  13731. */
  13732. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13733. /**
  13734. * Prepare the list of defines associated to the shader.
  13735. * @param defines the list of defines to complete
  13736. */
  13737. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13738. /**
  13739. * Returns true if all the image processing information are ready.
  13740. */
  13741. isReady(): boolean;
  13742. /**
  13743. * Binds the image processing to the shader.
  13744. * @param effect The effect to bind to
  13745. */
  13746. bind(effect: Effect, aspectRatio?: number): void;
  13747. /**
  13748. * Clones the current image processing instance.
  13749. * @return The cloned image processing
  13750. */
  13751. clone(): ImageProcessingConfiguration;
  13752. /**
  13753. * Serializes the current image processing instance to a json representation.
  13754. * @return a JSON representation
  13755. */
  13756. serialize(): any;
  13757. /**
  13758. * Parses the image processing from a json representation.
  13759. * @param source the JSON source to parse
  13760. * @return The parsed image processing
  13761. */
  13762. static Parse(source: any): ImageProcessingConfiguration;
  13763. private static _VIGNETTEMODE_MULTIPLY;
  13764. private static _VIGNETTEMODE_OPAQUE;
  13765. /**
  13766. * Used to apply the vignette as a mix with the pixel color.
  13767. */
  13768. static readonly VIGNETTEMODE_MULTIPLY: number;
  13769. /**
  13770. * Used to apply the vignette as a replacement of the pixel color.
  13771. */
  13772. static readonly VIGNETTEMODE_OPAQUE: number;
  13773. }
  13774. }
  13775. declare module BABYLON {
  13776. /**
  13777. * Manages the defines for the Material
  13778. */
  13779. class MaterialDefines {
  13780. private _keys;
  13781. private _isDirty;
  13782. /** @hidden */
  13783. _renderId: number;
  13784. /** @hidden */
  13785. _areLightsDirty: boolean;
  13786. /** @hidden */
  13787. _areAttributesDirty: boolean;
  13788. /** @hidden */
  13789. _areTexturesDirty: boolean;
  13790. /** @hidden */
  13791. _areFresnelDirty: boolean;
  13792. /** @hidden */
  13793. _areMiscDirty: boolean;
  13794. /** @hidden */
  13795. _areImageProcessingDirty: boolean;
  13796. /** @hidden */
  13797. _normals: boolean;
  13798. /** @hidden */
  13799. _uvs: boolean;
  13800. /** @hidden */
  13801. _needNormals: boolean;
  13802. /** @hidden */
  13803. _needUVs: boolean;
  13804. /**
  13805. * Specifies if the material needs to be re-calculated
  13806. */
  13807. readonly isDirty: boolean;
  13808. /**
  13809. * Marks the material to indicate that it has been re-calculated
  13810. */
  13811. markAsProcessed(): void;
  13812. /**
  13813. * Marks the material to indicate that it needs to be re-calculated
  13814. */
  13815. markAsUnprocessed(): void;
  13816. /**
  13817. * Marks the material to indicate all of its defines need to be re-calculated
  13818. */
  13819. markAllAsDirty(): void;
  13820. /**
  13821. * Marks the material to indicate that image processing needs to be re-calculated
  13822. */
  13823. markAsImageProcessingDirty(): void;
  13824. /**
  13825. * Marks the material to indicate the lights need to be re-calculated
  13826. */
  13827. markAsLightDirty(): void;
  13828. /**
  13829. * Marks the attribute state as changed
  13830. */
  13831. markAsAttributesDirty(): void;
  13832. /**
  13833. * Marks the texture state as changed
  13834. */
  13835. markAsTexturesDirty(): void;
  13836. /**
  13837. * Marks the fresnel state as changed
  13838. */
  13839. markAsFresnelDirty(): void;
  13840. /**
  13841. * Marks the misc state as changed
  13842. */
  13843. markAsMiscDirty(): void;
  13844. /**
  13845. * Rebuilds the material defines
  13846. */
  13847. rebuild(): void;
  13848. /**
  13849. * Specifies if two material defines are equal
  13850. * @param other - A material define instance to compare to
  13851. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13852. */
  13853. isEqual(other: MaterialDefines): boolean;
  13854. /**
  13855. * Clones this instance's defines to another instance
  13856. * @param other - material defines to clone values to
  13857. */
  13858. cloneTo(other: MaterialDefines): void;
  13859. /**
  13860. * Resets the material define values
  13861. */
  13862. reset(): void;
  13863. /**
  13864. * Converts the material define values to a string
  13865. * @returns - String of material define information
  13866. */
  13867. toString(): string;
  13868. }
  13869. /**
  13870. * Base class for the main features of a material in Babylon.js
  13871. */
  13872. class Material implements IAnimatable {
  13873. private static _TriangleFillMode;
  13874. private static _WireFrameFillMode;
  13875. private static _PointFillMode;
  13876. private static _PointListDrawMode;
  13877. private static _LineListDrawMode;
  13878. private static _LineLoopDrawMode;
  13879. private static _LineStripDrawMode;
  13880. private static _TriangleStripDrawMode;
  13881. private static _TriangleFanDrawMode;
  13882. /**
  13883. * Returns the triangle fill mode
  13884. */
  13885. static readonly TriangleFillMode: number;
  13886. /**
  13887. * Returns the wireframe mode
  13888. */
  13889. static readonly WireFrameFillMode: number;
  13890. /**
  13891. * Returns the point fill mode
  13892. */
  13893. static readonly PointFillMode: number;
  13894. /**
  13895. * Returns the point list draw mode
  13896. */
  13897. static readonly PointListDrawMode: number;
  13898. /**
  13899. * Returns the line list draw mode
  13900. */
  13901. static readonly LineListDrawMode: number;
  13902. /**
  13903. * Returns the line loop draw mode
  13904. */
  13905. static readonly LineLoopDrawMode: number;
  13906. /**
  13907. * Returns the line strip draw mode
  13908. */
  13909. static readonly LineStripDrawMode: number;
  13910. /**
  13911. * Returns the triangle strip draw mode
  13912. */
  13913. static readonly TriangleStripDrawMode: number;
  13914. /**
  13915. * Returns the triangle fan draw mode
  13916. */
  13917. static readonly TriangleFanDrawMode: number;
  13918. /**
  13919. * Stores the clock-wise side orientation
  13920. */
  13921. private static _ClockWiseSideOrientation;
  13922. /**
  13923. * Stores the counter clock-wise side orientation
  13924. */
  13925. private static _CounterClockWiseSideOrientation;
  13926. /**
  13927. * Returns the clock-wise side orientation
  13928. */
  13929. static readonly ClockWiseSideOrientation: number;
  13930. /**
  13931. * Returns the counter clock-wise side orientation
  13932. */
  13933. static readonly CounterClockWiseSideOrientation: number;
  13934. /**
  13935. * The dirty texture flag value
  13936. */
  13937. private static _TextureDirtyFlag;
  13938. /**
  13939. * The dirty light flag value
  13940. */
  13941. private static _LightDirtyFlag;
  13942. /**
  13943. * The dirty fresnel flag value
  13944. */
  13945. private static _FresnelDirtyFlag;
  13946. /**
  13947. * The dirty attribute flag value
  13948. */
  13949. private static _AttributesDirtyFlag;
  13950. /**
  13951. * The dirty misc flag value
  13952. */
  13953. private static _MiscDirtyFlag;
  13954. /**
  13955. * Returns the dirty texture flag value
  13956. */
  13957. static readonly TextureDirtyFlag: number;
  13958. /**
  13959. * Returns the dirty light flag value
  13960. */
  13961. static readonly LightDirtyFlag: number;
  13962. /**
  13963. * Returns the dirty fresnel flag value
  13964. */
  13965. static readonly FresnelDirtyFlag: number;
  13966. /**
  13967. * Returns the dirty attributes flag value
  13968. */
  13969. static readonly AttributesDirtyFlag: number;
  13970. /**
  13971. * Returns the dirty misc flag value
  13972. */
  13973. static readonly MiscDirtyFlag: number;
  13974. /**
  13975. * The ID of the material
  13976. */
  13977. id: string;
  13978. /**
  13979. * Gets or sets the unique id of the material
  13980. */
  13981. uniqueId: number;
  13982. /**
  13983. * The name of the material
  13984. */
  13985. name: string;
  13986. /**
  13987. * Specifies if the ready state should be checked on each call
  13988. */
  13989. checkReadyOnEveryCall: boolean;
  13990. /**
  13991. * Specifies if the ready state should be checked once
  13992. */
  13993. checkReadyOnlyOnce: boolean;
  13994. /**
  13995. * The state of the material
  13996. */
  13997. state: string;
  13998. /**
  13999. * The alpha value of the material
  14000. */
  14001. protected _alpha: number;
  14002. /**
  14003. * Gets the alpha value of the material
  14004. */
  14005. /**
  14006. * Sets the alpha value of the material
  14007. */
  14008. alpha: number;
  14009. /**
  14010. * Specifies if back face culling is enabled
  14011. */
  14012. protected _backFaceCulling: boolean;
  14013. /**
  14014. * Gets the back-face culling state
  14015. */
  14016. /**
  14017. * Sets the back-face culling state
  14018. */
  14019. backFaceCulling: boolean;
  14020. /**
  14021. * Stores the value for side orientation
  14022. */
  14023. sideOrientation: number;
  14024. /**
  14025. * Callback triggered when the material is compiled
  14026. */
  14027. onCompiled: (effect: Effect) => void;
  14028. /**
  14029. * Callback triggered when an error occurs
  14030. */
  14031. onError: (effect: Effect, errors: string) => void;
  14032. /**
  14033. * Callback triggered to get the render target textures
  14034. */
  14035. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14036. /**
  14037. * Specifies if the material should be serialized
  14038. */
  14039. doNotSerialize: boolean;
  14040. /**
  14041. * Specifies if the effect should be stored on sub meshes
  14042. */
  14043. storeEffectOnSubMeshes: boolean;
  14044. /**
  14045. * Stores the animations for the material
  14046. */
  14047. animations: Array<Animation>;
  14048. /**
  14049. * An event triggered when the material is disposed
  14050. */
  14051. onDisposeObservable: Observable<Material>;
  14052. /**
  14053. * An observer which watches for dispose events
  14054. */
  14055. private _onDisposeObserver;
  14056. /**
  14057. * Called during a dispose event
  14058. */
  14059. onDispose: () => void;
  14060. /**
  14061. * An event triggered when the material is bound
  14062. */
  14063. onBindObservable: Observable<AbstractMesh>;
  14064. /**
  14065. * An observer which watches for bind events
  14066. */
  14067. private _onBindObserver;
  14068. /**
  14069. * Called during a bind event
  14070. */
  14071. onBind: (Mesh: AbstractMesh) => void;
  14072. /**
  14073. * An event triggered when the material is unbound
  14074. */
  14075. onUnBindObservable: Observable<Material>;
  14076. /**
  14077. * Stores the value of the alpha mode
  14078. */
  14079. private _alphaMode;
  14080. /**
  14081. * Gets the value of the alpha mode
  14082. */
  14083. /**
  14084. * Sets the value of the alpha mode.
  14085. *
  14086. * | Value | Type | Description |
  14087. * | --- | --- | --- |
  14088. * | 0 | ALPHA_DISABLE | |
  14089. * | 1 | ALPHA_ADD | |
  14090. * | 2 | ALPHA_COMBINE | |
  14091. * | 3 | ALPHA_SUBTRACT | |
  14092. * | 4 | ALPHA_MULTIPLY | |
  14093. * | 5 | ALPHA_MAXIMIZED | |
  14094. * | 6 | ALPHA_ONEONE | |
  14095. * | 7 | ALPHA_PREMULTIPLIED | |
  14096. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14097. * | 9 | ALPHA_INTERPOLATE | |
  14098. * | 10 | ALPHA_SCREENMODE | |
  14099. *
  14100. */
  14101. alphaMode: number;
  14102. /**
  14103. * Stores the state of the need depth pre-pass value
  14104. */
  14105. private _needDepthPrePass;
  14106. /**
  14107. * Gets the depth pre-pass value
  14108. */
  14109. /**
  14110. * Sets the need depth pre-pass value
  14111. */
  14112. needDepthPrePass: boolean;
  14113. /**
  14114. * Specifies if depth writing should be disabled
  14115. */
  14116. disableDepthWrite: boolean;
  14117. /**
  14118. * Specifies if depth writing should be forced
  14119. */
  14120. forceDepthWrite: boolean;
  14121. /**
  14122. * Specifies if there should be a separate pass for culling
  14123. */
  14124. separateCullingPass: boolean;
  14125. /**
  14126. * Stores the state specifing if fog should be enabled
  14127. */
  14128. private _fogEnabled;
  14129. /**
  14130. * Gets the value of the fog enabled state
  14131. */
  14132. /**
  14133. * Sets the state for enabling fog
  14134. */
  14135. fogEnabled: boolean;
  14136. /**
  14137. * Stores the size of points
  14138. */
  14139. pointSize: number;
  14140. /**
  14141. * Stores the z offset value
  14142. */
  14143. zOffset: number;
  14144. /**
  14145. * Gets a value specifying if wireframe mode is enabled
  14146. */
  14147. /**
  14148. * Sets the state of wireframe mode
  14149. */
  14150. wireframe: boolean;
  14151. /**
  14152. * Gets the value specifying if point clouds are enabled
  14153. */
  14154. /**
  14155. * Sets the state of point cloud mode
  14156. */
  14157. pointsCloud: boolean;
  14158. /**
  14159. * Gets the material fill mode
  14160. */
  14161. /**
  14162. * Sets the material fill mode
  14163. */
  14164. fillMode: number;
  14165. /**
  14166. * Stores the effects for the material
  14167. */
  14168. _effect: Nullable<Effect>;
  14169. /**
  14170. * Specifies if the material was previously ready
  14171. */
  14172. _wasPreviouslyReady: boolean;
  14173. /**
  14174. * Specifies if uniform buffers should be used
  14175. */
  14176. private _useUBO;
  14177. /**
  14178. * Stores a reference to the scene
  14179. */
  14180. private _scene;
  14181. /**
  14182. * Stores the fill mode state
  14183. */
  14184. private _fillMode;
  14185. /**
  14186. * Specifies if the depth write state should be cached
  14187. */
  14188. private _cachedDepthWriteState;
  14189. /**
  14190. * Stores the uniform buffer
  14191. */
  14192. protected _uniformBuffer: UniformBuffer;
  14193. /**
  14194. * Creates a material instance
  14195. * @param name defines the name of the material
  14196. * @param scene defines the scene to reference
  14197. * @param doNotAdd specifies if the material should be added to the scene
  14198. */
  14199. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14200. /**
  14201. * Returns a string representation of the current material
  14202. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14203. * @returns a string with material information
  14204. */
  14205. toString(fullDetails?: boolean): string;
  14206. /**
  14207. * Gets the class name of the material
  14208. * @returns a string with the class name of the material
  14209. */
  14210. getClassName(): string;
  14211. /**
  14212. * Specifies if updates for the material been locked
  14213. */
  14214. readonly isFrozen: boolean;
  14215. /**
  14216. * Locks updates for the material
  14217. */
  14218. freeze(): void;
  14219. /**
  14220. * Unlocks updates for the material
  14221. */
  14222. unfreeze(): void;
  14223. /**
  14224. * Specifies if the material is ready to be used
  14225. * @param mesh defines the mesh to check
  14226. * @param useInstances specifies if instances should be used
  14227. * @returns a boolean indicating if the material is ready to be used
  14228. */
  14229. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14230. /**
  14231. * Specifies that the submesh is ready to be used
  14232. * @param mesh defines the mesh to check
  14233. * @param subMesh defines which submesh to check
  14234. * @param useInstances specifies that instances should be used
  14235. * @returns a boolean indicating that the submesh is ready or not
  14236. */
  14237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14238. /**
  14239. * Returns the material effect
  14240. * @returns the effect associated with the material
  14241. */
  14242. getEffect(): Nullable<Effect>;
  14243. /**
  14244. * Returns the current scene
  14245. * @returns a Scene
  14246. */
  14247. getScene(): Scene;
  14248. /**
  14249. * Specifies if the material will require alpha blending
  14250. * @returns a boolean specifying if alpha blending is needed
  14251. */
  14252. needAlphaBlending(): boolean;
  14253. /**
  14254. * Specifies if the mesh will require alpha blending
  14255. * @param mesh defines the mesh to check
  14256. * @returns a boolean specifying if alpha blending is needed for the mesh
  14257. */
  14258. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14259. /**
  14260. * Specifies if this material should be rendered in alpha test mode
  14261. * @returns a boolean specifying if an alpha test is needed.
  14262. */
  14263. needAlphaTesting(): boolean;
  14264. /**
  14265. * Gets the texture used for the alpha test
  14266. * @returns the texture to use for alpha testing
  14267. */
  14268. getAlphaTestTexture(): Nullable<BaseTexture>;
  14269. /**
  14270. * Marks the material to indicate that it needs to be re-calculated
  14271. */
  14272. markDirty(): void;
  14273. /** @hidden */
  14274. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14275. /**
  14276. * Binds the material to the mesh
  14277. * @param world defines the world transformation matrix
  14278. * @param mesh defines the mesh to bind the material to
  14279. */
  14280. bind(world: Matrix, mesh?: Mesh): void;
  14281. /**
  14282. * Binds the submesh to the material
  14283. * @param world defines the world transformation matrix
  14284. * @param mesh defines the mesh containing the submesh
  14285. * @param subMesh defines the submesh to bind the material to
  14286. */
  14287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14288. /**
  14289. * Binds the world matrix to the material
  14290. * @param world defines the world transformation matrix
  14291. */
  14292. bindOnlyWorldMatrix(world: Matrix): void;
  14293. /**
  14294. * Binds the scene's uniform buffer to the effect.
  14295. * @param effect defines the effect to bind to the scene uniform buffer
  14296. * @param sceneUbo defines the uniform buffer storing scene data
  14297. */
  14298. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14299. /**
  14300. * Binds the view matrix to the effect
  14301. * @param effect defines the effect to bind the view matrix to
  14302. */
  14303. bindView(effect: Effect): void;
  14304. /**
  14305. * Binds the view projection matrix to the effect
  14306. * @param effect defines the effect to bind the view projection matrix to
  14307. */
  14308. bindViewProjection(effect: Effect): void;
  14309. /**
  14310. * Specifies if material alpha testing should be turned on for the mesh
  14311. * @param mesh defines the mesh to check
  14312. */
  14313. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14314. /**
  14315. * Processes to execute after binding the material to a mesh
  14316. * @param mesh defines the rendered mesh
  14317. */
  14318. protected _afterBind(mesh?: Mesh): void;
  14319. /**
  14320. * Unbinds the material from the mesh
  14321. */
  14322. unbind(): void;
  14323. /**
  14324. * Gets the active textures from the material
  14325. * @returns an array of textures
  14326. */
  14327. getActiveTextures(): BaseTexture[];
  14328. /**
  14329. * Specifies if the material uses a texture
  14330. * @param texture defines the texture to check against the material
  14331. * @returns a boolean specifying if the material uses the texture
  14332. */
  14333. hasTexture(texture: BaseTexture): boolean;
  14334. /**
  14335. * Makes a duplicate of the material, and gives it a new name
  14336. * @param name defines the new name for the duplicated material
  14337. * @returns the cloned material
  14338. */
  14339. clone(name: string): Nullable<Material>;
  14340. /**
  14341. * Gets the meshes bound to the material
  14342. * @returns an array of meshes bound to the material
  14343. */
  14344. getBindedMeshes(): AbstractMesh[];
  14345. /**
  14346. * Force shader compilation
  14347. * @param mesh defines the mesh associated with this material
  14348. * @param onCompiled defines a function to execute once the material is compiled
  14349. * @param options defines the options to configure the compilation
  14350. */
  14351. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14352. clipPlane: boolean;
  14353. }>): void;
  14354. /**
  14355. * Force shader compilation
  14356. * @param mesh defines the mesh that will use this material
  14357. * @param options defines additional options for compiling the shaders
  14358. * @returns a promise that resolves when the compilation completes
  14359. */
  14360. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14361. clipPlane: boolean;
  14362. }>): Promise<void>;
  14363. /**
  14364. * Marks a define in the material to indicate that it needs to be re-computed
  14365. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14366. */
  14367. markAsDirty(flag: number): void;
  14368. /**
  14369. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14370. * @param func defines a function which checks material defines against the submeshes
  14371. */
  14372. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14373. /**
  14374. * Indicates that image processing needs to be re-calculated for all submeshes
  14375. */
  14376. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14377. /**
  14378. * Indicates that textures need to be re-calculated for all submeshes
  14379. */
  14380. protected _markAllSubMeshesAsTexturesDirty(): void;
  14381. /**
  14382. * Indicates that fresnel needs to be re-calculated for all submeshes
  14383. */
  14384. protected _markAllSubMeshesAsFresnelDirty(): void;
  14385. /**
  14386. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14387. */
  14388. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14389. /**
  14390. * Indicates that lights need to be re-calculated for all submeshes
  14391. */
  14392. protected _markAllSubMeshesAsLightsDirty(): void;
  14393. /**
  14394. * Indicates that attributes need to be re-calculated for all submeshes
  14395. */
  14396. protected _markAllSubMeshesAsAttributesDirty(): void;
  14397. /**
  14398. * Indicates that misc needs to be re-calculated for all submeshes
  14399. */
  14400. protected _markAllSubMeshesAsMiscDirty(): void;
  14401. /**
  14402. * Indicates that textures and misc need to be re-calculated for all submeshes
  14403. */
  14404. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14405. /**
  14406. * Disposes the material
  14407. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14408. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14409. */
  14410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14411. /**
  14412. * Serializes this material
  14413. * @returns the serialized material object
  14414. */
  14415. serialize(): any;
  14416. /**
  14417. * Creates a MultiMaterial from parsed MultiMaterial data.
  14418. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14419. * @param scene defines the hosting scene
  14420. * @returns a new MultiMaterial
  14421. */
  14422. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14423. /**
  14424. * Creates a material from parsed material data
  14425. * @param parsedMaterial defines parsed material data
  14426. * @param scene defines the hosting scene
  14427. * @param rootUrl defines the root URL to use to load textures
  14428. * @returns a new material
  14429. */
  14430. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14431. }
  14432. }
  14433. declare module BABYLON {
  14434. /**
  14435. * "Static Class" containing the most commonly used helper while dealing with material for
  14436. * rendering purpose.
  14437. *
  14438. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14439. *
  14440. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14441. */
  14442. class MaterialHelper {
  14443. /**
  14444. * Bind the current view position to an effect.
  14445. * @param effect The effect to be bound
  14446. * @param scene The scene the eyes position is used from
  14447. */
  14448. static BindEyePosition(effect: Effect, scene: Scene): void;
  14449. /**
  14450. * Helps preparing the defines values about the UVs in used in the effect.
  14451. * UVs are shared as much as we can accross chanels in the shaders.
  14452. * @param texture The texture we are preparing the UVs for
  14453. * @param defines The defines to update
  14454. * @param key The chanel key "diffuse", "specular"... used in the shader
  14455. */
  14456. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14457. /**
  14458. * Binds a texture matrix value to its corrsponding uniform
  14459. * @param texture The texture to bind the matrix for
  14460. * @param uniformBuffer The uniform buffer receivin the data
  14461. * @param key The chanel key "diffuse", "specular"... used in the shader
  14462. */
  14463. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14464. /**
  14465. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14466. * @param mesh defines the current mesh
  14467. * @param scene defines the current scene
  14468. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14469. * @param pointsCloud defines if point cloud rendering has to be turned on
  14470. * @param fogEnabled defines if fog has to be turned on
  14471. * @param alphaTest defines if alpha testing has to be turned on
  14472. * @param defines defines the current list of defines
  14473. */
  14474. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14475. /**
  14476. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14477. * @param scene defines the current scene
  14478. * @param engine defines the current engine
  14479. * @param defines specifies the list of active defines
  14480. * @param useInstances defines if instances have to be turned on
  14481. * @param useClipPlane defines if clip plane have to be turned on
  14482. */
  14483. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14484. /**
  14485. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14486. * @param mesh The mesh containing the geometry data we will draw
  14487. * @param defines The defines to update
  14488. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14489. * @param useBones Precise whether bones should be used or not (override mesh info)
  14490. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14491. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14492. * @returns false if defines are considered not dirty and have not been checked
  14493. */
  14494. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14495. /**
  14496. * Prepares the defines related to the light information passed in parameter
  14497. * @param scene The scene we are intending to draw
  14498. * @param mesh The mesh the effect is compiling for
  14499. * @param defines The defines to update
  14500. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14501. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14502. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14503. * @returns true if normals will be required for the rest of the effect
  14504. */
  14505. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14506. /**
  14507. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14508. * that won t be acctive due to defines being turned off.
  14509. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14510. * @param samplersList The samplers list
  14511. * @param defines The defines helping in the list generation
  14512. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14513. */
  14514. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14515. /**
  14516. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14517. * @param defines The defines to update while falling back
  14518. * @param fallbacks The authorized effect fallbacks
  14519. * @param maxSimultaneousLights The maximum number of lights allowed
  14520. * @param rank the current rank of the Effect
  14521. * @returns The newly affected rank
  14522. */
  14523. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14524. /**
  14525. * Prepares the list of attributes required for morph targets according to the effect defines.
  14526. * @param attribs The current list of supported attribs
  14527. * @param mesh The mesh to prepare the morph targets attributes for
  14528. * @param defines The current Defines of the effect
  14529. */
  14530. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14531. /**
  14532. * Prepares the list of attributes required for bones according to the effect defines.
  14533. * @param attribs The current list of supported attribs
  14534. * @param mesh The mesh to prepare the bones attributes for
  14535. * @param defines The current Defines of the effect
  14536. * @param fallbacks The current efffect fallback strategy
  14537. */
  14538. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14539. /**
  14540. * Prepares the list of attributes required for instances according to the effect defines.
  14541. * @param attribs The current list of supported attribs
  14542. * @param defines The current Defines of the effect
  14543. */
  14544. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14545. /**
  14546. * Binds the light shadow information to the effect for the given mesh.
  14547. * @param light The light containing the generator
  14548. * @param scene The scene the lights belongs to
  14549. * @param mesh The mesh we are binding the information to render
  14550. * @param lightIndex The light index in the effect used to render the mesh
  14551. * @param effect The effect we are binding the data to
  14552. */
  14553. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14554. /**
  14555. * Binds the light information to the effect.
  14556. * @param light The light containing the generator
  14557. * @param effect The effect we are binding the data to
  14558. * @param lightIndex The light index in the effect used to render
  14559. */
  14560. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14561. /**
  14562. * Binds the lights information from the scene to the effect for the given mesh.
  14563. * @param scene The scene the lights belongs to
  14564. * @param mesh The mesh we are binding the information to render
  14565. * @param effect The effect we are binding the data to
  14566. * @param defines The generated defines for the effect
  14567. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14568. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14569. */
  14570. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14571. /**
  14572. * Binds the fog information from the scene to the effect for the given mesh.
  14573. * @param scene The scene the lights belongs to
  14574. * @param mesh The mesh we are binding the information to render
  14575. * @param effect The effect we are binding the data to
  14576. */
  14577. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14578. /**
  14579. * Binds the bones information from the mesh to the effect.
  14580. * @param mesh The mesh we are binding the information to render
  14581. * @param effect The effect we are binding the data to
  14582. */
  14583. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14584. /**
  14585. * Binds the morph targets information from the mesh to the effect.
  14586. * @param abstractMesh The mesh we are binding the information to render
  14587. * @param effect The effect we are binding the data to
  14588. */
  14589. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14590. /**
  14591. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14592. * @param defines The generated defines used in the effect
  14593. * @param effect The effect we are binding the data to
  14594. * @param scene The scene we are willing to render with logarithmic scale for
  14595. */
  14596. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14597. /**
  14598. * Binds the clip plane information from the scene to the effect.
  14599. * @param scene The scene the clip plane information are extracted from
  14600. * @param effect The effect we are binding the data to
  14601. */
  14602. static BindClipPlane(effect: Effect, scene: Scene): void;
  14603. }
  14604. }
  14605. declare module BABYLON {
  14606. class MultiMaterial extends Material {
  14607. private _subMaterials;
  14608. subMaterials: Nullable<Material>[];
  14609. constructor(name: string, scene: Scene);
  14610. private _hookArray(array);
  14611. getSubMaterial(index: number): Nullable<Material>;
  14612. getActiveTextures(): BaseTexture[];
  14613. getClassName(): string;
  14614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14615. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14616. serialize(): any;
  14617. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14618. }
  14619. }
  14620. declare module BABYLON {
  14621. class PushMaterial extends Material {
  14622. protected _activeEffect: Effect;
  14623. protected _normalMatrix: Matrix;
  14624. constructor(name: string, scene: Scene);
  14625. getEffect(): Effect;
  14626. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14627. /**
  14628. * Binds the given world matrix to the active effect
  14629. *
  14630. * @param world the matrix to bind
  14631. */
  14632. bindOnlyWorldMatrix(world: Matrix): void;
  14633. /**
  14634. * Binds the given normal matrix to the active effect
  14635. *
  14636. * @param normalMatrix the matrix to bind
  14637. */
  14638. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14639. bind(world: Matrix, mesh?: Mesh): void;
  14640. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14641. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14642. }
  14643. }
  14644. declare module BABYLON {
  14645. class ShaderMaterial extends Material {
  14646. private _shaderPath;
  14647. private _options;
  14648. private _textures;
  14649. private _textureArrays;
  14650. private _floats;
  14651. private _ints;
  14652. private _floatsArrays;
  14653. private _colors3;
  14654. private _colors3Arrays;
  14655. private _colors4;
  14656. private _vectors2;
  14657. private _vectors3;
  14658. private _vectors4;
  14659. private _matrices;
  14660. private _matrices3x3;
  14661. private _matrices2x2;
  14662. private _vectors2Arrays;
  14663. private _vectors3Arrays;
  14664. private _cachedWorldViewMatrix;
  14665. private _renderId;
  14666. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14667. getClassName(): string;
  14668. needAlphaBlending(): boolean;
  14669. needAlphaTesting(): boolean;
  14670. private _checkUniform(uniformName);
  14671. setTexture(name: string, texture: Texture): ShaderMaterial;
  14672. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14673. setFloat(name: string, value: number): ShaderMaterial;
  14674. setInt(name: string, value: number): ShaderMaterial;
  14675. setFloats(name: string, value: number[]): ShaderMaterial;
  14676. setColor3(name: string, value: Color3): ShaderMaterial;
  14677. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14678. setColor4(name: string, value: Color4): ShaderMaterial;
  14679. setVector2(name: string, value: Vector2): ShaderMaterial;
  14680. setVector3(name: string, value: Vector3): ShaderMaterial;
  14681. setVector4(name: string, value: Vector4): ShaderMaterial;
  14682. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14683. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14684. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14685. setArray2(name: string, value: number[]): ShaderMaterial;
  14686. setArray3(name: string, value: number[]): ShaderMaterial;
  14687. private _checkCache(scene, mesh?, useInstances?);
  14688. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14689. bindOnlyWorldMatrix(world: Matrix): void;
  14690. bind(world: Matrix, mesh?: Mesh): void;
  14691. getActiveTextures(): BaseTexture[];
  14692. hasTexture(texture: BaseTexture): boolean;
  14693. clone(name: string): ShaderMaterial;
  14694. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14695. serialize(): any;
  14696. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14697. }
  14698. }
  14699. declare module BABYLON {
  14700. /** @hidden */
  14701. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14702. MAINUV1: boolean;
  14703. MAINUV2: boolean;
  14704. DIFFUSE: boolean;
  14705. DIFFUSEDIRECTUV: number;
  14706. AMBIENT: boolean;
  14707. AMBIENTDIRECTUV: number;
  14708. OPACITY: boolean;
  14709. OPACITYDIRECTUV: number;
  14710. OPACITYRGB: boolean;
  14711. REFLECTION: boolean;
  14712. EMISSIVE: boolean;
  14713. EMISSIVEDIRECTUV: number;
  14714. SPECULAR: boolean;
  14715. SPECULARDIRECTUV: number;
  14716. BUMP: boolean;
  14717. BUMPDIRECTUV: number;
  14718. PARALLAX: boolean;
  14719. PARALLAXOCCLUSION: boolean;
  14720. SPECULAROVERALPHA: boolean;
  14721. CLIPPLANE: boolean;
  14722. ALPHATEST: boolean;
  14723. DEPTHPREPASS: boolean;
  14724. ALPHAFROMDIFFUSE: boolean;
  14725. POINTSIZE: boolean;
  14726. FOG: boolean;
  14727. SPECULARTERM: boolean;
  14728. DIFFUSEFRESNEL: boolean;
  14729. OPACITYFRESNEL: boolean;
  14730. REFLECTIONFRESNEL: boolean;
  14731. REFRACTIONFRESNEL: boolean;
  14732. EMISSIVEFRESNEL: boolean;
  14733. FRESNEL: boolean;
  14734. NORMAL: boolean;
  14735. UV1: boolean;
  14736. UV2: boolean;
  14737. VERTEXCOLOR: boolean;
  14738. VERTEXALPHA: boolean;
  14739. NUM_BONE_INFLUENCERS: number;
  14740. BonesPerMesh: number;
  14741. INSTANCES: boolean;
  14742. GLOSSINESS: boolean;
  14743. ROUGHNESS: boolean;
  14744. EMISSIVEASILLUMINATION: boolean;
  14745. LINKEMISSIVEWITHDIFFUSE: boolean;
  14746. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14747. LIGHTMAP: boolean;
  14748. LIGHTMAPDIRECTUV: number;
  14749. OBJECTSPACE_NORMALMAP: boolean;
  14750. USELIGHTMAPASSHADOWMAP: boolean;
  14751. REFLECTIONMAP_3D: boolean;
  14752. REFLECTIONMAP_SPHERICAL: boolean;
  14753. REFLECTIONMAP_PLANAR: boolean;
  14754. REFLECTIONMAP_CUBIC: boolean;
  14755. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14756. REFLECTIONMAP_PROJECTION: boolean;
  14757. REFLECTIONMAP_SKYBOX: boolean;
  14758. REFLECTIONMAP_EXPLICIT: boolean;
  14759. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14760. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14761. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14762. INVERTCUBICMAP: boolean;
  14763. LOGARITHMICDEPTH: boolean;
  14764. REFRACTION: boolean;
  14765. REFRACTIONMAP_3D: boolean;
  14766. REFLECTIONOVERALPHA: boolean;
  14767. TWOSIDEDLIGHTING: boolean;
  14768. SHADOWFLOAT: boolean;
  14769. MORPHTARGETS: boolean;
  14770. MORPHTARGETS_NORMAL: boolean;
  14771. MORPHTARGETS_TANGENT: boolean;
  14772. NUM_MORPH_INFLUENCERS: number;
  14773. NONUNIFORMSCALING: boolean;
  14774. PREMULTIPLYALPHA: boolean;
  14775. IMAGEPROCESSING: boolean;
  14776. VIGNETTE: boolean;
  14777. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14778. VIGNETTEBLENDMODEOPAQUE: boolean;
  14779. TONEMAPPING: boolean;
  14780. CONTRAST: boolean;
  14781. COLORCURVES: boolean;
  14782. COLORGRADING: boolean;
  14783. COLORGRADING3D: boolean;
  14784. SAMPLER3DGREENDEPTH: boolean;
  14785. SAMPLER3DBGRMAP: boolean;
  14786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14787. /**
  14788. * If the reflection texture on this material is in linear color space
  14789. * @hidden
  14790. */
  14791. IS_REFLECTION_LINEAR: boolean;
  14792. /**
  14793. * If the refraction texture on this material is in linear color space
  14794. * @hidden
  14795. */
  14796. IS_REFRACTION_LINEAR: boolean;
  14797. EXPOSURE: boolean;
  14798. constructor();
  14799. setReflectionMode(modeToEnable: string): void;
  14800. }
  14801. class StandardMaterial extends PushMaterial {
  14802. private _diffuseTexture;
  14803. diffuseTexture: Nullable<BaseTexture>;
  14804. private _ambientTexture;
  14805. ambientTexture: Nullable<BaseTexture>;
  14806. private _opacityTexture;
  14807. opacityTexture: Nullable<BaseTexture>;
  14808. private _reflectionTexture;
  14809. reflectionTexture: Nullable<BaseTexture>;
  14810. private _emissiveTexture;
  14811. emissiveTexture: Nullable<BaseTexture>;
  14812. private _specularTexture;
  14813. specularTexture: Nullable<BaseTexture>;
  14814. private _bumpTexture;
  14815. bumpTexture: Nullable<BaseTexture>;
  14816. private _lightmapTexture;
  14817. lightmapTexture: Nullable<BaseTexture>;
  14818. private _refractionTexture;
  14819. refractionTexture: Nullable<BaseTexture>;
  14820. ambientColor: Color3;
  14821. diffuseColor: Color3;
  14822. specularColor: Color3;
  14823. emissiveColor: Color3;
  14824. specularPower: number;
  14825. private _useAlphaFromDiffuseTexture;
  14826. useAlphaFromDiffuseTexture: boolean;
  14827. private _useEmissiveAsIllumination;
  14828. useEmissiveAsIllumination: boolean;
  14829. private _linkEmissiveWithDiffuse;
  14830. linkEmissiveWithDiffuse: boolean;
  14831. private _useSpecularOverAlpha;
  14832. useSpecularOverAlpha: boolean;
  14833. private _useReflectionOverAlpha;
  14834. useReflectionOverAlpha: boolean;
  14835. private _disableLighting;
  14836. disableLighting: boolean;
  14837. private _useObjectSpaceNormalMap;
  14838. /**
  14839. * Allows using an object space normal map (instead of tangent space).
  14840. */
  14841. useObjectSpaceNormalMap: boolean;
  14842. private _useParallax;
  14843. useParallax: boolean;
  14844. private _useParallaxOcclusion;
  14845. useParallaxOcclusion: boolean;
  14846. parallaxScaleBias: number;
  14847. private _roughness;
  14848. roughness: number;
  14849. indexOfRefraction: number;
  14850. invertRefractionY: boolean;
  14851. /**
  14852. * Defines the alpha limits in alpha test mode
  14853. */
  14854. alphaCutOff: number;
  14855. private _useLightmapAsShadowmap;
  14856. useLightmapAsShadowmap: boolean;
  14857. private _diffuseFresnelParameters;
  14858. diffuseFresnelParameters: FresnelParameters;
  14859. private _opacityFresnelParameters;
  14860. opacityFresnelParameters: FresnelParameters;
  14861. private _reflectionFresnelParameters;
  14862. reflectionFresnelParameters: FresnelParameters;
  14863. private _refractionFresnelParameters;
  14864. refractionFresnelParameters: FresnelParameters;
  14865. private _emissiveFresnelParameters;
  14866. emissiveFresnelParameters: FresnelParameters;
  14867. private _useReflectionFresnelFromSpecular;
  14868. useReflectionFresnelFromSpecular: boolean;
  14869. private _useGlossinessFromSpecularMapAlpha;
  14870. useGlossinessFromSpecularMapAlpha: boolean;
  14871. private _maxSimultaneousLights;
  14872. maxSimultaneousLights: number;
  14873. /**
  14874. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14875. */
  14876. private _invertNormalMapX;
  14877. invertNormalMapX: boolean;
  14878. /**
  14879. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14880. */
  14881. private _invertNormalMapY;
  14882. invertNormalMapY: boolean;
  14883. /**
  14884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14885. */
  14886. private _twoSidedLighting;
  14887. twoSidedLighting: boolean;
  14888. /**
  14889. * Default configuration related to image processing available in the standard Material.
  14890. */
  14891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14892. /**
  14893. * Gets the image processing configuration used either in this material.
  14894. */
  14895. /**
  14896. * Sets the Default image processing configuration used either in the this material.
  14897. *
  14898. * If sets to null, the scene one is in use.
  14899. */
  14900. imageProcessingConfiguration: ImageProcessingConfiguration;
  14901. /**
  14902. * Keep track of the image processing observer to allow dispose and replace.
  14903. */
  14904. private _imageProcessingObserver;
  14905. /**
  14906. * Attaches a new image processing configuration to the Standard Material.
  14907. * @param configuration
  14908. */
  14909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14910. /**
  14911. * Gets wether the color curves effect is enabled.
  14912. */
  14913. /**
  14914. * Sets wether the color curves effect is enabled.
  14915. */
  14916. cameraColorCurvesEnabled: boolean;
  14917. /**
  14918. * Gets wether the color grading effect is enabled.
  14919. */
  14920. /**
  14921. * Gets wether the color grading effect is enabled.
  14922. */
  14923. cameraColorGradingEnabled: boolean;
  14924. /**
  14925. * Gets wether tonemapping is enabled or not.
  14926. */
  14927. /**
  14928. * Sets wether tonemapping is enabled or not
  14929. */
  14930. cameraToneMappingEnabled: boolean;
  14931. /**
  14932. * The camera exposure used on this material.
  14933. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14934. * This corresponds to a photographic exposure.
  14935. */
  14936. /**
  14937. * The camera exposure used on this material.
  14938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14939. * This corresponds to a photographic exposure.
  14940. */
  14941. cameraExposure: number;
  14942. /**
  14943. * Gets The camera contrast used on this material.
  14944. */
  14945. /**
  14946. * Sets The camera contrast used on this material.
  14947. */
  14948. cameraContrast: number;
  14949. /**
  14950. * Gets the Color Grading 2D Lookup Texture.
  14951. */
  14952. /**
  14953. * Sets the Color Grading 2D Lookup Texture.
  14954. */
  14955. cameraColorGradingTexture: Nullable<BaseTexture>;
  14956. /**
  14957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14959. * 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;
  14960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14961. */
  14962. /**
  14963. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14964. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14965. * 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;
  14966. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14967. */
  14968. cameraColorCurves: Nullable<ColorCurves>;
  14969. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14970. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14971. protected _worldViewProjectionMatrix: Matrix;
  14972. protected _globalAmbientColor: Color3;
  14973. protected _useLogarithmicDepth: boolean;
  14974. constructor(name: string, scene: Scene);
  14975. getClassName(): string;
  14976. useLogarithmicDepth: boolean;
  14977. needAlphaBlending(): boolean;
  14978. needAlphaTesting(): boolean;
  14979. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14980. getAlphaTestTexture(): Nullable<BaseTexture>;
  14981. /**
  14982. * Child classes can use it to update shaders
  14983. */
  14984. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14985. buildUniformLayout(): void;
  14986. unbind(): void;
  14987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14988. getAnimatables(): IAnimatable[];
  14989. getActiveTextures(): BaseTexture[];
  14990. hasTexture(texture: BaseTexture): boolean;
  14991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14992. clone(name: string): StandardMaterial;
  14993. serialize(): any;
  14994. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14995. static _DiffuseTextureEnabled: boolean;
  14996. static DiffuseTextureEnabled: boolean;
  14997. static _AmbientTextureEnabled: boolean;
  14998. static AmbientTextureEnabled: boolean;
  14999. static _OpacityTextureEnabled: boolean;
  15000. static OpacityTextureEnabled: boolean;
  15001. static _ReflectionTextureEnabled: boolean;
  15002. static ReflectionTextureEnabled: boolean;
  15003. static _EmissiveTextureEnabled: boolean;
  15004. static EmissiveTextureEnabled: boolean;
  15005. static _SpecularTextureEnabled: boolean;
  15006. static SpecularTextureEnabled: boolean;
  15007. static _BumpTextureEnabled: boolean;
  15008. static BumpTextureEnabled: boolean;
  15009. static _LightmapTextureEnabled: boolean;
  15010. static LightmapTextureEnabled: boolean;
  15011. static _RefractionTextureEnabled: boolean;
  15012. static RefractionTextureEnabled: boolean;
  15013. static _ColorGradingTextureEnabled: boolean;
  15014. static ColorGradingTextureEnabled: boolean;
  15015. static _FresnelEnabled: boolean;
  15016. static FresnelEnabled: boolean;
  15017. }
  15018. }
  15019. declare module BABYLON {
  15020. class UniformBuffer {
  15021. private _engine;
  15022. private _buffer;
  15023. private _data;
  15024. private _bufferData;
  15025. private _dynamic?;
  15026. private _uniformLocations;
  15027. private _uniformSizes;
  15028. private _uniformLocationPointer;
  15029. private _needSync;
  15030. private _noUBO;
  15031. private _currentEffect;
  15032. private static _MAX_UNIFORM_SIZE;
  15033. private static _tempBuffer;
  15034. /**
  15035. * Wrapper for updateUniform.
  15036. * @method updateMatrix3x3
  15037. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15038. * @param {Float32Array} matrix
  15039. */
  15040. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15041. /**
  15042. * Wrapper for updateUniform.
  15043. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15044. * @param {Float32Array} matrix
  15045. */
  15046. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15047. /**
  15048. * Wrapper for updateUniform.
  15049. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15050. * @param {number} x
  15051. */
  15052. updateFloat: (name: string, x: number) => void;
  15053. /**
  15054. * Wrapper for updateUniform.
  15055. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15056. * @param {number} x
  15057. * @param {number} y
  15058. * @param {string} [suffix] Suffix to add to the uniform name.
  15059. */
  15060. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15061. /**
  15062. * Wrapper for updateUniform.
  15063. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15064. * @param {number} x
  15065. * @param {number} y
  15066. * @param {number} z
  15067. * @param {string} [suffix] Suffix to add to the uniform name.
  15068. */
  15069. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15070. /**
  15071. * Wrapper for updateUniform.
  15072. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15073. * @param {number} x
  15074. * @param {number} y
  15075. * @param {number} z
  15076. * @param {number} w
  15077. * @param {string} [suffix] Suffix to add to the uniform name.
  15078. */
  15079. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15080. /**
  15081. * Wrapper for updateUniform.
  15082. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15083. * @param {Matrix} A 4x4 matrix.
  15084. */
  15085. updateMatrix: (name: string, mat: Matrix) => void;
  15086. /**
  15087. * Wrapper for updateUniform.
  15088. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15089. * @param {Vector3} vector
  15090. */
  15091. updateVector3: (name: string, vector: Vector3) => void;
  15092. /**
  15093. * Wrapper for updateUniform.
  15094. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15095. * @param {Vector4} vector
  15096. */
  15097. updateVector4: (name: string, vector: Vector4) => void;
  15098. /**
  15099. * Wrapper for updateUniform.
  15100. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15101. * @param {Color3} color
  15102. * @param {string} [suffix] Suffix to add to the uniform name.
  15103. */
  15104. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15105. /**
  15106. * Wrapper for updateUniform.
  15107. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15108. * @param {Color3} color
  15109. * @param {number} alpha
  15110. * @param {string} [suffix] Suffix to add to the uniform name.
  15111. */
  15112. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15113. /**
  15114. * Uniform buffer objects.
  15115. *
  15116. * Handles blocks of uniform on the GPU.
  15117. *
  15118. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15119. *
  15120. * For more information, please refer to :
  15121. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15122. */
  15123. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15124. /**
  15125. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15126. * or just falling back on setUniformXXX calls.
  15127. */
  15128. readonly useUbo: boolean;
  15129. /**
  15130. * Indicates if the WebGL underlying uniform buffer is in sync
  15131. * with the javascript cache data.
  15132. */
  15133. readonly isSync: boolean;
  15134. /**
  15135. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15136. * Also, a dynamic UniformBuffer will disable cache verification and always
  15137. * update the underlying WebGL uniform buffer to the GPU.
  15138. */
  15139. isDynamic(): boolean;
  15140. /**
  15141. * The data cache on JS side.
  15142. */
  15143. getData(): Float32Array;
  15144. /**
  15145. * The underlying WebGL Uniform buffer.
  15146. */
  15147. getBuffer(): Nullable<WebGLBuffer>;
  15148. /**
  15149. * std140 layout specifies how to align data within an UBO structure.
  15150. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15151. * for specs.
  15152. */
  15153. private _fillAlignment(size);
  15154. /**
  15155. * Adds an uniform in the buffer.
  15156. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15157. * for the layout to be correct !
  15158. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15159. * @param {number|number[]} size Data size, or data directly.
  15160. */
  15161. addUniform(name: string, size: number | number[]): void;
  15162. /**
  15163. * Wrapper for addUniform.
  15164. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15165. * @param {Matrix} mat A 4x4 matrix.
  15166. */
  15167. addMatrix(name: string, mat: Matrix): void;
  15168. /**
  15169. * Wrapper for addUniform.
  15170. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15171. * @param {number} x
  15172. * @param {number} y
  15173. */
  15174. addFloat2(name: string, x: number, y: number): void;
  15175. /**
  15176. * Wrapper for addUniform.
  15177. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15178. * @param {number} x
  15179. * @param {number} y
  15180. * @param {number} z
  15181. */
  15182. addFloat3(name: string, x: number, y: number, z: number): void;
  15183. /**
  15184. * Wrapper for addUniform.
  15185. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15186. * @param {Color3} color
  15187. */
  15188. addColor3(name: string, color: Color3): void;
  15189. /**
  15190. * Wrapper for addUniform.
  15191. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15192. * @param {Color3} color
  15193. * @param {number} alpha
  15194. */
  15195. addColor4(name: string, color: Color3, alpha: number): void;
  15196. /**
  15197. * Wrapper for addUniform.
  15198. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15199. * @param {Vector3} vector
  15200. */
  15201. addVector3(name: string, vector: Vector3): void;
  15202. /**
  15203. * Wrapper for addUniform.
  15204. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15205. */
  15206. addMatrix3x3(name: string): void;
  15207. /**
  15208. * Wrapper for addUniform.
  15209. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15210. */
  15211. addMatrix2x2(name: string): void;
  15212. /**
  15213. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15214. */
  15215. create(): void;
  15216. _rebuild(): void;
  15217. /**
  15218. * Updates the WebGL Uniform Buffer on the GPU.
  15219. * If the `dynamic` flag is set to true, no cache comparison is done.
  15220. * Otherwise, the buffer will be updated only if the cache differs.
  15221. */
  15222. update(): void;
  15223. /**
  15224. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15225. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15226. * @param {number[]|Float32Array} data Flattened data
  15227. * @param {number} size Size of the data.
  15228. */
  15229. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15230. private _updateMatrix3x3ForUniform(name, matrix);
  15231. private _updateMatrix3x3ForEffect(name, matrix);
  15232. private _updateMatrix2x2ForEffect(name, matrix);
  15233. private _updateMatrix2x2ForUniform(name, matrix);
  15234. private _updateFloatForEffect(name, x);
  15235. private _updateFloatForUniform(name, x);
  15236. private _updateFloat2ForEffect(name, x, y, suffix?);
  15237. private _updateFloat2ForUniform(name, x, y, suffix?);
  15238. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15239. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15240. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15241. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15242. private _updateMatrixForEffect(name, mat);
  15243. private _updateMatrixForUniform(name, mat);
  15244. private _updateVector3ForEffect(name, vector);
  15245. private _updateVector3ForUniform(name, vector);
  15246. private _updateVector4ForEffect(name, vector);
  15247. private _updateVector4ForUniform(name, vector);
  15248. private _updateColor3ForEffect(name, color, suffix?);
  15249. private _updateColor3ForUniform(name, color, suffix?);
  15250. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15251. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15252. /**
  15253. * Sets a sampler uniform on the effect.
  15254. * @param {string} name Name of the sampler.
  15255. * @param {Texture} texture
  15256. */
  15257. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15258. /**
  15259. * Directly updates the value of the uniform in the cache AND on the GPU.
  15260. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15261. * @param {number[]|Float32Array} data Flattened data
  15262. */
  15263. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15264. /**
  15265. * Binds this uniform buffer to an effect.
  15266. * @param {Effect} effect
  15267. * @param {string} name Name of the uniform block in the shader.
  15268. */
  15269. bindToEffect(effect: Effect, name: string): void;
  15270. /**
  15271. * Disposes the uniform buffer.
  15272. */
  15273. dispose(): void;
  15274. }
  15275. }
  15276. declare module BABYLON {
  15277. class Scalar {
  15278. /**
  15279. * Two pi constants convenient for computation.
  15280. */
  15281. static TwoPi: number;
  15282. /**
  15283. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15284. */
  15285. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15286. /**
  15287. * Returns a string : the upper case translation of the number i to hexadecimal.
  15288. */
  15289. static ToHex(i: number): string;
  15290. /**
  15291. * Returns -1 if value is negative and +1 is value is positive.
  15292. * Returns the value itself if it's equal to zero.
  15293. */
  15294. static Sign(value: number): number;
  15295. /**
  15296. * Returns the value itself if it's between min and max.
  15297. * Returns min if the value is lower than min.
  15298. * Returns max if the value is greater than max.
  15299. */
  15300. static Clamp(value: number, min?: number, max?: number): number;
  15301. /**
  15302. * Returns the log2 of value.
  15303. */
  15304. static Log2(value: number): number;
  15305. /**
  15306. * Loops the value, so that it is never larger than length and never smaller than 0.
  15307. *
  15308. * This is similar to the modulo operator but it works with floating point numbers.
  15309. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15310. * With t = 5 and length = 2.5, the result would be 0.0.
  15311. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15312. */
  15313. static Repeat(value: number, length: number): number;
  15314. /**
  15315. * Normalize the value between 0.0 and 1.0 using min and max values
  15316. */
  15317. static Normalize(value: number, min: number, max: number): number;
  15318. /**
  15319. * Denormalize the value from 0.0 and 1.0 using min and max values
  15320. */
  15321. static Denormalize(normalized: number, min: number, max: number): number;
  15322. /**
  15323. * Calculates the shortest difference between two given angles given in degrees.
  15324. */
  15325. static DeltaAngle(current: number, target: number): number;
  15326. /**
  15327. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15328. *
  15329. * The returned value will move back and forth between 0 and length
  15330. */
  15331. static PingPong(tx: number, length: number): number;
  15332. /**
  15333. * Interpolates between min and max with smoothing at the limits.
  15334. *
  15335. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15336. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15337. */
  15338. static SmoothStep(from: number, to: number, tx: number): number;
  15339. /**
  15340. * Moves a value current towards target.
  15341. *
  15342. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15343. * Negative values of maxDelta pushes the value away from target.
  15344. */
  15345. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15346. /**
  15347. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15348. *
  15349. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15350. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15351. */
  15352. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15353. /**
  15354. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15355. */
  15356. static Lerp(start: number, end: number, amount: number): number;
  15357. /**
  15358. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15359. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15360. */
  15361. static LerpAngle(start: number, end: number, amount: number): number;
  15362. /**
  15363. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15364. */
  15365. static InverseLerp(a: number, b: number, value: number): number;
  15366. /**
  15367. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15368. */
  15369. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15370. /**
  15371. * Returns a random float number between and min and max values
  15372. */
  15373. static RandomRange(min: number, max: number): number;
  15374. /**
  15375. * This function returns percentage of a number in a given range.
  15376. *
  15377. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15378. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15379. */
  15380. static RangeToPercent(number: number, min: number, max: number): number;
  15381. /**
  15382. * This function returns number that corresponds to the percentage in a given range.
  15383. *
  15384. * PercentToRange(0.34,0,100) will return 34.
  15385. */
  15386. static PercentToRange(percent: number, min: number, max: number): number;
  15387. /**
  15388. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15389. * @param angle The angle to normalize in radian.
  15390. * @return The converted angle.
  15391. */
  15392. static NormalizeRadians(angle: number): number;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. const ToGammaSpace: number;
  15397. const ToLinearSpace = 2.2;
  15398. const Epsilon = 0.001;
  15399. /**
  15400. * Class used to hold a RBG color
  15401. */
  15402. class Color3 {
  15403. /**
  15404. * Defines the red component (between 0 and 1, default is 0)
  15405. */
  15406. r: number;
  15407. /**
  15408. * Defines the green component (between 0 and 1, default is 0)
  15409. */
  15410. g: number;
  15411. /**
  15412. * Defines the blue component (between 0 and 1, default is 0)
  15413. */
  15414. b: number;
  15415. /**
  15416. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15417. * @param r defines the red component (between 0 and 1, default is 0)
  15418. * @param g defines the green component (between 0 and 1, default is 0)
  15419. * @param b defines the blue component (between 0 and 1, default is 0)
  15420. */
  15421. constructor(
  15422. /**
  15423. * Defines the red component (between 0 and 1, default is 0)
  15424. */
  15425. r?: number,
  15426. /**
  15427. * Defines the green component (between 0 and 1, default is 0)
  15428. */
  15429. g?: number,
  15430. /**
  15431. * Defines the blue component (between 0 and 1, default is 0)
  15432. */
  15433. b?: number);
  15434. /**
  15435. * Creates a string with the Color3 current values
  15436. * @returns the string representation of the Color3 object
  15437. */
  15438. toString(): string;
  15439. /**
  15440. * Returns the string "Color3"
  15441. * @returns "Color3"
  15442. */
  15443. getClassName(): string;
  15444. /**
  15445. * Compute the Color3 hash code
  15446. * @returns an unique number that can be used to hash Color3 objects
  15447. */
  15448. getHashCode(): number;
  15449. /**
  15450. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15451. * @param array defines the array where to store the r,g,b components
  15452. * @param index defines an optional index in the target array to define where to start storing values
  15453. * @returns the current Color3 object
  15454. */
  15455. toArray(array: FloatArray, index?: number): Color3;
  15456. /**
  15457. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15458. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15459. * @returns a new {BABYLON.Color4} object
  15460. */
  15461. toColor4(alpha?: number): Color4;
  15462. /**
  15463. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15464. * @returns the new array
  15465. */
  15466. asArray(): number[];
  15467. /**
  15468. * Returns the luminance value
  15469. * @returns a float value
  15470. */
  15471. toLuminance(): number;
  15472. /**
  15473. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15474. * @param otherColor defines the second operand
  15475. * @returns the new Color3 object
  15476. */
  15477. multiply(otherColor: Color3): Color3;
  15478. /**
  15479. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15480. * @param otherColor defines the second operand
  15481. * @param result defines the Color3 object where to store the result
  15482. * @returns the current Color3
  15483. */
  15484. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15485. /**
  15486. * Determines equality between Color3 objects
  15487. * @param otherColor defines the second operand
  15488. * @returns true if the rgb values are equal to the given ones
  15489. */
  15490. equals(otherColor: Color3): boolean;
  15491. /**
  15492. * Determines equality between the current Color3 object and a set of r,b,g values
  15493. * @param r defines the red component to check
  15494. * @param g defines the green component to check
  15495. * @param b defines the blue component to check
  15496. * @returns true if the rgb values are equal to the given ones
  15497. */
  15498. equalsFloats(r: number, g: number, b: number): boolean;
  15499. /**
  15500. * Multiplies in place each rgb value by scale
  15501. * @param scale defines the scaling factor
  15502. * @returns the updated Color3
  15503. */
  15504. scale(scale: number): Color3;
  15505. /**
  15506. * Multiplies the rgb values by scale and stores the result into "result"
  15507. * @param scale defines the scaling factor
  15508. * @param result defines the Color3 object where to store the result
  15509. * @returns the unmodified current Color3
  15510. */
  15511. scaleToRef(scale: number, result: Color3): Color3;
  15512. /**
  15513. * Scale the current Color3 values by a factor and add the result to a given Color3
  15514. * @param scale defines the scale factor
  15515. * @param result defines color to store the result into
  15516. * @returns the unmodified current Color3
  15517. */
  15518. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15519. /**
  15520. * Clamps the rgb values by the min and max values and stores the result into "result"
  15521. * @param min defines minimum clamping value (default is 0)
  15522. * @param max defines maximum clamping value (default is 1)
  15523. * @param result defines color to store the result into
  15524. * @returns the original Color3
  15525. */
  15526. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15527. /**
  15528. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15529. * @param otherColor defines the second operand
  15530. * @returns the new Color3
  15531. */
  15532. add(otherColor: Color3): Color3;
  15533. /**
  15534. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15535. * @param otherColor defines the second operand
  15536. * @param result defines Color3 object to store the result into
  15537. * @returns the unmodified current Color3
  15538. */
  15539. addToRef(otherColor: Color3, result: Color3): Color3;
  15540. /**
  15541. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15542. * @param otherColor defines the second operand
  15543. * @returns the new Color3
  15544. */
  15545. subtract(otherColor: Color3): Color3;
  15546. /**
  15547. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15548. * @param otherColor defines the second operand
  15549. * @param result defines Color3 object to store the result into
  15550. * @returns the unmodified current Color3
  15551. */
  15552. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15553. /**
  15554. * Copy the current object
  15555. * @returns a new Color3 copied the current one
  15556. */
  15557. clone(): Color3;
  15558. /**
  15559. * Copies the rgb values from the source in the current Color3
  15560. * @param source defines the source Color3 object
  15561. * @returns the updated Color3 object
  15562. */
  15563. copyFrom(source: Color3): Color3;
  15564. /**
  15565. * Updates the Color3 rgb values from the given floats
  15566. * @param r defines the red component to read from
  15567. * @param g defines the green component to read from
  15568. * @param b defines the blue component to read from
  15569. * @returns the current Color3 object
  15570. */
  15571. copyFromFloats(r: number, g: number, b: number): Color3;
  15572. /**
  15573. * Updates the Color3 rgb values from the given floats
  15574. * @param r defines the red component to read from
  15575. * @param g defines the green component to read from
  15576. * @param b defines the blue component to read from
  15577. * @returns the current Color3 object
  15578. */
  15579. set(r: number, g: number, b: number): Color3;
  15580. /**
  15581. * Compute the Color3 hexadecimal code as a string
  15582. * @returns a string containing the hexadecimal representation of the Color3 object
  15583. */
  15584. toHexString(): string;
  15585. /**
  15586. * Computes a new Color3 converted from the current one to linear space
  15587. * @returns a new Color3 object
  15588. */
  15589. toLinearSpace(): Color3;
  15590. /**
  15591. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15592. * @param convertedColor defines the Color3 object where to store the linear space version
  15593. * @returns the unmodified Color3
  15594. */
  15595. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15596. /**
  15597. * Computes a new Color3 converted from the current one to gamma space
  15598. * @returns a new Color3 object
  15599. */
  15600. toGammaSpace(): Color3;
  15601. /**
  15602. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15603. * @param convertedColor defines the Color3 object where to store the gamma space version
  15604. * @returns the unmodified Color3
  15605. */
  15606. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15607. /**
  15608. * Creates a new Color3 from the string containing valid hexadecimal values
  15609. * @param hex defines a string containing valid hexadecimal values
  15610. * @returns a new Color3 object
  15611. */
  15612. static FromHexString(hex: string): Color3;
  15613. /**
  15614. * Creates a new Vector3 from the starting index of the given array
  15615. * @param array defines the source array
  15616. * @param offset defines an offset in the source array
  15617. * @returns a new Color3 object
  15618. */
  15619. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15620. /**
  15621. * Creates a new Color3 from integer values (< 256)
  15622. * @param r defines the red component to read from (value between 0 and 255)
  15623. * @param g defines the green component to read from (value between 0 and 255)
  15624. * @param b defines the blue component to read from (value between 0 and 255)
  15625. * @returns a new Color3 object
  15626. */
  15627. static FromInts(r: number, g: number, b: number): Color3;
  15628. /**
  15629. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15630. * @param start defines the start Color3 value
  15631. * @param end defines the end Color3 value
  15632. * @param amount defines the gradient value between start and end
  15633. * @returns a new Color3 object
  15634. */
  15635. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15636. /**
  15637. * Returns a Color3 value containing a red color
  15638. * @returns a new Color3 object
  15639. */
  15640. static Red(): Color3;
  15641. /**
  15642. * Returns a Color3 value containing a green color
  15643. * @returns a new Color3 object
  15644. */
  15645. static Green(): Color3;
  15646. /**
  15647. * Returns a Color3 value containing a blue color
  15648. * @returns a new Color3 object
  15649. */
  15650. static Blue(): Color3;
  15651. /**
  15652. * Returns a Color3 value containing a black color
  15653. * @returns a new Color3 object
  15654. */
  15655. static Black(): Color3;
  15656. /**
  15657. * Returns a Color3 value containing a white color
  15658. * @returns a new Color3 object
  15659. */
  15660. static White(): Color3;
  15661. /**
  15662. * Returns a Color3 value containing a purple color
  15663. * @returns a new Color3 object
  15664. */
  15665. static Purple(): Color3;
  15666. /**
  15667. * Returns a Color3 value containing a magenta color
  15668. * @returns a new Color3 object
  15669. */
  15670. static Magenta(): Color3;
  15671. /**
  15672. * Returns a Color3 value containing a yellow color
  15673. * @returns a new Color3 object
  15674. */
  15675. static Yellow(): Color3;
  15676. /**
  15677. * Returns a Color3 value containing a gray color
  15678. * @returns a new Color3 object
  15679. */
  15680. static Gray(): Color3;
  15681. /**
  15682. * Returns a Color3 value containing a teal color
  15683. * @returns a new Color3 object
  15684. */
  15685. static Teal(): Color3;
  15686. /**
  15687. * Returns a Color3 value containing a random color
  15688. * @returns a new Color3 object
  15689. */
  15690. static Random(): Color3;
  15691. }
  15692. /**
  15693. * Class used to hold a RBGA color
  15694. */
  15695. class Color4 {
  15696. /**
  15697. * Defines the red component (between 0 and 1, default is 0)
  15698. */
  15699. r: number;
  15700. /**
  15701. * Defines the green component (between 0 and 1, default is 0)
  15702. */
  15703. g: number;
  15704. /**
  15705. * Defines the blue component (between 0 and 1, default is 0)
  15706. */
  15707. b: number;
  15708. /**
  15709. * Defines the alpha component (between 0 and 1, default is 1)
  15710. */
  15711. a: number;
  15712. /**
  15713. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15714. * @param r defines the red component (between 0 and 1, default is 0)
  15715. * @param g defines the green component (between 0 and 1, default is 0)
  15716. * @param b defines the blue component (between 0 and 1, default is 0)
  15717. * @param a defines the alpha component (between 0 and 1, default is 1)
  15718. */
  15719. constructor(
  15720. /**
  15721. * Defines the red component (between 0 and 1, default is 0)
  15722. */
  15723. r?: number,
  15724. /**
  15725. * Defines the green component (between 0 and 1, default is 0)
  15726. */
  15727. g?: number,
  15728. /**
  15729. * Defines the blue component (between 0 and 1, default is 0)
  15730. */
  15731. b?: number,
  15732. /**
  15733. * Defines the alpha component (between 0 and 1, default is 1)
  15734. */
  15735. a?: number);
  15736. /**
  15737. * Adds in place the given Color4 values to the current Color4 object
  15738. * @param right defines the second operand
  15739. * @returns the current updated Color4 object
  15740. */
  15741. addInPlace(right: Color4): Color4;
  15742. /**
  15743. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15744. * @returns the new array
  15745. */
  15746. asArray(): number[];
  15747. /**
  15748. * Stores from the starting index in the given array the Color4 successive values
  15749. * @param array defines the array where to store the r,g,b components
  15750. * @param index defines an optional index in the target array to define where to start storing values
  15751. * @returns the current Color4 object
  15752. */
  15753. toArray(array: number[], index?: number): Color4;
  15754. /**
  15755. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15756. * @param right defines the second operand
  15757. * @returns a new Color4 object
  15758. */
  15759. add(right: Color4): Color4;
  15760. /**
  15761. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15762. * @param right defines the second operand
  15763. * @returns a new Color4 object
  15764. */
  15765. subtract(right: Color4): Color4;
  15766. /**
  15767. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15768. * @param right defines the second operand
  15769. * @param result defines the Color4 object where to store the result
  15770. * @returns the current Color4 object
  15771. */
  15772. subtractToRef(right: Color4, result: Color4): Color4;
  15773. /**
  15774. * Creates a new Color4 with the current Color4 values multiplied by scale
  15775. * @param scale defines the scaling factor to apply
  15776. * @returns a new Color4 object
  15777. */
  15778. scale(scale: number): Color4;
  15779. /**
  15780. * Multiplies the current Color4 values by scale and stores the result in "result"
  15781. * @param scale defines the scaling factor to apply
  15782. * @param result defines the Color4 object where to store the result
  15783. * @returns the current unmodified Color4
  15784. */
  15785. scaleToRef(scale: number, result: Color4): Color4;
  15786. /**
  15787. * Scale the current Color4 values by a factor and add the result to a given Color4
  15788. * @param scale defines the scale factor
  15789. * @param result defines the Color4 object where to store the result
  15790. * @returns the unmodified current Color4
  15791. */
  15792. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15793. /**
  15794. * Clamps the rgb values by the min and max values and stores the result into "result"
  15795. * @param min defines minimum clamping value (default is 0)
  15796. * @param max defines maximum clamping value (default is 1)
  15797. * @param result defines color to store the result into.
  15798. * @returns the cuurent Color4
  15799. */
  15800. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15801. /**
  15802. * Multipy an Color4 value by another and return a new Color4 object
  15803. * @param color defines the Color4 value to multiply by
  15804. * @returns a new Color4 object
  15805. */
  15806. multiply(color: Color4): Color4;
  15807. /**
  15808. * Multipy a Color4 value by another and push the result in a reference value
  15809. * @param color defines the Color4 value to multiply by
  15810. * @param result defines the Color4 to fill the result in
  15811. * @returns the result Color4
  15812. */
  15813. multiplyToRef(color: Color4, result: Color4): Color4;
  15814. /**
  15815. * Creates a string with the Color4 current values
  15816. * @returns the string representation of the Color4 object
  15817. */
  15818. toString(): string;
  15819. /**
  15820. * Returns the string "Color4"
  15821. * @returns "Color4"
  15822. */
  15823. getClassName(): string;
  15824. /**
  15825. * Compute the Color4 hash code
  15826. * @returns an unique number that can be used to hash Color4 objects
  15827. */
  15828. getHashCode(): number;
  15829. /**
  15830. * Creates a new Color4 copied from the current one
  15831. * @returns a new Color4 object
  15832. */
  15833. clone(): Color4;
  15834. /**
  15835. * Copies the given Color4 values into the current one
  15836. * @param source defines the source Color4 object
  15837. * @returns the current updated Color4 object
  15838. */
  15839. copyFrom(source: Color4): Color4;
  15840. /**
  15841. * Copies the given float values into the current one
  15842. * @param r defines the red component to read from
  15843. * @param g defines the green component to read from
  15844. * @param b defines the blue component to read from
  15845. * @param a defines the alpha component to read from
  15846. * @returns the current updated Color4 object
  15847. */
  15848. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15849. /**
  15850. * Copies the given float values into the current one
  15851. * @param r defines the red component to read from
  15852. * @param g defines the green component to read from
  15853. * @param b defines the blue component to read from
  15854. * @param a defines the alpha component to read from
  15855. * @returns the current updated Color4 object
  15856. */
  15857. set(r: number, g: number, b: number, a: number): Color4;
  15858. /**
  15859. * Compute the Color4 hexadecimal code as a string
  15860. * @returns a string containing the hexadecimal representation of the Color4 object
  15861. */
  15862. toHexString(): string;
  15863. /**
  15864. * Computes a new Color4 converted from the current one to linear space
  15865. * @returns a new Color4 object
  15866. */
  15867. toLinearSpace(): Color4;
  15868. /**
  15869. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15870. * @param convertedColor defines the Color4 object where to store the linear space version
  15871. * @returns the unmodified Color4
  15872. */
  15873. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15874. /**
  15875. * Computes a new Color4 converted from the current one to gamma space
  15876. * @returns a new Color4 object
  15877. */
  15878. toGammaSpace(): Color4;
  15879. /**
  15880. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15881. * @param convertedColor defines the Color4 object where to store the gamma space version
  15882. * @returns the unmodified Color4
  15883. */
  15884. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15885. /**
  15886. * Creates a new Color4 from the string containing valid hexadecimal values
  15887. * @param hex defines a string containing valid hexadecimal values
  15888. * @returns a new Color4 object
  15889. */
  15890. static FromHexString(hex: string): Color4;
  15891. /**
  15892. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15893. * @param left defines the start value
  15894. * @param right defines the end value
  15895. * @param amount defines the gradient factor
  15896. * @returns a new Color4 object
  15897. */
  15898. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15899. /**
  15900. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15901. * @param left defines the start value
  15902. * @param right defines the end value
  15903. * @param amount defines the gradient factor
  15904. * @param result defines the Color4 object where to store data
  15905. */
  15906. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15907. /**
  15908. * Creates a new Color4 from the starting index element of the given array
  15909. * @param array defines the source array to read from
  15910. * @param offset defines the offset in the source array
  15911. * @returns a new Color4 object
  15912. */
  15913. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15914. /**
  15915. * Creates a new Color3 from integer values (< 256)
  15916. * @param r defines the red component to read from (value between 0 and 255)
  15917. * @param g defines the green component to read from (value between 0 and 255)
  15918. * @param b defines the blue component to read from (value between 0 and 255)
  15919. * @param a defines the alpha component to read from (value between 0 and 255)
  15920. * @returns a new Color3 object
  15921. */
  15922. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15923. /**
  15924. * Check the content of a given array and convert it to an array containing RGBA data
  15925. * If the original array was already containing count * 4 values then it is returned directly
  15926. * @param colors defines the array to check
  15927. * @param count defines the number of RGBA data to expect
  15928. * @returns an array containing count * 4 values (RGBA)
  15929. */
  15930. static CheckColors4(colors: number[], count: number): number[];
  15931. }
  15932. /**
  15933. * Class representing a vector containing 2 coordinates
  15934. */
  15935. class Vector2 {
  15936. /** defines the first coordinate */
  15937. x: number;
  15938. /** defines the second coordinate */
  15939. y: number;
  15940. /**
  15941. * Creates a new Vector2 from the given x and y coordinates
  15942. * @param x defines the first coordinate
  15943. * @param y defines the second coordinate
  15944. */
  15945. constructor(
  15946. /** defines the first coordinate */
  15947. x?: number,
  15948. /** defines the second coordinate */
  15949. y?: number);
  15950. /**
  15951. * Gets a string with the Vector2 coordinates
  15952. * @returns a string with the Vector2 coordinates
  15953. */
  15954. toString(): string;
  15955. /**
  15956. * Gets class name
  15957. * @returns the string "Vector2"
  15958. */
  15959. getClassName(): string;
  15960. /**
  15961. * Gets current vector hash code
  15962. * @returns the Vector2 hash code as a number
  15963. */
  15964. getHashCode(): number;
  15965. /**
  15966. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15967. * @param array defines the source array
  15968. * @param index defines the offset in source array
  15969. * @returns the current Vector2
  15970. */
  15971. toArray(array: FloatArray, index?: number): Vector2;
  15972. /**
  15973. * Copy the current vector to an array
  15974. * @returns a new array with 2 elements: the Vector2 coordinates.
  15975. */
  15976. asArray(): number[];
  15977. /**
  15978. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15979. * @param source defines the source Vector2
  15980. * @returns the current updated Vector2
  15981. */
  15982. copyFrom(source: Vector2): Vector2;
  15983. /**
  15984. * Sets the Vector2 coordinates with the given floats
  15985. * @param x defines the first coordinate
  15986. * @param y defines the second coordinate
  15987. * @returns the current updated Vector2
  15988. */
  15989. copyFromFloats(x: number, y: number): Vector2;
  15990. /**
  15991. * Sets the Vector2 coordinates with the given floats
  15992. * @param x defines the first coordinate
  15993. * @param y defines the second coordinate
  15994. * @returns the current updated Vector2
  15995. */
  15996. set(x: number, y: number): Vector2;
  15997. /**
  15998. * Add another vector with the current one
  15999. * @param otherVector defines the other vector
  16000. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16001. */
  16002. add(otherVector: Vector2): Vector2;
  16003. /**
  16004. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16005. * @param otherVector defines the other vector
  16006. * @param result defines the target vector
  16007. * @returns the unmodified current Vector2
  16008. */
  16009. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16010. /**
  16011. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16012. * @param otherVector defines the other vector
  16013. * @returns the current updated Vector2
  16014. */
  16015. addInPlace(otherVector: Vector2): Vector2;
  16016. /**
  16017. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16018. * @param otherVector defines the other vector
  16019. * @returns a new Vector2
  16020. */
  16021. addVector3(otherVector: Vector3): Vector2;
  16022. /**
  16023. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16024. * @param otherVector defines the other vector
  16025. * @returns a new Vector2
  16026. */
  16027. subtract(otherVector: Vector2): Vector2;
  16028. /**
  16029. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16030. * @param otherVector defines the other vector
  16031. * @param result defines the target vector
  16032. * @returns the unmodified current Vector2
  16033. */
  16034. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16035. /**
  16036. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16037. * @param otherVector defines the other vector
  16038. * @returns the current updated Vector2
  16039. */
  16040. subtractInPlace(otherVector: Vector2): Vector2;
  16041. /**
  16042. * Multiplies in place the current Vector2 coordinates by the given ones
  16043. * @param otherVector defines the other vector
  16044. * @returns the current updated Vector2
  16045. */
  16046. multiplyInPlace(otherVector: Vector2): Vector2;
  16047. /**
  16048. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16049. * @param otherVector defines the other vector
  16050. * @returns a new Vector2
  16051. */
  16052. multiply(otherVector: Vector2): Vector2;
  16053. /**
  16054. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16055. * @param otherVector defines the other vector
  16056. * @param result defines the target vector
  16057. * @returns the unmodified current Vector2
  16058. */
  16059. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16060. /**
  16061. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16062. * @param x defines the first coordinate
  16063. * @param y defines the second coordinate
  16064. * @returns a new Vector2
  16065. */
  16066. multiplyByFloats(x: number, y: number): Vector2;
  16067. /**
  16068. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16069. * @param otherVector defines the other vector
  16070. * @returns a new Vector2
  16071. */
  16072. divide(otherVector: Vector2): Vector2;
  16073. /**
  16074. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16075. * @param otherVector defines the other vector
  16076. * @param result defines the target vector
  16077. * @returns the unmodified current Vector2
  16078. */
  16079. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16080. /**
  16081. * Divides the current Vector3 coordinates by the given ones
  16082. * @param otherVector defines the other vector
  16083. * @returns the current updated Vector2
  16084. */
  16085. divideInPlace(otherVector: Vector2): Vector2;
  16086. /**
  16087. * Gets a new Vector2 with current Vector2 negated coordinates
  16088. * @returns a new Vector2
  16089. */
  16090. negate(): Vector2;
  16091. /**
  16092. * Multiply the Vector2 coordinates by scale
  16093. * @param scale defines the scaling factor
  16094. * @returns the current updated Vector2
  16095. */
  16096. scaleInPlace(scale: number): Vector2;
  16097. /**
  16098. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16099. * @param scale defines the scaling factor
  16100. * @returns a new Vector2
  16101. */
  16102. scale(scale: number): Vector2;
  16103. /**
  16104. * Scale the current Vector2 values by a factor to a given Vector2
  16105. * @param scale defines the scale factor
  16106. * @param result defines the Vector2 object where to store the result
  16107. * @returns the unmodified current Vector2
  16108. */
  16109. scaleToRef(scale: number, result: Vector2): Vector2;
  16110. /**
  16111. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16112. * @param scale defines the scale factor
  16113. * @param result defines the Vector2 object where to store the result
  16114. * @returns the unmodified current Vector2
  16115. */
  16116. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16117. /**
  16118. * Gets a boolean if two vectors are equals
  16119. * @param otherVector defines the other vector
  16120. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16121. */
  16122. equals(otherVector: Vector2): boolean;
  16123. /**
  16124. * Gets a boolean if two vectors are equals (using an epsilon value)
  16125. * @param otherVector defines the other vector
  16126. * @param epsilon defines the minimal distance to consider equality
  16127. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16128. */
  16129. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16130. /**
  16131. * Gets the length of the vector
  16132. * @returns the vector length (float)
  16133. */
  16134. length(): number;
  16135. /**
  16136. * Gets the vector squared length
  16137. * @returns the vector squared length (float)
  16138. */
  16139. lengthSquared(): number;
  16140. /**
  16141. * Normalize the vector
  16142. * @returns the current updated Vector2
  16143. */
  16144. normalize(): Vector2;
  16145. /**
  16146. * Gets a new Vector2 copied from the Vector2
  16147. * @returns a new Vector2
  16148. */
  16149. clone(): Vector2;
  16150. /**
  16151. * Gets a new Vector2(0, 0)
  16152. * @returns a new Vector2
  16153. */
  16154. static Zero(): Vector2;
  16155. /**
  16156. * Gets a new Vector2(1, 1)
  16157. * @returns a new Vector2
  16158. */
  16159. static One(): Vector2;
  16160. /**
  16161. * Gets a new Vector2 set from the given index element of the given array
  16162. * @param array defines the data source
  16163. * @param offset defines the offset in the data source
  16164. * @returns a new Vector2
  16165. */
  16166. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16167. /**
  16168. * Sets "result" from the given index element of the given array
  16169. * @param array defines the data source
  16170. * @param offset defines the offset in the data source
  16171. * @param result defines the target vector
  16172. */
  16173. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16174. /**
  16175. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16176. * @param value1 defines 1st point of control
  16177. * @param value2 defines 2nd point of control
  16178. * @param value3 defines 3rd point of control
  16179. * @param value4 defines 4th point of control
  16180. * @param amount defines the interpolation factor
  16181. * @returns a new Vector2
  16182. */
  16183. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16184. /**
  16185. * 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".
  16186. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16187. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16188. * @param value defines the value to clamp
  16189. * @param min defines the lower limit
  16190. * @param max defines the upper limit
  16191. * @returns a new Vector2
  16192. */
  16193. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16194. /**
  16195. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16196. * @param value1 defines the 1st control point
  16197. * @param tangent1 defines the outgoing tangent
  16198. * @param value2 defines the 2nd control point
  16199. * @param tangent2 defines the incoming tangent
  16200. * @param amount defines the interpolation factor
  16201. * @returns a new Vector2
  16202. */
  16203. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16204. /**
  16205. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16206. * @param start defines the start vector
  16207. * @param end defines the end vector
  16208. * @param amount defines the interpolation factor
  16209. * @returns a new Vector2
  16210. */
  16211. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16212. /**
  16213. * Gets the dot product of the vector "left" and the vector "right"
  16214. * @param left defines first vector
  16215. * @param right defines second vector
  16216. * @returns the dot product (float)
  16217. */
  16218. static Dot(left: Vector2, right: Vector2): number;
  16219. /**
  16220. * Returns a new Vector2 equal to the normalized given vector
  16221. * @param vector defines the vector to normalize
  16222. * @returns a new Vector2
  16223. */
  16224. static Normalize(vector: Vector2): Vector2;
  16225. /**
  16226. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16227. * @param left defines 1st vector
  16228. * @param right defines 2nd vector
  16229. * @returns a new Vector2
  16230. */
  16231. static Minimize(left: Vector2, right: Vector2): Vector2;
  16232. /**
  16233. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16234. * @param left defines 1st vector
  16235. * @param right defines 2nd vector
  16236. * @returns a new Vector2
  16237. */
  16238. static Maximize(left: Vector2, right: Vector2): Vector2;
  16239. /**
  16240. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16241. * @param vector defines the vector to transform
  16242. * @param transformation defines the matrix to apply
  16243. * @returns a new Vector2
  16244. */
  16245. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16246. /**
  16247. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16248. * @param vector defines the vector to transform
  16249. * @param transformation defines the matrix to apply
  16250. * @param result defines the target vector
  16251. */
  16252. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16253. /**
  16254. * Determines if a given vector is included in a triangle
  16255. * @param p defines the vector to test
  16256. * @param p0 defines 1st triangle point
  16257. * @param p1 defines 2nd triangle point
  16258. * @param p2 defines 3rd triangle point
  16259. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16260. */
  16261. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16262. /**
  16263. * Gets the distance between the vectors "value1" and "value2"
  16264. * @param value1 defines first vector
  16265. * @param value2 defines second vector
  16266. * @returns the distance between vectors
  16267. */
  16268. static Distance(value1: Vector2, value2: Vector2): number;
  16269. /**
  16270. * Returns the squared distance between the vectors "value1" and "value2"
  16271. * @param value1 defines first vector
  16272. * @param value2 defines second vector
  16273. * @returns the squared distance between vectors
  16274. */
  16275. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16276. /**
  16277. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16278. * @param value1 defines first vector
  16279. * @param value2 defines second vector
  16280. * @returns a new Vector2
  16281. */
  16282. static Center(value1: Vector2, value2: Vector2): Vector2;
  16283. /**
  16284. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16285. * @param p defines the middle point
  16286. * @param segA defines one point of the segment
  16287. * @param segB defines the other point of the segment
  16288. * @returns the shortest distance
  16289. */
  16290. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16291. }
  16292. /**
  16293. * Classed used to store (x,y,z) vector representation
  16294. * A Vector3 is the main object used in 3D geometry
  16295. * It can represent etiher the coordinates of a point the space, either a direction
  16296. * Reminder: Babylon.js uses a left handed forward facing system
  16297. */
  16298. class Vector3 {
  16299. /**
  16300. * Defines the first coordinates (on X axis)
  16301. */
  16302. x: number;
  16303. /**
  16304. * Defines the second coordinates (on Y axis)
  16305. */
  16306. y: number;
  16307. /**
  16308. * Defines the third coordinates (on Z axis)
  16309. */
  16310. z: number;
  16311. /**
  16312. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16313. * @param x defines the first coordinates (on X axis)
  16314. * @param y defines the second coordinates (on Y axis)
  16315. * @param z defines the third coordinates (on Z axis)
  16316. */
  16317. constructor(
  16318. /**
  16319. * Defines the first coordinates (on X axis)
  16320. */
  16321. x?: number,
  16322. /**
  16323. * Defines the second coordinates (on Y axis)
  16324. */
  16325. y?: number,
  16326. /**
  16327. * Defines the third coordinates (on Z axis)
  16328. */
  16329. z?: number);
  16330. /**
  16331. * Creates a string representation of the Vector3
  16332. * @returns a string with the Vector3 coordinates.
  16333. */
  16334. toString(): string;
  16335. /**
  16336. * Gets the class name
  16337. * @returns the string "Vector3"
  16338. */
  16339. getClassName(): string;
  16340. /**
  16341. * Creates the Vector3 hash code
  16342. * @returns a number which tends to be unique between Vector3 instances
  16343. */
  16344. getHashCode(): number;
  16345. /**
  16346. * Creates an array containing three elements : the coordinates of the Vector3
  16347. * @returns a new array of numbers
  16348. */
  16349. asArray(): number[];
  16350. /**
  16351. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16352. * @param array defines the destination array
  16353. * @param index defines the offset in the destination array
  16354. * @returns the current Vector3
  16355. */
  16356. toArray(array: FloatArray, index?: number): Vector3;
  16357. /**
  16358. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16359. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16360. */
  16361. toQuaternion(): Quaternion;
  16362. /**
  16363. * Adds the given vector to the current Vector3
  16364. * @param otherVector defines the second operand
  16365. * @returns the current updated Vector3
  16366. */
  16367. addInPlace(otherVector: Vector3): Vector3;
  16368. /**
  16369. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16370. * @param otherVector defines the second operand
  16371. * @returns the resulting Vector3
  16372. */
  16373. add(otherVector: Vector3): Vector3;
  16374. /**
  16375. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16376. * @param otherVector defines the second operand
  16377. * @param result defines the Vector3 object where to store the result
  16378. * @returns the current Vector3
  16379. */
  16380. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16381. /**
  16382. * Subtract the given vector from the current Vector3
  16383. * @param otherVector defines the second operand
  16384. * @returns the current updated Vector3
  16385. */
  16386. subtractInPlace(otherVector: Vector3): Vector3;
  16387. /**
  16388. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16389. * @param otherVector defines the second operand
  16390. * @returns the resulting Vector3
  16391. */
  16392. subtract(otherVector: Vector3): Vector3;
  16393. /**
  16394. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16395. * @param otherVector defines the second operand
  16396. * @param result defines the Vector3 object where to store the result
  16397. * @returns the current Vector3
  16398. */
  16399. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16400. /**
  16401. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16402. * @param x defines the x coordinate of the operand
  16403. * @param y defines the y coordinate of the operand
  16404. * @param z defines the z coordinate of the operand
  16405. * @returns the resulting Vector3
  16406. */
  16407. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16408. /**
  16409. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16410. * @param x defines the x coordinate of the operand
  16411. * @param y defines the y coordinate of the operand
  16412. * @param z defines the z coordinate of the operand
  16413. * @param result defines the Vector3 object where to store the result
  16414. * @returns the current Vector3
  16415. */
  16416. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16417. /**
  16418. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16419. * @returns a new Vector3
  16420. */
  16421. negate(): Vector3;
  16422. /**
  16423. * Multiplies the Vector3 coordinates by the float "scale"
  16424. * @param scale defines the multiplier factor
  16425. * @returns the current updated Vector3
  16426. */
  16427. scaleInPlace(scale: number): Vector3;
  16428. /**
  16429. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16430. * @param scale defines the multiplier factor
  16431. * @returns a new Vector3
  16432. */
  16433. scale(scale: number): Vector3;
  16434. /**
  16435. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16436. * @param scale defines the multiplier factor
  16437. * @param result defines the Vector3 object where to store the result
  16438. * @returns the current Vector3
  16439. */
  16440. scaleToRef(scale: number, result: Vector3): Vector3;
  16441. /**
  16442. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16443. * @param scale defines the scale factor
  16444. * @param result defines the Vector3 object where to store the result
  16445. * @returns the unmodified current Vector3
  16446. */
  16447. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16448. /**
  16449. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16450. * @param otherVector defines the second operand
  16451. * @returns true if both vectors are equals
  16452. */
  16453. equals(otherVector: Vector3): boolean;
  16454. /**
  16455. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16456. * @param otherVector defines the second operand
  16457. * @param epsilon defines the minimal distance to define values as equals
  16458. * @returns true if both vectors are distant less than epsilon
  16459. */
  16460. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16461. /**
  16462. * Returns true if the current Vector3 coordinates equals the given floats
  16463. * @param x defines the x coordinate of the operand
  16464. * @param y defines the y coordinate of the operand
  16465. * @param z defines the z coordinate of the operand
  16466. * @returns true if both vectors are equals
  16467. */
  16468. equalsToFloats(x: number, y: number, z: number): boolean;
  16469. /**
  16470. * Multiplies the current Vector3 coordinates by the given ones
  16471. * @param otherVector defines the second operand
  16472. * @returns the current updated Vector3
  16473. */
  16474. multiplyInPlace(otherVector: Vector3): Vector3;
  16475. /**
  16476. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16477. * @param otherVector defines the second operand
  16478. * @returns the new Vector3
  16479. */
  16480. multiply(otherVector: Vector3): Vector3;
  16481. /**
  16482. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16483. * @param otherVector defines the second operand
  16484. * @param result defines the Vector3 object where to store the result
  16485. * @returns the current Vector3
  16486. */
  16487. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16488. /**
  16489. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16490. * @param x defines the x coordinate of the operand
  16491. * @param y defines the y coordinate of the operand
  16492. * @param z defines the z coordinate of the operand
  16493. * @returns the new Vector3
  16494. */
  16495. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16496. /**
  16497. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16498. * @param otherVector defines the second operand
  16499. * @returns the new Vector3
  16500. */
  16501. divide(otherVector: Vector3): Vector3;
  16502. /**
  16503. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16504. * @param otherVector defines the second operand
  16505. * @param result defines the Vector3 object where to store the result
  16506. * @returns the current Vector3
  16507. */
  16508. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16509. /**
  16510. * Divides the current Vector3 coordinates by the given ones.
  16511. * @param otherVector defines the second operand
  16512. * @returns the current updated Vector3
  16513. */
  16514. divideInPlace(otherVector: Vector3): Vector3;
  16515. /**
  16516. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16517. * @param other defines the second operand
  16518. * @returns the current updated Vector3
  16519. */
  16520. minimizeInPlace(other: Vector3): Vector3;
  16521. /**
  16522. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16523. * @param other defines the second operand
  16524. * @returns the current updated Vector3
  16525. */
  16526. maximizeInPlace(other: Vector3): Vector3;
  16527. /**
  16528. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16529. */
  16530. readonly isNonUniform: boolean;
  16531. /**
  16532. * Gets the length of the Vector3
  16533. * @returns the length of the Vecto3
  16534. */
  16535. length(): number;
  16536. /**
  16537. * Gets the squared length of the Vector3
  16538. * @returns squared length of the Vector3
  16539. */
  16540. lengthSquared(): number;
  16541. /**
  16542. * Normalize the current Vector3.
  16543. * Please note that this is an in place operation.
  16544. * @returns the current updated Vector3
  16545. */
  16546. normalize(): Vector3;
  16547. /**
  16548. * Normalize the current Vector3 to a new vector
  16549. * @returns the new Vector3
  16550. */
  16551. normalizeToNew(): Vector3;
  16552. /**
  16553. * Normalize the current Vector3 to the reference
  16554. * @param reference define the Vector3 to update
  16555. * @returns the updated Vector3
  16556. */
  16557. normalizeToRef(reference: Vector3): Vector3;
  16558. /**
  16559. * Creates a new Vector3 copied from the current Vector3
  16560. * @returns the new Vector3
  16561. */
  16562. clone(): Vector3;
  16563. /**
  16564. * Copies the given vector coordinates to the current Vector3 ones
  16565. * @param source defines the source Vector3
  16566. * @returns the current updated Vector3
  16567. */
  16568. copyFrom(source: Vector3): Vector3;
  16569. /**
  16570. * Copies the given floats to the current Vector3 coordinates
  16571. * @param x defines the x coordinate of the operand
  16572. * @param y defines the y coordinate of the operand
  16573. * @param z defines the z coordinate of the operand
  16574. * @returns the current updated Vector3
  16575. */
  16576. copyFromFloats(x: number, y: number, z: number): Vector3;
  16577. /**
  16578. * Copies the given floats to the current Vector3 coordinates
  16579. * @param x defines the x coordinate of the operand
  16580. * @param y defines the y coordinate of the operand
  16581. * @param z defines the z coordinate of the operand
  16582. * @returns the current updated Vector3
  16583. */
  16584. set(x: number, y: number, z: number): Vector3;
  16585. /**
  16586. * Get the clip factor between two vectors
  16587. * @param vector0 defines the first operand
  16588. * @param vector1 defines the second operand
  16589. * @param axis defines the axis to use
  16590. * @param size defines the size along the axis
  16591. * @returns the clip factor
  16592. */
  16593. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16594. /**
  16595. * Get angle between two vectors
  16596. * @param vector0 angle between vector0 and vector1
  16597. * @param vector1 angle between vector0 and vector1
  16598. * @param normal direction of the normal
  16599. * @return the angle between vector0 and vector1
  16600. */
  16601. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16602. /**
  16603. * Returns a new Vector3 set from the index "offset" of the given array
  16604. * @param array defines the source array
  16605. * @param offset defines the offset in the source array
  16606. * @returns the new Vector3
  16607. */
  16608. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16609. /**
  16610. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16611. * This function is deprecated. Use FromArray instead
  16612. * @param array defines the source array
  16613. * @param offset defines the offset in the source array
  16614. * @returns the new Vector3
  16615. */
  16616. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16617. /**
  16618. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16619. * @param array defines the source array
  16620. * @param offset defines the offset in the source array
  16621. * @param result defines the Vector3 where to store the result
  16622. */
  16623. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16624. /**
  16625. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16626. * This function is deprecated. Use FromArrayToRef instead.
  16627. * @param array defines the source array
  16628. * @param offset defines the offset in the source array
  16629. * @param result defines the Vector3 where to store the result
  16630. */
  16631. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16632. /**
  16633. * Sets the given vector "result" with the given floats.
  16634. * @param x defines the x coordinate of the source
  16635. * @param y defines the y coordinate of the source
  16636. * @param z defines the z coordinate of the source
  16637. * @param result defines the Vector3 where to store the result
  16638. */
  16639. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16640. /**
  16641. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16642. * @returns a new empty Vector3
  16643. */
  16644. static Zero(): Vector3;
  16645. /**
  16646. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16647. * @returns a new unit Vector3
  16648. */
  16649. static One(): Vector3;
  16650. /**
  16651. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16652. * @returns a new up Vector3
  16653. */
  16654. static Up(): Vector3;
  16655. /**
  16656. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16657. * @returns a new down Vector3
  16658. */
  16659. static Down(): Vector3;
  16660. /**
  16661. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16662. * @returns a new forward Vector3
  16663. */
  16664. static Forward(): Vector3;
  16665. /**
  16666. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16667. * @returns a new right Vector3
  16668. */
  16669. static Right(): Vector3;
  16670. /**
  16671. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16672. * @returns a new left Vector3
  16673. */
  16674. static Left(): Vector3;
  16675. /**
  16676. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16677. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16678. * @param vector defines the Vector3 to transform
  16679. * @param transformation defines the transformation matrix
  16680. * @returns the transformed Vector3
  16681. */
  16682. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16683. /**
  16684. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16685. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16686. * @param vector defines the Vector3 to transform
  16687. * @param transformation defines the transformation matrix
  16688. * @param result defines the Vector3 where to store the result
  16689. */
  16690. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16691. /**
  16692. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16693. * This method computes tranformed coordinates only, not transformed direction vectors
  16694. * @param x define the x coordinate of the source vector
  16695. * @param y define the y coordinate of the source vector
  16696. * @param z define the z coordinate of the source vector
  16697. * @param transformation defines the transformation matrix
  16698. * @param result defines the Vector3 where to store the result
  16699. */
  16700. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16701. /**
  16702. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16703. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16704. * @param vector defines the Vector3 to transform
  16705. * @param transformation defines the transformation matrix
  16706. * @returns the new Vector3
  16707. */
  16708. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16709. /**
  16710. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16711. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16712. * @param vector defines the Vector3 to transform
  16713. * @param transformation defines the transformation matrix
  16714. * @param result defines the Vector3 where to store the result
  16715. */
  16716. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16717. /**
  16718. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16720. * @param x define the x coordinate of the source vector
  16721. * @param y define the y coordinate of the source vector
  16722. * @param z define the z coordinate of the source vector
  16723. * @param transformation defines the transformation matrix
  16724. * @param result defines the Vector3 where to store the result
  16725. */
  16726. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16727. /**
  16728. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16729. * @param value1 defines the first control point
  16730. * @param value2 defines the second control point
  16731. * @param value3 defines the third control point
  16732. * @param value4 defines the fourth control point
  16733. * @param amount defines the amount on the spline to use
  16734. * @returns the new Vector3
  16735. */
  16736. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16737. /**
  16738. * 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"
  16739. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16740. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16741. * @param value defines the current value
  16742. * @param min defines the lower range value
  16743. * @param max defines the upper range value
  16744. * @returns the new Vector3
  16745. */
  16746. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16747. /**
  16748. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16749. * @param value1 defines the first control point
  16750. * @param tangent1 defines the first tangent vector
  16751. * @param value2 defines the second control point
  16752. * @param tangent2 defines the second tangent vector
  16753. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16754. * @returns the new Vector3
  16755. */
  16756. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16757. /**
  16758. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16759. * @param start defines the start value
  16760. * @param end defines the end value
  16761. * @param amount max defines amount between both (between 0 and 1)
  16762. * @returns the new Vector3
  16763. */
  16764. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16765. /**
  16766. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16767. * @param start defines the start value
  16768. * @param end defines the end value
  16769. * @param amount max defines amount between both (between 0 and 1)
  16770. * @param result defines the Vector3 where to store the result
  16771. */
  16772. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16773. /**
  16774. * Returns the dot product (float) between the vectors "left" and "right"
  16775. * @param left defines the left operand
  16776. * @param right defines the right operand
  16777. * @returns the dot product
  16778. */
  16779. static Dot(left: Vector3, right: Vector3): number;
  16780. /**
  16781. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16782. * The cross product is then orthogonal to both "left" and "right"
  16783. * @param left defines the left operand
  16784. * @param right defines the right operand
  16785. * @returns the cross product
  16786. */
  16787. static Cross(left: Vector3, right: Vector3): Vector3;
  16788. /**
  16789. * Sets the given vector "result" with the cross product of "left" and "right"
  16790. * The cross product is then orthogonal to both "left" and "right"
  16791. * @param left defines the left operand
  16792. * @param right defines the right operand
  16793. * @param result defines the Vector3 where to store the result
  16794. */
  16795. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16796. /**
  16797. * Returns a new Vector3 as the normalization of the given vector
  16798. * @param vector defines the Vector3 to normalize
  16799. * @returns the new Vector3
  16800. */
  16801. static Normalize(vector: Vector3): Vector3;
  16802. /**
  16803. * Sets the given vector "result" with the normalization of the given first vector
  16804. * @param vector defines the Vector3 to normalize
  16805. * @param result defines the Vector3 where to store the result
  16806. */
  16807. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16808. private static _viewportMatrixCache;
  16809. /**
  16810. * Project a Vector3 onto screen space
  16811. * @param vector defines the Vector3 to project
  16812. * @param world defines the world matrix to use
  16813. * @param transform defines the transform (view x projection) matrix to use
  16814. * @param viewport defines the screen viewport to use
  16815. * @returns the new Vector3
  16816. */
  16817. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16818. /**
  16819. * Unproject from screen space to object space
  16820. * @param source defines the screen space Vector3 to use
  16821. * @param viewportWidth defines the current width of the viewport
  16822. * @param viewportHeight defines the current height of the viewport
  16823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16824. * @param transform defines the transform (view x projection) matrix to use
  16825. * @returns the new Vector3
  16826. */
  16827. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16828. /**
  16829. * Unproject from screen space to object space
  16830. * @param source defines the screen space Vector3 to use
  16831. * @param viewportWidth defines the current width of the viewport
  16832. * @param viewportHeight defines the current height of the viewport
  16833. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16834. * @param view defines the view matrix to use
  16835. * @param projection defines the projection matrix to use
  16836. * @returns the new Vector3
  16837. */
  16838. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16839. /**
  16840. * Unproject from screen space to object space
  16841. * @param source defines the screen space Vector3 to use
  16842. * @param viewportWidth defines the current width of the viewport
  16843. * @param viewportHeight defines the current height of the viewport
  16844. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16845. * @param view defines the view matrix to use
  16846. * @param projection defines the projection matrix to use
  16847. * @param result defines the Vector3 where to store the result
  16848. */
  16849. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16850. /**
  16851. * Unproject from screen space to object space
  16852. * @param sourceX defines the screen space x coordinate to use
  16853. * @param sourceY defines the screen space y coordinate to use
  16854. * @param sourceZ defines the screen space z coordinate to use
  16855. * @param viewportWidth defines the current width of the viewport
  16856. * @param viewportHeight defines the current height of the viewport
  16857. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16858. * @param view defines the view matrix to use
  16859. * @param projection defines the projection matrix to use
  16860. * @param result defines the Vector3 where to store the result
  16861. */
  16862. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16863. /**
  16864. * Gets the minimal coordinate values between two Vector3
  16865. * @param left defines the first operand
  16866. * @param right defines the second operand
  16867. * @returns the new Vector3
  16868. */
  16869. static Minimize(left: Vector3, right: Vector3): Vector3;
  16870. /**
  16871. * Gets the maximal coordinate values between two Vector3
  16872. * @param left defines the first operand
  16873. * @param right defines the second operand
  16874. * @returns the new Vector3
  16875. */
  16876. static Maximize(left: Vector3, right: Vector3): Vector3;
  16877. /**
  16878. * Returns the distance between the vectors "value1" and "value2"
  16879. * @param value1 defines the first operand
  16880. * @param value2 defines the second operand
  16881. * @returns the distance
  16882. */
  16883. static Distance(value1: Vector3, value2: Vector3): number;
  16884. /**
  16885. * Returns the squared distance between the vectors "value1" and "value2"
  16886. * @param value1 defines the first operand
  16887. * @param value2 defines the second operand
  16888. * @returns the squared distance
  16889. */
  16890. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16891. /**
  16892. * Returns a new Vector3 located at the center between "value1" and "value2"
  16893. * @param value1 defines the first operand
  16894. * @param value2 defines the second operand
  16895. * @returns the new Vector3
  16896. */
  16897. static Center(value1: Vector3, value2: Vector3): Vector3;
  16898. /**
  16899. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16900. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16901. * to something in order to rotate it from its local system to the given target system
  16902. * Note: axis1, axis2 and axis3 are normalized during this operation
  16903. * @param axis1 defines the first axis
  16904. * @param axis2 defines the second axis
  16905. * @param axis3 defines the third axis
  16906. * @returns a new Vector3
  16907. */
  16908. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16909. /**
  16910. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16911. * @param axis1 defines the first axis
  16912. * @param axis2 defines the second axis
  16913. * @param axis3 defines the third axis
  16914. * @param ref defines the Vector3 where to store the result
  16915. */
  16916. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16917. }
  16918. class Vector4 {
  16919. x: number;
  16920. y: number;
  16921. z: number;
  16922. w: number;
  16923. /**
  16924. * Creates a Vector4 object from the given floats.
  16925. */
  16926. constructor(x: number, y: number, z: number, w: number);
  16927. /**
  16928. * Returns the string with the Vector4 coordinates.
  16929. */
  16930. toString(): string;
  16931. /**
  16932. * Returns the string "Vector4".
  16933. */
  16934. getClassName(): string;
  16935. /**
  16936. * Returns the Vector4 hash code.
  16937. */
  16938. getHashCode(): number;
  16939. /**
  16940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16941. */
  16942. asArray(): number[];
  16943. /**
  16944. * Populates the given array from the given index with the Vector4 coordinates.
  16945. * Returns the Vector4.
  16946. */
  16947. toArray(array: FloatArray, index?: number): Vector4;
  16948. /**
  16949. * Adds the given vector to the current Vector4.
  16950. * Returns the updated Vector4.
  16951. */
  16952. addInPlace(otherVector: Vector4): Vector4;
  16953. /**
  16954. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16955. */
  16956. add(otherVector: Vector4): Vector4;
  16957. /**
  16958. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16959. * Returns the current Vector4.
  16960. */
  16961. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16962. /**
  16963. * Subtract in place the given vector from the current Vector4.
  16964. * Returns the updated Vector4.
  16965. */
  16966. subtractInPlace(otherVector: Vector4): Vector4;
  16967. /**
  16968. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16969. */
  16970. subtract(otherVector: Vector4): Vector4;
  16971. /**
  16972. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16973. * Returns the current Vector4.
  16974. */
  16975. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16976. /**
  16977. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16978. */
  16979. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16980. /**
  16981. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16982. * Returns the current Vector4.
  16983. */
  16984. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16985. /**
  16986. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16987. */
  16988. negate(): Vector4;
  16989. /**
  16990. * Multiplies the current Vector4 coordinates by scale (float).
  16991. * Returns the updated Vector4.
  16992. */
  16993. scaleInPlace(scale: number): Vector4;
  16994. /**
  16995. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16996. */
  16997. scale(scale: number): Vector4;
  16998. /**
  16999. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17000. * Returns the current Vector4.
  17001. */
  17002. scaleToRef(scale: number, result: Vector4): Vector4;
  17003. /**
  17004. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17005. * @param scale defines the scale factor
  17006. * @param result defines the Vector4 object where to store the result
  17007. * @returns the unmodified current Vector4
  17008. */
  17009. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17010. /**
  17011. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17012. */
  17013. equals(otherVector: Vector4): boolean;
  17014. /**
  17015. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17016. */
  17017. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17018. /**
  17019. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17020. */
  17021. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17022. /**
  17023. * Multiplies in place the current Vector4 by the given one.
  17024. * Returns the updated Vector4.
  17025. */
  17026. multiplyInPlace(otherVector: Vector4): Vector4;
  17027. /**
  17028. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17029. */
  17030. multiply(otherVector: Vector4): Vector4;
  17031. /**
  17032. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17033. * Returns the current Vector4.
  17034. */
  17035. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17036. /**
  17037. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17038. */
  17039. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17040. /**
  17041. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17042. */
  17043. divide(otherVector: Vector4): Vector4;
  17044. /**
  17045. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17046. * Returns the current Vector4.
  17047. */
  17048. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17049. /**
  17050. * Divides the current Vector3 coordinates by the given ones.
  17051. * @returns the updated Vector3.
  17052. */
  17053. divideInPlace(otherVector: Vector4): Vector4;
  17054. /**
  17055. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17056. * @param other defines the second operand
  17057. * @returns the current updated Vector4
  17058. */
  17059. minimizeInPlace(other: Vector4): Vector4;
  17060. /**
  17061. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17062. * @param other defines the second operand
  17063. * @returns the current updated Vector4
  17064. */
  17065. maximizeInPlace(other: Vector4): Vector4;
  17066. /**
  17067. * Returns the Vector4 length (float).
  17068. */
  17069. length(): number;
  17070. /**
  17071. * Returns the Vector4 squared length (float).
  17072. */
  17073. lengthSquared(): number;
  17074. /**
  17075. * Normalizes in place the Vector4.
  17076. * Returns the updated Vector4.
  17077. */
  17078. normalize(): Vector4;
  17079. /**
  17080. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17081. */
  17082. toVector3(): Vector3;
  17083. /**
  17084. * Returns a new Vector4 copied from the current one.
  17085. */
  17086. clone(): Vector4;
  17087. /**
  17088. * Updates the current Vector4 with the given one coordinates.
  17089. * Returns the updated Vector4.
  17090. */
  17091. copyFrom(source: Vector4): Vector4;
  17092. /**
  17093. * Updates the current Vector4 coordinates with the given floats.
  17094. * Returns the updated Vector4.
  17095. */
  17096. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17097. /**
  17098. * Updates the current Vector4 coordinates with the given floats.
  17099. * Returns the updated Vector4.
  17100. */
  17101. set(x: number, y: number, z: number, w: number): Vector4;
  17102. /**
  17103. * Returns a new Vector4 set from the starting index of the given array.
  17104. */
  17105. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17106. /**
  17107. * Updates the given vector "result" from the starting index of the given array.
  17108. */
  17109. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17110. /**
  17111. * Updates the given vector "result" from the starting index of the given Float32Array.
  17112. */
  17113. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17114. /**
  17115. * Updates the given vector "result" coordinates from the given floats.
  17116. */
  17117. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17118. /**
  17119. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17120. */
  17121. static Zero(): Vector4;
  17122. /**
  17123. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17124. */
  17125. static One(): Vector4;
  17126. /**
  17127. * Returns a new normalized Vector4 from the given one.
  17128. */
  17129. static Normalize(vector: Vector4): Vector4;
  17130. /**
  17131. * Updates the given vector "result" from the normalization of the given one.
  17132. */
  17133. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17134. static Minimize(left: Vector4, right: Vector4): Vector4;
  17135. static Maximize(left: Vector4, right: Vector4): Vector4;
  17136. /**
  17137. * Returns the distance (float) between the vectors "value1" and "value2".
  17138. */
  17139. static Distance(value1: Vector4, value2: Vector4): number;
  17140. /**
  17141. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17142. */
  17143. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17144. /**
  17145. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17146. */
  17147. static Center(value1: Vector4, value2: Vector4): Vector4;
  17148. /**
  17149. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17150. * This methods computes transformed normalized direction vectors only.
  17151. */
  17152. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17153. /**
  17154. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17155. * This methods computes transformed normalized direction vectors only.
  17156. */
  17157. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17158. /**
  17159. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17160. * This methods computes transformed normalized direction vectors only.
  17161. */
  17162. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17163. }
  17164. interface ISize {
  17165. width: number;
  17166. height: number;
  17167. }
  17168. class Size implements ISize {
  17169. width: number;
  17170. height: number;
  17171. /**
  17172. * Creates a Size object from the given width and height (floats).
  17173. */
  17174. constructor(width: number, height: number);
  17175. toString(): string;
  17176. /**
  17177. * Returns the string "Size"
  17178. */
  17179. getClassName(): string;
  17180. /**
  17181. * Returns the Size hash code.
  17182. */
  17183. getHashCode(): number;
  17184. /**
  17185. * Updates the current size from the given one.
  17186. * Returns the updated Size.
  17187. */
  17188. copyFrom(src: Size): void;
  17189. /**
  17190. * Updates in place the current Size from the given floats.
  17191. * Returns the updated Size.
  17192. */
  17193. copyFromFloats(width: number, height: number): Size;
  17194. /**
  17195. * Updates in place the current Size from the given floats.
  17196. * Returns the updated Size.
  17197. */
  17198. set(width: number, height: number): Size;
  17199. /**
  17200. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17201. */
  17202. multiplyByFloats(w: number, h: number): Size;
  17203. /**
  17204. * Returns a new Size copied from the given one.
  17205. */
  17206. clone(): Size;
  17207. /**
  17208. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17209. */
  17210. equals(other: Size): boolean;
  17211. /**
  17212. * Returns the surface of the Size : width * height (float).
  17213. */
  17214. readonly surface: number;
  17215. /**
  17216. * Returns a new Size set to (0.0, 0.0)
  17217. */
  17218. static Zero(): Size;
  17219. /**
  17220. * Returns a new Size set as the addition result of the current Size and the given one.
  17221. */
  17222. add(otherSize: Size): Size;
  17223. /**
  17224. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17225. */
  17226. subtract(otherSize: Size): Size;
  17227. /**
  17228. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17229. */
  17230. static Lerp(start: Size, end: Size, amount: number): Size;
  17231. }
  17232. /**
  17233. * Class used to store quaternion data
  17234. * @see https://en.wikipedia.org/wiki/Quaternion
  17235. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17236. */
  17237. class Quaternion {
  17238. /** defines the first component (0 by default) */
  17239. x: number;
  17240. /** defines the second component (0 by default) */
  17241. y: number;
  17242. /** defines the third component (0 by default) */
  17243. z: number;
  17244. /** defines the fourth component (1.0 by default) */
  17245. w: number;
  17246. /**
  17247. * Creates a new Quaternion from the given floats
  17248. * @param x defines the first component (0 by default)
  17249. * @param y defines the second component (0 by default)
  17250. * @param z defines the third component (0 by default)
  17251. * @param w defines the fourth component (1.0 by default)
  17252. */
  17253. constructor(
  17254. /** defines the first component (0 by default) */
  17255. x?: number,
  17256. /** defines the second component (0 by default) */
  17257. y?: number,
  17258. /** defines the third component (0 by default) */
  17259. z?: number,
  17260. /** defines the fourth component (1.0 by default) */
  17261. w?: number);
  17262. /**
  17263. * Gets a string representation for the current quaternion
  17264. * @returns a string with the Quaternion coordinates
  17265. */
  17266. toString(): string;
  17267. /**
  17268. * Gets the class name of the quaternion
  17269. * @returns the string "Quaternion"
  17270. */
  17271. getClassName(): string;
  17272. /**
  17273. * Gets a hash code for this quaternion
  17274. * @returns the quaternion hash code
  17275. */
  17276. getHashCode(): number;
  17277. /**
  17278. * Copy the quaternion to an array
  17279. * @returns a new array populated with 4 elements from the quaternion coordinates
  17280. */
  17281. asArray(): number[];
  17282. /**
  17283. * Check if two quaternions are equals
  17284. * @param otherQuaternion defines the second operand
  17285. * @return true if the current quaternion and the given one coordinates are strictly equals
  17286. */
  17287. equals(otherQuaternion: Quaternion): boolean;
  17288. /**
  17289. * Clone the current quaternion
  17290. * @returns a new quaternion copied from the current one
  17291. */
  17292. clone(): Quaternion;
  17293. /**
  17294. * Copy a quaternion to the current one
  17295. * @param other defines the other quaternion
  17296. * @returns the updated current quaternion
  17297. */
  17298. copyFrom(other: Quaternion): Quaternion;
  17299. /**
  17300. * Updates the current quaternion with the given float coordinates
  17301. * @param x defines the x coordinate
  17302. * @param y defines the y coordinate
  17303. * @param z defines the z coordinate
  17304. * @param w defines the w coordinate
  17305. * @returns the updated current quaternion
  17306. */
  17307. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17308. /**
  17309. * Updates the current quaternion from the given float coordinates
  17310. * @param x defines the x coordinate
  17311. * @param y defines the y coordinate
  17312. * @param z defines the z coordinate
  17313. * @param w defines the w coordinate
  17314. * @returns the updated current quaternion
  17315. */
  17316. set(x: number, y: number, z: number, w: number): Quaternion;
  17317. /**
  17318. * Adds two quaternions
  17319. * @param other defines the second operand
  17320. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17321. */
  17322. add(other: Quaternion): Quaternion;
  17323. /**
  17324. * Add a quaternion to the current one
  17325. * @param other defines the quaternion to add
  17326. * @returns the current quaternion
  17327. */
  17328. addInPlace(other: Quaternion): Quaternion;
  17329. /**
  17330. * Subtract two quaternions
  17331. * @param other defines the second operand
  17332. * @returns a new quaternion as the subtraction result of the given one from the current one
  17333. */
  17334. subtract(other: Quaternion): Quaternion;
  17335. /**
  17336. * Multiplies the current quaternion by a scale factor
  17337. * @param value defines the scale factor
  17338. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17339. */
  17340. scale(value: number): Quaternion;
  17341. /**
  17342. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17343. * @param scale defines the scale factor
  17344. * @param result defines the Quaternion object where to store the result
  17345. * @returns the unmodified current quaternion
  17346. */
  17347. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17348. /**
  17349. * Multiplies in place the current quaternion by a scale factor
  17350. * @param value defines the scale factor
  17351. * @returns the current modified quaternion
  17352. */
  17353. scaleInPlace(value: number): Quaternion;
  17354. /**
  17355. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17356. * @param scale defines the scale factor
  17357. * @param result defines the Quaternion object where to store the result
  17358. * @returns the unmodified current quaternion
  17359. */
  17360. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17361. /**
  17362. * Multiplies two quaternions
  17363. * @param q1 defines the second operand
  17364. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17365. */
  17366. multiply(q1: Quaternion): Quaternion;
  17367. /**
  17368. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17369. * @param q1 defines the second operand
  17370. * @param result defines the target quaternion
  17371. * @returns the current quaternion
  17372. */
  17373. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17374. /**
  17375. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17376. * @param q1 defines the second operand
  17377. * @returns the currentupdated quaternion
  17378. */
  17379. multiplyInPlace(q1: Quaternion): Quaternion;
  17380. /**
  17381. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17382. * @param ref defines the target quaternion
  17383. * @returns the current quaternion
  17384. */
  17385. conjugateToRef(ref: Quaternion): Quaternion;
  17386. /**
  17387. * Conjugates in place (1-q) the current quaternion
  17388. * @returns the current updated quaternion
  17389. */
  17390. conjugateInPlace(): Quaternion;
  17391. /**
  17392. * Conjugates in place (1-q) the current quaternion
  17393. * @returns a new quaternion
  17394. */
  17395. conjugate(): Quaternion;
  17396. /**
  17397. * Gets length of current quaternion
  17398. * @returns the quaternion length (float)
  17399. */
  17400. length(): number;
  17401. /**
  17402. * Normalize in place the current quaternion
  17403. * @returns the current updated quaternion
  17404. */
  17405. normalize(): Quaternion;
  17406. /**
  17407. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17408. * @param order is a reserved parameter and is ignore for now
  17409. * @returns a new Vector3 containing the Euler angles
  17410. */
  17411. toEulerAngles(order?: string): Vector3;
  17412. /**
  17413. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17414. * @param result defines the vector which will be filled with the Euler angles
  17415. * @param order is a reserved parameter and is ignore for now
  17416. * @returns the current unchanged quaternion
  17417. */
  17418. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17419. /**
  17420. * Updates the given rotation matrix with the current quaternion values
  17421. * @param result defines the target matrix
  17422. * @returns the current unchanged quaternion
  17423. */
  17424. toRotationMatrix(result: Matrix): Quaternion;
  17425. /**
  17426. * Updates the current quaternion from the given rotation matrix values
  17427. * @param matrix defines the source matrix
  17428. * @returns the current updated quaternion
  17429. */
  17430. fromRotationMatrix(matrix: Matrix): Quaternion;
  17431. /**
  17432. * Creates a new quaternion from a rotation matrix
  17433. * @param matrix defines the source matrix
  17434. * @returns a new quaternion created from the given rotation matrix values
  17435. */
  17436. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17437. /**
  17438. * Updates the given quaternion with the given rotation matrix values
  17439. * @param matrix defines the source matrix
  17440. * @param result defines the target quaternion
  17441. */
  17442. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17443. /**
  17444. * Returns the dot product (float) between the quaternions "left" and "right"
  17445. * @param left defines the left operand
  17446. * @param right defines the right operand
  17447. * @returns the dot product
  17448. */
  17449. static Dot(left: Quaternion, right: Quaternion): number;
  17450. /**
  17451. * Checks if the two quaternions are close to each other
  17452. * @param quat0 defines the first quaternion to check
  17453. * @param quat1 defines the second quaternion to check
  17454. * @returns true if the two quaternions are close to each other
  17455. */
  17456. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17457. /**
  17458. * Creates an empty quaternion
  17459. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17460. */
  17461. static Zero(): Quaternion;
  17462. /**
  17463. * Inverse a given quaternion
  17464. * @param q defines the source quaternion
  17465. * @returns a new quaternion as the inverted current quaternion
  17466. */
  17467. static Inverse(q: Quaternion): Quaternion;
  17468. /**
  17469. * Creates an identity quaternion
  17470. * @returns the identity quaternion
  17471. */
  17472. static Identity(): Quaternion;
  17473. /**
  17474. * Gets a boolean indicating if the given quaternion is identity
  17475. * @param quaternion defines the quaternion to check
  17476. * @returns true if the quaternion is identity
  17477. */
  17478. static IsIdentity(quaternion: Quaternion): boolean;
  17479. /**
  17480. * Creates a quaternion from a rotation around an axis
  17481. * @param axis defines the axis to use
  17482. * @param angle defines the angle to use
  17483. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17484. */
  17485. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17486. /**
  17487. * Creates a rotation around an axis and stores it into the given quaternion
  17488. * @param axis defines the axis to use
  17489. * @param angle defines the angle to use
  17490. * @param result defines the target quaternion
  17491. * @returns the target quaternion
  17492. */
  17493. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17494. /**
  17495. * Creates a new quaternion from data stored into an array
  17496. * @param array defines the data source
  17497. * @param offset defines the offset in the source array where the data starts
  17498. * @returns a new quaternion
  17499. */
  17500. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17501. /**
  17502. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17503. * @param yaw defines the rotation around Y axis
  17504. * @param pitch defines the rotation around X axis
  17505. * @param roll defines the rotation around Z axis
  17506. * @returns the new quaternion
  17507. */
  17508. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17509. /**
  17510. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17511. * @param yaw defines the rotation around Y axis
  17512. * @param pitch defines the rotation around X axis
  17513. * @param roll defines the rotation around Z axis
  17514. * @param result defines the target quaternion
  17515. */
  17516. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17517. /**
  17518. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17519. * @param alpha defines the rotation around first axis
  17520. * @param beta defines the rotation around second axis
  17521. * @param gamma defines the rotation around third axis
  17522. * @returns the new quaternion
  17523. */
  17524. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17525. /**
  17526. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17527. * @param alpha defines the rotation around first axis
  17528. * @param beta defines the rotation around second axis
  17529. * @param gamma defines the rotation around third axis
  17530. * @param result defines the target quaternion
  17531. */
  17532. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17533. /**
  17534. * 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)
  17535. * @param axis1 defines the first axis
  17536. * @param axis2 defines the second axis
  17537. * @param axis3 defines the third axis
  17538. * @returns the new quaternion
  17539. */
  17540. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17541. /**
  17542. * 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
  17543. * @param axis1 defines the first axis
  17544. * @param axis2 defines the second axis
  17545. * @param axis3 defines the third axis
  17546. * @param ref defines the target quaternion
  17547. */
  17548. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17549. /**
  17550. * Interpolates between two quaternions
  17551. * @param left defines first quaternion
  17552. * @param right defines second quaternion
  17553. * @param amount defines the gradient to use
  17554. * @returns the new interpolated quaternion
  17555. */
  17556. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17557. /**
  17558. * Interpolates between two quaternions and stores it into a target quaternion
  17559. * @param left defines first quaternion
  17560. * @param right defines second quaternion
  17561. * @param amount defines the gradient to use
  17562. * @param result defines the target quaternion
  17563. */
  17564. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17565. /**
  17566. * Interpolate between two quaternions using Hermite interpolation
  17567. * @param value1 defines first quaternion
  17568. * @param tangent1 defines the incoming tangent
  17569. * @param value2 defines second quaternion
  17570. * @param tangent2 defines the outgoing tangent
  17571. * @param amount defines the target quaternion
  17572. * @returns the new interpolated quaternion
  17573. */
  17574. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17575. }
  17576. /**
  17577. * Class used to store matrix data (4x4)
  17578. */
  17579. class Matrix {
  17580. private static _tempQuaternion;
  17581. private static _xAxis;
  17582. private static _yAxis;
  17583. private static _zAxis;
  17584. private static _updateFlagSeed;
  17585. private static _identityReadOnly;
  17586. private _isIdentity;
  17587. private _isIdentityDirty;
  17588. /**
  17589. * Gets the update flag of the matrix which is an unique number for the matrix.
  17590. * It will be incremented every time the matrix data change.
  17591. * You can use it to speed the comparison between two versions of the same matrix.
  17592. */
  17593. updateFlag: number;
  17594. /**
  17595. * Gets or sets the internal data of the matrix
  17596. */
  17597. m: Float32Array;
  17598. /** @hidden */
  17599. _markAsUpdated(): void;
  17600. /**
  17601. * Creates an empty matrix (filled with zeros)
  17602. */
  17603. constructor();
  17604. /**
  17605. * Check if the current matrix is indentity
  17606. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17607. * @returns true is the matrix is the identity matrix
  17608. */
  17609. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17610. /**
  17611. * Gets the determinant of the matrix
  17612. * @returns the matrix determinant
  17613. */
  17614. determinant(): number;
  17615. /**
  17616. * Returns the matrix as a Float32Array
  17617. * @returns the matrix underlying array
  17618. */
  17619. toArray(): Float32Array;
  17620. /**
  17621. * Returns the matrix as a Float32Array
  17622. * @returns the matrix underlying array.
  17623. */
  17624. asArray(): Float32Array;
  17625. /**
  17626. * Inverts the current matrix in place
  17627. * @returns the current inverted matrix
  17628. */
  17629. invert(): Matrix;
  17630. /**
  17631. * Sets all the matrix elements to zero
  17632. * @returns the current matrix
  17633. */
  17634. reset(): Matrix;
  17635. /**
  17636. * Adds the current matrix with a second one
  17637. * @param other defines the matrix to add
  17638. * @returns a new matrix as the addition of the current matrix and the given one
  17639. */
  17640. add(other: Matrix): Matrix;
  17641. /**
  17642. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17643. * @param other defines the matrix to add
  17644. * @param result defines the target matrix
  17645. * @returns the current matrix
  17646. */
  17647. addToRef(other: Matrix, result: Matrix): Matrix;
  17648. /**
  17649. * Adds in place the given matrix to the current matrix
  17650. * @param other defines the second operand
  17651. * @returns the current updated matrix
  17652. */
  17653. addToSelf(other: Matrix): Matrix;
  17654. /**
  17655. * Sets the given matrix to the current inverted Matrix
  17656. * @param other defines the target matrix
  17657. * @returns the unmodified current matrix
  17658. */
  17659. invertToRef(other: Matrix): Matrix;
  17660. /**
  17661. * Inserts the translation vector (using 3 floats) in the current matrix
  17662. * @param x defines the 1st component of the translation
  17663. * @param y defines the 2nd component of the translation
  17664. * @param z defines the 3rd component of the translation
  17665. * @returns the current updated matrix
  17666. */
  17667. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17668. /**
  17669. * Inserts the translation vector in the current matrix
  17670. * @param vector3 defines the translation to insert
  17671. * @returns the current updated matrix
  17672. */
  17673. setTranslation(vector3: Vector3): Matrix;
  17674. /**
  17675. * Gets the translation value of the current matrix
  17676. * @returns a new Vector3 as the extracted translation from the matrix
  17677. */
  17678. getTranslation(): Vector3;
  17679. /**
  17680. * Fill a Vector3 with the extracted translation from the matrix
  17681. * @param result defines the Vector3 where to store the translation
  17682. * @returns the current matrix
  17683. */
  17684. getTranslationToRef(result: Vector3): Matrix;
  17685. /**
  17686. * Remove rotation and scaling part from the matrix
  17687. * @returns the updated matrix
  17688. */
  17689. removeRotationAndScaling(): Matrix;
  17690. /**
  17691. * Multiply two matrices
  17692. * @param other defines the second operand
  17693. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17694. */
  17695. multiply(other: Matrix): Matrix;
  17696. /**
  17697. * Copy the current matrix from the given one
  17698. * @param other defines the source matrix
  17699. * @returns the current updated matrix
  17700. */
  17701. copyFrom(other: Matrix): Matrix;
  17702. /**
  17703. * Populates the given array from the starting index with the current matrix values
  17704. * @param array defines the target array
  17705. * @param offset defines the offset in the target array where to start storing values
  17706. * @returns the current matrix
  17707. */
  17708. copyToArray(array: Float32Array, offset?: number): Matrix;
  17709. /**
  17710. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17711. * @param other defines the second operand
  17712. * @param result defines the matrix where to store the multiplication
  17713. * @returns the current matrix
  17714. */
  17715. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17716. /**
  17717. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17718. * @param other defines the second operand
  17719. * @param result defines the array where to store the multiplication
  17720. * @param offset defines the offset in the target array where to start storing values
  17721. * @returns the current matrix
  17722. */
  17723. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17724. /**
  17725. * Check equality between this matrix and a second one
  17726. * @param value defines the second matrix to compare
  17727. * @returns true is the current matrix and the given one values are strictly equal
  17728. */
  17729. equals(value: Matrix): boolean;
  17730. /**
  17731. * Clone the current matrix
  17732. * @returns a new matrix from the current matrix
  17733. */
  17734. clone(): Matrix;
  17735. /**
  17736. * Returns the name of the current matrix class
  17737. * @returns the string "Matrix"
  17738. */
  17739. getClassName(): string;
  17740. /**
  17741. * Gets the hash code of the current matrix
  17742. * @returns the hash code
  17743. */
  17744. getHashCode(): number;
  17745. /**
  17746. * Decomposes the current Matrix into a translation, rotation and scaling components
  17747. * @param scale defines the scale vector3 given as a reference to update
  17748. * @param rotation defines the rotation quaternion given as a reference to update
  17749. * @param translation defines the translation vector3 given as a reference to update
  17750. * @returns true if operation was successful
  17751. */
  17752. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17753. /**
  17754. * Gets specific row of the matrix
  17755. * @param index defines the number of the row to get
  17756. * @returns the index-th row of the current matrix as a new Vector4
  17757. */
  17758. getRow(index: number): Nullable<Vector4>;
  17759. /**
  17760. * Sets the index-th row of the current matrix to the vector4 values
  17761. * @param index defines the number of the row to set
  17762. * @param row defines the target vector4
  17763. * @returns the updated current matrix
  17764. */
  17765. setRow(index: number, row: Vector4): Matrix;
  17766. /**
  17767. * Compute the transpose of the matrix
  17768. * @returns the new transposed matrix
  17769. */
  17770. transpose(): Matrix;
  17771. /**
  17772. * Compute the transpose of the matrix and store it in a given matrix
  17773. * @param result defines the target matrix
  17774. * @returns the current matrix
  17775. */
  17776. transposeToRef(result: Matrix): Matrix;
  17777. /**
  17778. * Sets the index-th row of the current matrix with the given 4 x float values
  17779. * @param index defines the row index
  17780. * @param x defines the x component to set
  17781. * @param y defines the y component to set
  17782. * @param z defines the z component to set
  17783. * @param w defines the w component to set
  17784. * @returns the updated current matrix
  17785. */
  17786. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17787. /**
  17788. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17789. * @param scale defines the scale factor
  17790. * @returns a new matrix
  17791. */
  17792. scale(scale: number): Matrix;
  17793. /**
  17794. * Scale the current matrix values by a factor to a given result matrix
  17795. * @param scale defines the scale factor
  17796. * @param result defines the matrix to store the result
  17797. * @returns the current matrix
  17798. */
  17799. scaleToRef(scale: number, result: Matrix): Matrix;
  17800. /**
  17801. * Scale the current matrix values by a factor and add the result to a given matrix
  17802. * @param scale defines the scale factor
  17803. * @param result defines the Matrix to store the result
  17804. * @returns the current matrix
  17805. */
  17806. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17807. /**
  17808. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17809. * @param ref matrix to store the result
  17810. */
  17811. toNormalMatrix(ref: Matrix): void;
  17812. /**
  17813. * Gets only rotation part of the current matrix
  17814. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17815. */
  17816. getRotationMatrix(): Matrix;
  17817. /**
  17818. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17819. * @param result defines the target matrix to store data to
  17820. * @returns the current matrix
  17821. */
  17822. getRotationMatrixToRef(result: Matrix): Matrix;
  17823. /**
  17824. * Creates a matrix from an array
  17825. * @param array defines the source array
  17826. * @param offset defines an offset in the source array
  17827. * @returns a new Matrix set from the starting index of the given array
  17828. */
  17829. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17830. /**
  17831. * Copy the content of an array into a given matrix
  17832. * @param array defines the source array
  17833. * @param offset defines an offset in the source array
  17834. * @param result defines the target matrix
  17835. */
  17836. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17837. /**
  17838. * Stores an array into a matrix after having multiplied each component by a given factor
  17839. * @param array defines the source array
  17840. * @param offset defines the offset in the source array
  17841. * @param scale defines the scaling factor
  17842. * @param result defines the target matrix
  17843. */
  17844. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17845. /**
  17846. * Stores a list of values (16) inside a given matrix
  17847. * @param initialM11 defines 1st value of 1st row
  17848. * @param initialM12 defines 2nd value of 1st row
  17849. * @param initialM13 defines 3rd value of 1st row
  17850. * @param initialM14 defines 4th value of 1st row
  17851. * @param initialM21 defines 1st value of 2nd row
  17852. * @param initialM22 defines 2nd value of 2nd row
  17853. * @param initialM23 defines 3rd value of 2nd row
  17854. * @param initialM24 defines 4th value of 2nd row
  17855. * @param initialM31 defines 1st value of 3rd row
  17856. * @param initialM32 defines 2nd value of 3rd row
  17857. * @param initialM33 defines 3rd value of 3rd row
  17858. * @param initialM34 defines 4th value of 3rd row
  17859. * @param initialM41 defines 1st value of 4th row
  17860. * @param initialM42 defines 2nd value of 4th row
  17861. * @param initialM43 defines 3rd value of 4th row
  17862. * @param initialM44 defines 4th value of 4th row
  17863. * @param result defines the target matrix
  17864. */
  17865. 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;
  17866. /**
  17867. * Gets an identity matrix that must not be updated
  17868. */
  17869. static readonly IdentityReadOnly: Matrix;
  17870. /**
  17871. * Creates new matrix from a list of values (16)
  17872. * @param initialM11 defines 1st value of 1st row
  17873. * @param initialM12 defines 2nd value of 1st row
  17874. * @param initialM13 defines 3rd value of 1st row
  17875. * @param initialM14 defines 4th value of 1st row
  17876. * @param initialM21 defines 1st value of 2nd row
  17877. * @param initialM22 defines 2nd value of 2nd row
  17878. * @param initialM23 defines 3rd value of 2nd row
  17879. * @param initialM24 defines 4th value of 2nd row
  17880. * @param initialM31 defines 1st value of 3rd row
  17881. * @param initialM32 defines 2nd value of 3rd row
  17882. * @param initialM33 defines 3rd value of 3rd row
  17883. * @param initialM34 defines 4th value of 3rd row
  17884. * @param initialM41 defines 1st value of 4th row
  17885. * @param initialM42 defines 2nd value of 4th row
  17886. * @param initialM43 defines 3rd value of 4th row
  17887. * @param initialM44 defines 4th value of 4th row
  17888. * @returns the new matrix
  17889. */
  17890. 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;
  17891. /**
  17892. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17893. * @param scale defines the scale vector3
  17894. * @param rotation defines the rotation quaternion
  17895. * @param translation defines the translation vector3
  17896. * @returns a new matrix
  17897. */
  17898. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17899. /**
  17900. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17901. * @param scale defines the scale vector3
  17902. * @param rotation defines the rotation quaternion
  17903. * @param translation defines the translation vector3
  17904. * @param result defines the target matrix
  17905. */
  17906. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17907. /**
  17908. * Creates a new identity matrix
  17909. * @returns a new identity matrix
  17910. */
  17911. static Identity(): Matrix;
  17912. /**
  17913. * Creates a new identity matrix and stores the result in a given matrix
  17914. * @param result defines the target matrix
  17915. */
  17916. static IdentityToRef(result: Matrix): void;
  17917. /**
  17918. * Creates a new zero matrix
  17919. * @returns a new zero matrix
  17920. */
  17921. static Zero(): Matrix;
  17922. /**
  17923. * Creates a new rotation matrix for "angle" radians around the X axis
  17924. * @param angle defines the angle (in radians) to use
  17925. * @return the new matrix
  17926. */
  17927. static RotationX(angle: number): Matrix;
  17928. /**
  17929. * Creates a new matrix as the invert of a given matrix
  17930. * @param source defines the source matrix
  17931. * @returns the new matrix
  17932. */
  17933. static Invert(source: Matrix): Matrix;
  17934. /**
  17935. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17936. * @param angle defines the angle (in radians) to use
  17937. * @param result defines the target matrix
  17938. */
  17939. static RotationXToRef(angle: number, result: Matrix): void;
  17940. /**
  17941. * Creates a new rotation matrix for "angle" radians around the Y axis
  17942. * @param angle defines the angle (in radians) to use
  17943. * @return the new matrix
  17944. */
  17945. static RotationY(angle: number): Matrix;
  17946. /**
  17947. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17948. * @param angle defines the angle (in radians) to use
  17949. * @param result defines the target matrix
  17950. */
  17951. static RotationYToRef(angle: number, result: Matrix): void;
  17952. /**
  17953. * Creates a new rotation matrix for "angle" radians around the Z axis
  17954. * @param angle defines the angle (in radians) to use
  17955. * @return the new matrix
  17956. */
  17957. static RotationZ(angle: number): Matrix;
  17958. /**
  17959. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17960. * @param angle defines the angle (in radians) to use
  17961. * @param result defines the target matrix
  17962. */
  17963. static RotationZToRef(angle: number, result: Matrix): void;
  17964. /**
  17965. * Creates a new rotation matrix for "angle" radians around the given axis
  17966. * @param axis defines the axis to use
  17967. * @param angle defines the angle (in radians) to use
  17968. * @return the new matrix
  17969. */
  17970. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17971. /**
  17972. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17973. * @param axis defines the axis to use
  17974. * @param angle defines the angle (in radians) to use
  17975. * @param result defines the target matrix
  17976. */
  17977. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17978. /**
  17979. * Creates a rotation matrix
  17980. * @param yaw defines the yaw angle in radians (Y axis)
  17981. * @param pitch defines the pitch angle in radians (X axis)
  17982. * @param roll defines the roll angle in radians (X axis)
  17983. * @returns the new rotation matrix
  17984. */
  17985. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17986. /**
  17987. * Creates a rotation matrix and stores it in a given matrix
  17988. * @param yaw defines the yaw angle in radians (Y axis)
  17989. * @param pitch defines the pitch angle in radians (X axis)
  17990. * @param roll defines the roll angle in radians (X axis)
  17991. * @param result defines the target matrix
  17992. */
  17993. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17994. /**
  17995. * Creates a scaling matrix
  17996. * @param x defines the scale factor on X axis
  17997. * @param y defines the scale factor on Y axis
  17998. * @param z defines the scale factor on Z axis
  17999. * @returns the new matrix
  18000. */
  18001. static Scaling(x: number, y: number, z: number): Matrix;
  18002. /**
  18003. * Creates a scaling matrix and stores it in a given matrix
  18004. * @param x defines the scale factor on X axis
  18005. * @param y defines the scale factor on Y axis
  18006. * @param z defines the scale factor on Z axis
  18007. * @param result defines the target matrix
  18008. */
  18009. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18010. /**
  18011. * Creates a translation matrix
  18012. * @param x defines the translation on X axis
  18013. * @param y defines the translation on Y axis
  18014. * @param z defines the translationon Z axis
  18015. * @returns the new matrix
  18016. */
  18017. static Translation(x: number, y: number, z: number): Matrix;
  18018. /**
  18019. * Creates a translation matrix and stores it in a given matrix
  18020. * @param x defines the translation on X axis
  18021. * @param y defines the translation on Y axis
  18022. * @param z defines the translationon Z axis
  18023. * @param result defines the target matrix
  18024. */
  18025. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18026. /**
  18027. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18028. * @param startValue defines the start value
  18029. * @param endValue defines the end value
  18030. * @param gradient defines the gradient factor
  18031. * @returns the new matrix
  18032. */
  18033. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18034. /**
  18035. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18036. * @param startValue defines the start value
  18037. * @param endValue defines the end value
  18038. * @param gradient defines the gradient factor
  18039. * @param result defines the Matrix object where to store data
  18040. */
  18041. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18042. /**
  18043. * Builds a new matrix whose values are computed by:
  18044. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18045. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18046. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18047. * @param startValue defines the first matrix
  18048. * @param endValue defines the second matrix
  18049. * @param gradient defines the gradient between the two matrices
  18050. * @returns the new matrix
  18051. */
  18052. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18053. /**
  18054. * Update a matrix to values which are computed by:
  18055. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18056. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18057. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18058. * @param startValue defines the first matrix
  18059. * @param endValue defines the second matrix
  18060. * @param gradient defines the gradient between the two matrices
  18061. * @param result defines the target matrix
  18062. */
  18063. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18064. /**
  18065. * 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"
  18066. * This function works in left handed mode
  18067. * @param eye defines the final position of the entity
  18068. * @param target defines where the entity should look at
  18069. * @param up defines the up vector for the entity
  18070. * @returns the new matrix
  18071. */
  18072. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18073. /**
  18074. * 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".
  18075. * This function works in left handed mode
  18076. * @param eye defines the final position of the entity
  18077. * @param target defines where the entity should look at
  18078. * @param up defines the up vector for the entity
  18079. * @param result defines the target matrix
  18080. */
  18081. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18082. /**
  18083. * 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"
  18084. * This function works in right handed mode
  18085. * @param eye defines the final position of the entity
  18086. * @param target defines where the entity should look at
  18087. * @param up defines the up vector for the entity
  18088. * @returns the new matrix
  18089. */
  18090. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18091. /**
  18092. * 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".
  18093. * This function works in right handed mode
  18094. * @param eye defines the final position of the entity
  18095. * @param target defines where the entity should look at
  18096. * @param up defines the up vector for the entity
  18097. * @param result defines the target matrix
  18098. */
  18099. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18100. /**
  18101. * Create a left-handed orthographic projection matrix
  18102. * @param width defines the viewport width
  18103. * @param height defines the viewport height
  18104. * @param znear defines the near clip plane
  18105. * @param zfar defines the far clip plane
  18106. * @returns a new matrix as a left-handed orthographic projection matrix
  18107. */
  18108. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18109. /**
  18110. * Store a left-handed orthographic projection to a given matrix
  18111. * @param width defines the viewport width
  18112. * @param height defines the viewport height
  18113. * @param znear defines the near clip plane
  18114. * @param zfar defines the far clip plane
  18115. * @param result defines the target matrix
  18116. */
  18117. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18118. /**
  18119. * Create a left-handed orthographic projection matrix
  18120. * @param left defines the viewport left coordinate
  18121. * @param right defines the viewport right coordinate
  18122. * @param bottom defines the viewport bottom coordinate
  18123. * @param top defines the viewport top coordinate
  18124. * @param znear defines the near clip plane
  18125. * @param zfar defines the far clip plane
  18126. * @returns a new matrix as a left-handed orthographic projection matrix
  18127. */
  18128. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18129. /**
  18130. * Stores a left-handed orthographic projection into a given matrix
  18131. * @param left defines the viewport left coordinate
  18132. * @param right defines the viewport right coordinate
  18133. * @param bottom defines the viewport bottom coordinate
  18134. * @param top defines the viewport top coordinate
  18135. * @param znear defines the near clip plane
  18136. * @param zfar defines the far clip plane
  18137. * @param result defines the target matrix
  18138. */
  18139. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18140. /**
  18141. * Creates a right-handed orthographic projection matrix
  18142. * @param left defines the viewport left coordinate
  18143. * @param right defines the viewport right coordinate
  18144. * @param bottom defines the viewport bottom coordinate
  18145. * @param top defines the viewport top coordinate
  18146. * @param znear defines the near clip plane
  18147. * @param zfar defines the far clip plane
  18148. * @returns a new matrix as a right-handed orthographic projection matrix
  18149. */
  18150. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18151. /**
  18152. * Stores a right-handed orthographic projection into a given matrix
  18153. * @param left defines the viewport left coordinate
  18154. * @param right defines the viewport right coordinate
  18155. * @param bottom defines the viewport bottom coordinate
  18156. * @param top defines the viewport top coordinate
  18157. * @param znear defines the near clip plane
  18158. * @param zfar defines the far clip plane
  18159. * @param result defines the target matrix
  18160. */
  18161. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18162. /**
  18163. * Creates a left-handed perspective projection matrix
  18164. * @param width defines the viewport width
  18165. * @param height defines the viewport height
  18166. * @param znear defines the near clip plane
  18167. * @param zfar defines the far clip plane
  18168. * @returns a new matrix as a left-handed perspective projection matrix
  18169. */
  18170. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18171. /**
  18172. * Creates a left-handed perspective projection matrix
  18173. * @param fov defines the horizontal field of view
  18174. * @param aspect defines the aspect ratio
  18175. * @param znear defines the near clip plane
  18176. * @param zfar defines the far clip plane
  18177. * @returns a new matrix as a left-handed perspective projection matrix
  18178. */
  18179. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18180. /**
  18181. * Stores a left-handed perspective projection into a given matrix
  18182. * @param fov defines the horizontal field of view
  18183. * @param aspect defines the aspect ratio
  18184. * @param znear defines the near clip plane
  18185. * @param zfar defines the far clip plane
  18186. * @param result defines the target matrix
  18187. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18188. */
  18189. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18190. /**
  18191. * Creates a right-handed perspective projection matrix
  18192. * @param fov defines the horizontal field of view
  18193. * @param aspect defines the aspect ratio
  18194. * @param znear defines the near clip plane
  18195. * @param zfar defines the far clip plane
  18196. * @returns a new matrix as a right-handed perspective projection matrix
  18197. */
  18198. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18199. /**
  18200. * Stores a right-handed perspective projection into a given matrix
  18201. * @param fov defines the horizontal field of view
  18202. * @param aspect defines the aspect ratio
  18203. * @param znear defines the near clip plane
  18204. * @param zfar defines the far clip plane
  18205. * @param result defines the target matrix
  18206. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18207. */
  18208. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18209. /**
  18210. * Stores a perspective projection for WebVR info a given matrix
  18211. * @param fov defines the field of view
  18212. * @param znear defines the near clip plane
  18213. * @param zfar defines the far clip plane
  18214. * @param result defines the target matrix
  18215. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18216. */
  18217. static PerspectiveFovWebVRToRef(fov: {
  18218. upDegrees: number;
  18219. downDegrees: number;
  18220. leftDegrees: number;
  18221. rightDegrees: number;
  18222. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18223. /**
  18224. * Computes a complete transformation matrix
  18225. * @param viewport defines the viewport to use
  18226. * @param world defines the world matrix
  18227. * @param view defines the view matrix
  18228. * @param projection defines the projection matrix
  18229. * @param zmin defines the near clip plane
  18230. * @param zmax defines the far clip plane
  18231. * @returns the transformation matrix
  18232. */
  18233. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18234. /**
  18235. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18236. * @param matrix defines the matrix to use
  18237. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18238. */
  18239. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18240. /**
  18241. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18242. * @param matrix defines the matrix to use
  18243. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18244. */
  18245. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18246. /**
  18247. * Compute the transpose of a given matrix
  18248. * @param matrix defines the matrix to transpose
  18249. * @returns the new matrix
  18250. */
  18251. static Transpose(matrix: Matrix): Matrix;
  18252. /**
  18253. * Compute the transpose of a matrix and store it in a target matrix
  18254. * @param matrix defines the matrix to transpose
  18255. * @param result defines the target matrix
  18256. */
  18257. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18258. /**
  18259. * Computes a reflection matrix from a plane
  18260. * @param plane defines the reflection plane
  18261. * @returns a new matrix
  18262. */
  18263. static Reflection(plane: Plane): Matrix;
  18264. /**
  18265. * Computes a reflection matrix from a plane
  18266. * @param plane defines the reflection plane
  18267. * @param result defines the target matrix
  18268. */
  18269. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18270. /**
  18271. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18272. * @param xaxis defines the value of the 1st axis
  18273. * @param yaxis defines the value of the 2nd axis
  18274. * @param zaxis defines the value of the 3rd axis
  18275. * @param result defines the target matrix
  18276. */
  18277. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18278. /**
  18279. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18280. * @param quat defines the quaternion to use
  18281. * @param result defines the target matrix
  18282. */
  18283. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18284. }
  18285. class Plane {
  18286. normal: Vector3;
  18287. d: number;
  18288. /**
  18289. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18290. */
  18291. constructor(a: number, b: number, c: number, d: number);
  18292. /**
  18293. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18294. */
  18295. asArray(): number[];
  18296. /**
  18297. * Returns a new plane copied from the current Plane.
  18298. */
  18299. clone(): Plane;
  18300. /**
  18301. * Returns the string "Plane".
  18302. */
  18303. getClassName(): string;
  18304. /**
  18305. * Returns the Plane hash code.
  18306. */
  18307. getHashCode(): number;
  18308. /**
  18309. * Normalize the current Plane in place.
  18310. * Returns the updated Plane.
  18311. */
  18312. normalize(): Plane;
  18313. /**
  18314. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18315. */
  18316. transform(transformation: Matrix): Plane;
  18317. /**
  18318. * Returns the dot product (float) of the point coordinates and the plane normal.
  18319. */
  18320. dotCoordinate(point: Vector3): number;
  18321. /**
  18322. * Updates the current Plane from the plane defined by the three given points.
  18323. * Returns the updated Plane.
  18324. */
  18325. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18326. /**
  18327. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18328. */
  18329. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18330. /**
  18331. * Returns the signed distance (float) from the given point to the Plane.
  18332. */
  18333. signedDistanceTo(point: Vector3): number;
  18334. /**
  18335. * Returns a new Plane from the given array.
  18336. */
  18337. static FromArray(array: ArrayLike<number>): Plane;
  18338. /**
  18339. * Returns a new Plane defined by the three given points.
  18340. */
  18341. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18342. /**
  18343. * Returns a new Plane the normal vector to this plane at the given origin point.
  18344. * Note : the vector "normal" is updated because normalized.
  18345. */
  18346. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18347. /**
  18348. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18349. */
  18350. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18351. }
  18352. class Viewport {
  18353. x: number;
  18354. y: number;
  18355. width: number;
  18356. height: number;
  18357. /**
  18358. * Creates a Viewport object located at (x, y) and sized (width, height).
  18359. */
  18360. constructor(x: number, y: number, width: number, height: number);
  18361. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18362. /**
  18363. * Returns a new Viewport copied from the current one.
  18364. */
  18365. clone(): Viewport;
  18366. }
  18367. class Frustum {
  18368. /**
  18369. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18370. */
  18371. static GetPlanes(transform: Matrix): Plane[];
  18372. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18373. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18374. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18375. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18376. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18377. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18378. /**
  18379. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18380. */
  18381. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18382. }
  18383. /** Defines supported spaces */
  18384. enum Space {
  18385. /** Local (object) space */
  18386. LOCAL = 0,
  18387. /** World space */
  18388. WORLD = 1,
  18389. /** Bone space */
  18390. BONE = 2,
  18391. }
  18392. /** Defines the 3 main axes */
  18393. class Axis {
  18394. /** X axis */
  18395. static X: Vector3;
  18396. /** Y axis */
  18397. static Y: Vector3;
  18398. /** Z axis */
  18399. static Z: Vector3;
  18400. }
  18401. class BezierCurve {
  18402. /**
  18403. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18404. */
  18405. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18406. }
  18407. /**
  18408. * Defines potential orientation for back face culling
  18409. */
  18410. enum Orientation {
  18411. /**
  18412. * Clockwise
  18413. */
  18414. CW = 0,
  18415. /** Counter clockwise */
  18416. CCW = 1,
  18417. }
  18418. /**
  18419. * Defines angle representation
  18420. */
  18421. class Angle {
  18422. private _radians;
  18423. /**
  18424. * Creates an Angle object of "radians" radians (float).
  18425. */
  18426. constructor(radians: number);
  18427. /**
  18428. * Get value in degrees
  18429. * @returns the Angle value in degrees (float)
  18430. */
  18431. degrees(): number;
  18432. /**
  18433. * Get value in radians
  18434. * @returns the Angle value in radians (float)
  18435. */
  18436. radians(): number;
  18437. /**
  18438. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18439. * @param a defines first vector
  18440. * @param b defines second vector
  18441. * @returns a new Angle
  18442. */
  18443. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18444. /**
  18445. * Gets a new Angle object from the given float in radians
  18446. * @param radians defines the angle value in radians
  18447. * @returns a new Angle
  18448. */
  18449. static FromRadians(radians: number): Angle;
  18450. /**
  18451. * Gets a new Angle object from the given float in degrees
  18452. * @param degrees defines the angle value in degrees
  18453. * @returns a new Angle
  18454. */
  18455. static FromDegrees(degrees: number): Angle;
  18456. }
  18457. class Arc2 {
  18458. startPoint: Vector2;
  18459. midPoint: Vector2;
  18460. endPoint: Vector2;
  18461. centerPoint: Vector2;
  18462. radius: number;
  18463. angle: Angle;
  18464. startAngle: Angle;
  18465. orientation: Orientation;
  18466. /**
  18467. * Creates an Arc object from the three given points : start, middle and end.
  18468. */
  18469. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18470. }
  18471. class Path2 {
  18472. private _points;
  18473. private _length;
  18474. closed: boolean;
  18475. /**
  18476. * Creates a Path2 object from the starting 2D coordinates x and y.
  18477. */
  18478. constructor(x: number, y: number);
  18479. /**
  18480. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18481. * Returns the updated Path2.
  18482. */
  18483. addLineTo(x: number, y: number): Path2;
  18484. /**
  18485. * 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.
  18486. * Returns the updated Path2.
  18487. */
  18488. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18489. /**
  18490. * Closes the Path2.
  18491. * Returns the Path2.
  18492. */
  18493. close(): Path2;
  18494. /**
  18495. * Returns the Path2 total length (float).
  18496. */
  18497. length(): number;
  18498. /**
  18499. * Returns the Path2 internal array of points.
  18500. */
  18501. getPoints(): Vector2[];
  18502. /**
  18503. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18504. */
  18505. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18506. /**
  18507. * Returns a new Path2 starting at the coordinates (x, y).
  18508. */
  18509. static StartingAt(x: number, y: number): Path2;
  18510. }
  18511. class Path3D {
  18512. path: Vector3[];
  18513. private _curve;
  18514. private _distances;
  18515. private _tangents;
  18516. private _normals;
  18517. private _binormals;
  18518. private _raw;
  18519. /**
  18520. * new Path3D(path, normal, raw)
  18521. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18522. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18523. * path : an array of Vector3, the curve axis of the Path3D
  18524. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18525. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18526. */
  18527. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18528. /**
  18529. * Returns the Path3D array of successive Vector3 designing its curve.
  18530. */
  18531. getCurve(): Vector3[];
  18532. /**
  18533. * Returns an array populated with tangent vectors on each Path3D curve point.
  18534. */
  18535. getTangents(): Vector3[];
  18536. /**
  18537. * Returns an array populated with normal vectors on each Path3D curve point.
  18538. */
  18539. getNormals(): Vector3[];
  18540. /**
  18541. * Returns an array populated with binormal vectors on each Path3D curve point.
  18542. */
  18543. getBinormals(): Vector3[];
  18544. /**
  18545. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18546. */
  18547. getDistances(): number[];
  18548. /**
  18549. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18550. * Returns the same object updated.
  18551. */
  18552. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18553. private _compute(firstNormal);
  18554. private _getFirstNonNullVector(index);
  18555. private _getLastNonNullVector(index);
  18556. private _normalVector(v0, vt, va);
  18557. }
  18558. class Curve3 {
  18559. private _points;
  18560. private _length;
  18561. /**
  18562. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18563. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18564. * @param v1 (Vector3) the control point
  18565. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18566. * @param nbPoints (integer) the wanted number of points in the curve
  18567. */
  18568. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18569. /**
  18570. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18571. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18572. * @param v1 (Vector3) the first control point
  18573. * @param v2 (Vector3) the second control point
  18574. * @param v3 (Vector3) the end point of the Cubic Bezier
  18575. * @param nbPoints (integer) the wanted number of points in the curve
  18576. */
  18577. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18578. /**
  18579. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18580. * @param p1 (Vector3) the origin point of the Hermite Spline
  18581. * @param t1 (Vector3) the tangent vector at the origin point
  18582. * @param p2 (Vector3) the end point of the Hermite Spline
  18583. * @param t2 (Vector3) the tangent vector at the end point
  18584. * @param nbPoints (integer) the wanted number of points in the curve
  18585. */
  18586. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18587. /**
  18588. * Returns a Curve3 object along a CatmullRom Spline curve :
  18589. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18590. * @param nbPoints (integer) the wanted number of points between each curve control points
  18591. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18592. */
  18593. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18594. /**
  18595. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18596. * A Curve3 is designed from a series of successive Vector3.
  18597. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18598. */
  18599. constructor(points: Vector3[]);
  18600. /**
  18601. * Returns the Curve3 stored array of successive Vector3
  18602. */
  18603. getPoints(): Vector3[];
  18604. /**
  18605. * Returns the computed length (float) of the curve.
  18606. */
  18607. length(): number;
  18608. /**
  18609. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18610. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18611. * curveA and curveB keep unchanged.
  18612. */
  18613. continue(curve: Curve3): Curve3;
  18614. private _computeLength(path);
  18615. }
  18616. class PositionNormalVertex {
  18617. position: Vector3;
  18618. normal: Vector3;
  18619. constructor(position?: Vector3, normal?: Vector3);
  18620. clone(): PositionNormalVertex;
  18621. }
  18622. class PositionNormalTextureVertex {
  18623. position: Vector3;
  18624. normal: Vector3;
  18625. uv: Vector2;
  18626. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18627. clone(): PositionNormalTextureVertex;
  18628. }
  18629. class Tmp {
  18630. static Color3: Color3[];
  18631. static Color4: Color4[];
  18632. static Vector2: Vector2[];
  18633. static Vector3: Vector3[];
  18634. static Vector4: Vector4[];
  18635. static Quaternion: Quaternion[];
  18636. static Matrix: Matrix[];
  18637. }
  18638. }
  18639. declare module BABYLON {
  18640. /**
  18641. * Class representing spherical polynomial coefficients to the 3rd degree
  18642. */
  18643. class SphericalPolynomial {
  18644. /**
  18645. * The x coefficients of the spherical polynomial
  18646. */
  18647. x: Vector3;
  18648. /**
  18649. * The y coefficients of the spherical polynomial
  18650. */
  18651. y: Vector3;
  18652. /**
  18653. * The z coefficients of the spherical polynomial
  18654. */
  18655. z: Vector3;
  18656. /**
  18657. * The xx coefficients of the spherical polynomial
  18658. */
  18659. xx: Vector3;
  18660. /**
  18661. * The yy coefficients of the spherical polynomial
  18662. */
  18663. yy: Vector3;
  18664. /**
  18665. * The zz coefficients of the spherical polynomial
  18666. */
  18667. zz: Vector3;
  18668. /**
  18669. * The xy coefficients of the spherical polynomial
  18670. */
  18671. xy: Vector3;
  18672. /**
  18673. * The yz coefficients of the spherical polynomial
  18674. */
  18675. yz: Vector3;
  18676. /**
  18677. * The zx coefficients of the spherical polynomial
  18678. */
  18679. zx: Vector3;
  18680. /**
  18681. * Adds an ambient color to the spherical polynomial
  18682. * @param color the color to add
  18683. */
  18684. addAmbient(color: Color3): void;
  18685. /**
  18686. * Scales the spherical polynomial by the given amount
  18687. * @param scale the amount to scale
  18688. */
  18689. scale(scale: number): void;
  18690. /**
  18691. * Gets the spherical polynomial from harmonics
  18692. * @param harmonics the spherical harmonics
  18693. * @returns the spherical polynomial
  18694. */
  18695. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18696. /**
  18697. * Constructs a spherical polynomial from an array.
  18698. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18699. * @returns the spherical polynomial
  18700. */
  18701. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18702. }
  18703. /**
  18704. * Class representing spherical harmonics coefficients to the 3rd degree
  18705. */
  18706. class SphericalHarmonics {
  18707. /**
  18708. * The l0,0 coefficients of the spherical harmonics
  18709. */
  18710. l00: Vector3;
  18711. /**
  18712. * The l1,-1 coefficients of the spherical harmonics
  18713. */
  18714. l1_1: Vector3;
  18715. /**
  18716. * The l1,0 coefficients of the spherical harmonics
  18717. */
  18718. l10: Vector3;
  18719. /**
  18720. * The l1,1 coefficients of the spherical harmonics
  18721. */
  18722. l11: Vector3;
  18723. /**
  18724. * The l2,-2 coefficients of the spherical harmonics
  18725. */
  18726. l2_2: Vector3;
  18727. /**
  18728. * The l2,-1 coefficients of the spherical harmonics
  18729. */
  18730. l2_1: Vector3;
  18731. /**
  18732. * The l2,0 coefficients of the spherical harmonics
  18733. */
  18734. l20: Vector3;
  18735. /**
  18736. * The l2,1 coefficients of the spherical harmonics
  18737. */
  18738. l21: Vector3;
  18739. /**
  18740. * The l2,2 coefficients of the spherical harmonics
  18741. */
  18742. lL22: Vector3;
  18743. /**
  18744. * Adds a light to the spherical harmonics
  18745. * @param direction the direction of the light
  18746. * @param color the color of the light
  18747. * @param deltaSolidAngle the delta solid angle of the light
  18748. */
  18749. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18750. /**
  18751. * Scales the spherical harmonics by the given amount
  18752. * @param scale the amount to scale
  18753. */
  18754. scale(scale: number): void;
  18755. /**
  18756. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  18757. *
  18758. * ```
  18759. * E_lm = A_l * L_lm
  18760. * ```
  18761. *
  18762. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  18763. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  18764. * the scaling factors are given in equation 9.
  18765. */
  18766. convertIncidentRadianceToIrradiance(): void;
  18767. /**
  18768. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  18769. *
  18770. * ```
  18771. * L = (1/pi) * E * rho
  18772. * ```
  18773. *
  18774. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  18775. */
  18776. convertIrradianceToLambertianRadiance(): void;
  18777. /**
  18778. * Gets the spherical harmonics from polynomial
  18779. * @param polynomial the spherical polynomial
  18780. * @returns the spherical harmonics
  18781. */
  18782. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18783. /**
  18784. * Constructs a spherical harmonics from an array.
  18785. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  18786. * @returns the spherical harmonics
  18787. */
  18788. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  18789. }
  18790. }
  18791. declare module BABYLON {
  18792. /**
  18793. * Class used to store all common mesh properties
  18794. */
  18795. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18796. /** No occlusion */
  18797. static OCCLUSION_TYPE_NONE: number;
  18798. /** Occlusion set to optimisitic */
  18799. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18800. /** Occlusion set to strict */
  18801. static OCCLUSION_TYPE_STRICT: number;
  18802. /** Use an accurante occlusion algorithm */
  18803. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18804. /** Use a conservative occlusion algorithm */
  18805. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18806. /**
  18807. * No billboard
  18808. */
  18809. static readonly BILLBOARDMODE_NONE: number;
  18810. /** Billboard on X axis */
  18811. static readonly BILLBOARDMODE_X: number;
  18812. /** Billboard on Y axis */
  18813. static readonly BILLBOARDMODE_Y: number;
  18814. /** Billboard on Z axis */
  18815. static readonly BILLBOARDMODE_Z: number;
  18816. /** Billboard on all axes */
  18817. static readonly BILLBOARDMODE_ALL: number;
  18818. private _facetPositions;
  18819. private _facetNormals;
  18820. private _facetPartitioning;
  18821. private _facetNb;
  18822. private _partitioningSubdivisions;
  18823. private _partitioningBBoxRatio;
  18824. private _facetDataEnabled;
  18825. private _facetParameters;
  18826. private _bbSize;
  18827. private _subDiv;
  18828. private _facetDepthSort;
  18829. private _facetDepthSortEnabled;
  18830. private _depthSortedIndices;
  18831. private _depthSortedFacets;
  18832. private _facetDepthSortFunction;
  18833. private _facetDepthSortFrom;
  18834. private _facetDepthSortOrigin;
  18835. private _invertedMatrix;
  18836. /**
  18837. * Gets the number of facets in the mesh
  18838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18839. */
  18840. readonly facetNb: number;
  18841. /**
  18842. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18844. */
  18845. partitioningSubdivisions: number;
  18846. /**
  18847. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18848. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18850. */
  18851. partitioningBBoxRatio: number;
  18852. /**
  18853. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18854. * Works only for updatable meshes.
  18855. * Doesn't work with multi-materials
  18856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18857. */
  18858. mustDepthSortFacets: boolean;
  18859. /**
  18860. * The location (Vector3) where the facet depth sort must be computed from.
  18861. * By default, the active camera position.
  18862. * Used only when facet depth sort is enabled
  18863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18864. */
  18865. facetDepthSortFrom: Vector3;
  18866. /**
  18867. * gets a boolean indicating if facetData is enabled
  18868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18869. */
  18870. readonly isFacetDataEnabled: boolean;
  18871. /** @hidden */
  18872. _updateNonUniformScalingState(value: boolean): boolean;
  18873. /**
  18874. * An event triggered when this mesh collides with another one
  18875. */
  18876. onCollideObservable: Observable<AbstractMesh>;
  18877. private _onCollideObserver;
  18878. /** Set a function to call when this mesh collides with another one */
  18879. onCollide: () => void;
  18880. /**
  18881. * An event triggered when the collision's position changes
  18882. */
  18883. onCollisionPositionChangeObservable: Observable<Vector3>;
  18884. private _onCollisionPositionChangeObserver;
  18885. /** Set a function to call when the collision's position changes */
  18886. onCollisionPositionChange: () => void;
  18887. /**
  18888. * An event triggered when material is changed
  18889. */
  18890. onMaterialChangedObservable: Observable<AbstractMesh>;
  18891. /**
  18892. * Gets or sets the orientation for POV movement & rotation
  18893. */
  18894. definedFacingForward: boolean;
  18895. /**
  18896. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18897. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18898. * * 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.
  18899. * @see http://doc.babylonjs.com/features/occlusionquery
  18900. */
  18901. occlusionQueryAlgorithmType: number;
  18902. /**
  18903. * 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:
  18904. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18905. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18906. * * 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.
  18907. * @see http://doc.babylonjs.com/features/occlusionquery
  18908. */
  18909. occlusionType: number;
  18910. /**
  18911. * 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.
  18912. * The default value is -1 which means don't break the query and wait till the result
  18913. * @see http://doc.babylonjs.com/features/occlusionquery
  18914. */
  18915. occlusionRetryCount: number;
  18916. private _occlusionInternalRetryCounter;
  18917. protected _isOccluded: boolean;
  18918. /**
  18919. * 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
  18920. * @see http://doc.babylonjs.com/features/occlusionquery
  18921. */
  18922. isOccluded: boolean;
  18923. private _isOcclusionQueryInProgress;
  18924. /**
  18925. * Flag to check the progress status of the query
  18926. * @see http://doc.babylonjs.com/features/occlusionquery
  18927. */
  18928. readonly isOcclusionQueryInProgress: boolean;
  18929. private _occlusionQuery;
  18930. private _visibility;
  18931. /**
  18932. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18933. */
  18934. /**
  18935. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18936. */
  18937. visibility: number;
  18938. /** Gets or sets the alpha index used to sort transparent meshes
  18939. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18940. */
  18941. alphaIndex: number;
  18942. /**
  18943. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18944. */
  18945. isVisible: boolean;
  18946. /**
  18947. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18948. */
  18949. isPickable: boolean;
  18950. /**
  18951. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18952. */
  18953. showBoundingBox: boolean;
  18954. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18955. showSubMeshesBoundingBox: boolean;
  18956. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18958. */
  18959. isBlocker: boolean;
  18960. /**
  18961. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18962. */
  18963. enablePointerMoveEvents: boolean;
  18964. /**
  18965. * Specifies the rendering group id for this mesh (0 by default)
  18966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18967. */
  18968. renderingGroupId: number;
  18969. private _material;
  18970. /** Gets or sets current material */
  18971. material: Nullable<Material>;
  18972. private _receiveShadows;
  18973. /**
  18974. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18975. * @see http://doc.babylonjs.com/babylon101/shadows
  18976. */
  18977. receiveShadows: boolean;
  18978. /**
  18979. * Gets or sets a boolean indicating if the outline must be rendered as well
  18980. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18981. */
  18982. renderOutline: boolean;
  18983. /** Defines color to use when rendering outline */
  18984. outlineColor: Color3;
  18985. /** Define width to use when rendering outline */
  18986. outlineWidth: number;
  18987. /**
  18988. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18989. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18990. */
  18991. renderOverlay: boolean;
  18992. /** Defines color to use when rendering overlay */
  18993. overlayColor: Color3;
  18994. /** Defines alpha to use when rendering overlay */
  18995. overlayAlpha: number;
  18996. private _hasVertexAlpha;
  18997. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18998. hasVertexAlpha: boolean;
  18999. private _useVertexColors;
  19000. /** 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) */
  19001. useVertexColors: boolean;
  19002. private _computeBonesUsingShaders;
  19003. /**
  19004. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19005. */
  19006. computeBonesUsingShaders: boolean;
  19007. private _numBoneInfluencers;
  19008. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19009. numBoneInfluencers: number;
  19010. private _applyFog;
  19011. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19012. applyFog: boolean;
  19013. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19014. useOctreeForRenderingSelection: boolean;
  19015. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19016. useOctreeForPicking: boolean;
  19017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19018. useOctreeForCollisions: boolean;
  19019. private _layerMask;
  19020. /**
  19021. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19022. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19023. */
  19024. layerMask: number;
  19025. /**
  19026. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19027. */
  19028. alwaysSelectAsActiveMesh: boolean;
  19029. /**
  19030. * Gets or sets the current action manager
  19031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19032. */
  19033. actionManager: Nullable<ActionManager>;
  19034. /**
  19035. * Gets or sets impostor used for physic simulation
  19036. * @see http://doc.babylonjs.com/features/physics_engine
  19037. */
  19038. physicsImpostor: Nullable<PhysicsImpostor>;
  19039. private _checkCollisions;
  19040. private _collisionMask;
  19041. private _collisionGroup;
  19042. /**
  19043. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19045. */
  19046. ellipsoid: Vector3;
  19047. /**
  19048. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19050. */
  19051. ellipsoidOffset: Vector3;
  19052. private _collider;
  19053. private _oldPositionForCollisions;
  19054. private _diffPositionForCollisions;
  19055. /**
  19056. * Gets or sets a collision mask used to mask collisions (default is -1).
  19057. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19058. */
  19059. collisionMask: number;
  19060. /**
  19061. * Gets or sets the current collision group mask (-1 by default).
  19062. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19063. */
  19064. collisionGroup: number;
  19065. /**
  19066. * Defines edge width used when edgesRenderer is enabled
  19067. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19068. */
  19069. edgesWidth: number;
  19070. /**
  19071. * Defines edge color used when edgesRenderer is enabled
  19072. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19073. */
  19074. edgesColor: Color4;
  19075. /** @hidden */
  19076. _edgesRenderer: Nullable<EdgesRenderer>;
  19077. private _collisionsTransformMatrix;
  19078. private _collisionsScalingMatrix;
  19079. /** @hidden */
  19080. _masterMesh: Nullable<AbstractMesh>;
  19081. /** @hidden */
  19082. _boundingInfo: Nullable<BoundingInfo>;
  19083. /** @hidden */
  19084. _renderId: number;
  19085. /**
  19086. * Gets or sets the list of subMeshes
  19087. * @see http://doc.babylonjs.com/how_to/multi_materials
  19088. */
  19089. subMeshes: SubMesh[];
  19090. /** @hidden */
  19091. _submeshesOctree: Octree<SubMesh>;
  19092. /** @hidden */
  19093. _intersectionsInProgress: AbstractMesh[];
  19094. /** @hidden */
  19095. _unIndexed: boolean;
  19096. /** @hidden */
  19097. _lightSources: Light[];
  19098. /** @hidden */
  19099. readonly _positions: Nullable<Vector3[]>;
  19100. /** @hidden */
  19101. _waitingActions: any;
  19102. /** @hidden */
  19103. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19104. private _skeleton;
  19105. /** @hidden */
  19106. _bonesTransformMatrices: Nullable<Float32Array>;
  19107. /**
  19108. * Gets or sets a skeleton to apply skining transformations
  19109. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19110. */
  19111. skeleton: Nullable<Skeleton>;
  19112. /**
  19113. * Creates a new AbstractMesh
  19114. * @param name defines the name of the mesh
  19115. * @param scene defines the hosting scene
  19116. */
  19117. constructor(name: string, scene?: Nullable<Scene>);
  19118. /**
  19119. * Returns the string "AbstractMesh"
  19120. * @returns "AbstractMesh"
  19121. */
  19122. getClassName(): string;
  19123. /**
  19124. * Gets a string representation of the current mesh
  19125. * @param fullDetails defines a boolean indicating if full details must be included
  19126. * @returns a string representation of the current mesh
  19127. */
  19128. toString(fullDetails?: boolean): string;
  19129. /** @hidden */
  19130. _rebuild(): void;
  19131. /** @hidden */
  19132. _resyncLightSources(): void;
  19133. /** @hidden */
  19134. _resyncLighSource(light: Light): void;
  19135. /** @hidden */
  19136. _unBindEffect(): void;
  19137. /** @hidden */
  19138. _removeLightSource(light: Light): void;
  19139. private _markSubMeshesAsDirty(func);
  19140. /** @hidden */
  19141. _markSubMeshesAsLightDirty(): void;
  19142. /** @hidden */
  19143. _markSubMeshesAsAttributesDirty(): void;
  19144. /** @hidden */
  19145. _markSubMeshesAsMiscDirty(): void;
  19146. /**
  19147. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19148. */
  19149. scaling: Vector3;
  19150. /**
  19151. * Disables the mesh edge rendering mode
  19152. * @returns the currentAbstractMesh
  19153. */
  19154. disableEdgesRendering(): AbstractMesh;
  19155. /**
  19156. * Enables the edge rendering mode on the mesh.
  19157. * This mode makes the mesh edges visible
  19158. * @param epsilon defines the maximal distance between two angles to detect a face
  19159. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19160. * @returns the currentAbstractMesh
  19161. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19162. */
  19163. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19164. /**
  19165. * Gets the edgesRenderer associated with the mesh
  19166. */
  19167. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19168. /**
  19169. * Returns true if the mesh is blocked. Implemented by child classes
  19170. */
  19171. readonly isBlocked: boolean;
  19172. /**
  19173. * Returns the mesh itself by default. Implemented by child classes
  19174. * @param camera defines the camera to use to pick the right LOD level
  19175. * @returns the currentAbstractMesh
  19176. */
  19177. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19178. /**
  19179. * Returns 0 by default. Implemented by child classes
  19180. * @returns an integer
  19181. */
  19182. getTotalVertices(): number;
  19183. /**
  19184. * Returns null by default. Implemented by child classes
  19185. * @returns null
  19186. */
  19187. getIndices(): Nullable<IndicesArray>;
  19188. /**
  19189. * Returns the array of the requested vertex data kind. Implemented by child classes
  19190. * @param kind defines the vertex data kind to use
  19191. * @returns null
  19192. */
  19193. getVerticesData(kind: string): Nullable<FloatArray>;
  19194. /**
  19195. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19196. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19197. * Note that a new underlying VertexBuffer object is created each call.
  19198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19199. * @param kind defines vertex data kind:
  19200. * * BABYLON.VertexBuffer.PositionKind
  19201. * * BABYLON.VertexBuffer.UVKind
  19202. * * BABYLON.VertexBuffer.UV2Kind
  19203. * * BABYLON.VertexBuffer.UV3Kind
  19204. * * BABYLON.VertexBuffer.UV4Kind
  19205. * * BABYLON.VertexBuffer.UV5Kind
  19206. * * BABYLON.VertexBuffer.UV6Kind
  19207. * * BABYLON.VertexBuffer.ColorKind
  19208. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19209. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19210. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19211. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19212. * @param data defines the data source
  19213. * @param updatable defines if the data must be flagged as updatable (or static)
  19214. * @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
  19215. * @returns the current mesh
  19216. */
  19217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19218. /**
  19219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19220. * If the mesh has no geometry, it is simply returned as it is.
  19221. * @param kind defines vertex data kind:
  19222. * * BABYLON.VertexBuffer.PositionKind
  19223. * * BABYLON.VertexBuffer.UVKind
  19224. * * BABYLON.VertexBuffer.UV2Kind
  19225. * * BABYLON.VertexBuffer.UV3Kind
  19226. * * BABYLON.VertexBuffer.UV4Kind
  19227. * * BABYLON.VertexBuffer.UV5Kind
  19228. * * BABYLON.VertexBuffer.UV6Kind
  19229. * * BABYLON.VertexBuffer.ColorKind
  19230. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19231. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19232. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19233. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19234. * @param data defines the data source
  19235. * @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
  19236. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19237. * @returns the current mesh
  19238. */
  19239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19240. /**
  19241. * Sets the mesh indices,
  19242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19243. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19244. * @param totalVertices Defines the total number of vertices
  19245. * @returns the current mesh
  19246. */
  19247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19248. /**
  19249. * Gets a boolean indicating if specific vertex data is present
  19250. * @param kind defines the vertex data kind to use
  19251. * @returns true is data kind is present
  19252. */
  19253. isVerticesDataPresent(kind: string): boolean;
  19254. /**
  19255. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19256. * @returns a BoundingInfo
  19257. */
  19258. getBoundingInfo(): BoundingInfo;
  19259. /**
  19260. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19261. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19262. * @returns the current mesh
  19263. */
  19264. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19265. /**
  19266. * Overwrite the current bounding info
  19267. * @param boundingInfo defines the new bounding info
  19268. * @returns the current mesh
  19269. */
  19270. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19271. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19272. readonly useBones: boolean;
  19273. /** @hidden */
  19274. _preActivate(): void;
  19275. /** @hidden */
  19276. _preActivateForIntermediateRendering(renderId: number): void;
  19277. /** @hidden */
  19278. _activate(renderId: number): void;
  19279. /**
  19280. * Gets the current world matrix
  19281. * @returns a Matrix
  19282. */
  19283. getWorldMatrix(): Matrix;
  19284. /** @hidden */
  19285. _getWorldMatrixDeterminant(): number;
  19286. /**
  19287. * Perform relative position change from the point of view of behind the front of the mesh.
  19288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19289. * Supports definition of mesh facing forward or backward
  19290. * @param amountRight defines the distance on the right axis
  19291. * @param amountUp defines the distance on the up axis
  19292. * @param amountForward defines the distance on the forward axis
  19293. * @returns the current mesh
  19294. */
  19295. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19296. /**
  19297. * Calculate relative position change from the point of view of behind the front of the mesh.
  19298. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19299. * Supports definition of mesh facing forward or backward
  19300. * @param amountRight defines the distance on the right axis
  19301. * @param amountUp defines the distance on the up axis
  19302. * @param amountForward defines the distance on the forward axis
  19303. * @returns the new displacement vector
  19304. */
  19305. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19306. /**
  19307. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19308. * Supports definition of mesh facing forward or backward
  19309. * @param flipBack defines the flip
  19310. * @param twirlClockwise defines the twirl
  19311. * @param tiltRight defines the tilt
  19312. * @returns the current mesh
  19313. */
  19314. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19315. /**
  19316. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19317. * Supports definition of mesh facing forward or backward.
  19318. * @param flipBack defines the flip
  19319. * @param twirlClockwise defines the twirl
  19320. * @param tiltRight defines the tilt
  19321. * @returns the new rotation vector
  19322. */
  19323. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19324. /**
  19325. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19326. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19327. * @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
  19328. * @returns the new bounding vectors
  19329. */
  19330. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19331. min: Vector3;
  19332. max: Vector3;
  19333. };
  19334. /** @hidden */
  19335. _updateBoundingInfo(): AbstractMesh;
  19336. /** @hidden */
  19337. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19338. /** @hidden */
  19339. protected _afterComputeWorldMatrix(): void;
  19340. /**
  19341. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19342. * A mesh is in the frustum if its bounding box intersects the frustum
  19343. * @param frustumPlanes defines the frustum to test
  19344. * @returns true if the mesh is in the frustum planes
  19345. */
  19346. isInFrustum(frustumPlanes: Plane[]): boolean;
  19347. /**
  19348. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19349. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19350. * @param frustumPlanes defines the frustum to test
  19351. * @returns true if the mesh is completely in the frustum planes
  19352. */
  19353. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19354. /**
  19355. * True if the mesh intersects another mesh or a SolidParticle object
  19356. * @param mesh defines a target mesh or SolidParticle to test
  19357. * @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)
  19358. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19359. * @returns true if there is an intersection
  19360. */
  19361. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19362. /**
  19363. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19364. * @param point defines the point to test
  19365. * @returns true if there is an intersection
  19366. */
  19367. intersectsPoint(point: Vector3): boolean;
  19368. /**
  19369. * Gets the current physics impostor
  19370. * @see http://doc.babylonjs.com/features/physics_engine
  19371. * @returns a physics impostor or null
  19372. */
  19373. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19374. /**
  19375. * Gets the position of the current mesh in camera space
  19376. * @param camera defines the camera to use
  19377. * @returns a position
  19378. */
  19379. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19380. /**
  19381. * Returns the distance from the mesh to the active camera
  19382. * @param camera defines the camera to use
  19383. * @returns the distance
  19384. */
  19385. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19386. /**
  19387. * Apply a physic impulse to the mesh
  19388. * @param force defines the force to apply
  19389. * @param contactPoint defines where to apply the force
  19390. * @returns the current mesh
  19391. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19392. */
  19393. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19394. /**
  19395. * Creates a physic joint between two meshes
  19396. * @param otherMesh defines the other mesh to use
  19397. * @param pivot1 defines the pivot to use on this mesh
  19398. * @param pivot2 defines the pivot to use on the other mesh
  19399. * @param options defines additional options (can be plugin dependent)
  19400. * @returns the current mesh
  19401. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19402. */
  19403. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19404. /**
  19405. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19407. */
  19408. checkCollisions: boolean;
  19409. /**
  19410. * Gets Collider object used to compute collisions (not physics)
  19411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19412. */
  19413. readonly collider: Collider;
  19414. /**
  19415. * Move the mesh using collision engine
  19416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19417. * @param displacement defines the requested displacement vector
  19418. * @returns the current mesh
  19419. */
  19420. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19421. private _onCollisionPositionChange;
  19422. /**
  19423. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19424. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19425. * @param maxCapacity defines the maximum size of each block (64 by default)
  19426. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19427. * @returns the new octree
  19428. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19430. */
  19431. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19432. /** @hidden */
  19433. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19434. /** @hidden */
  19435. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19436. /** @hidden */
  19437. _checkCollision(collider: Collider): AbstractMesh;
  19438. /** @hidden */
  19439. _generatePointsArray(): boolean;
  19440. /**
  19441. * Checks if the passed Ray intersects with the mesh
  19442. * @param ray defines the ray to use
  19443. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19444. * @returns the picking info
  19445. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19446. */
  19447. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19448. /**
  19449. * Clones the current mesh
  19450. * @param name defines the mesh name
  19451. * @param newParent defines the new mesh parent
  19452. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19453. * @returns the new mesh
  19454. */
  19455. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19456. /**
  19457. * Disposes all the submeshes of the current meshnp
  19458. * @returns the current mesh
  19459. */
  19460. releaseSubMeshes(): AbstractMesh;
  19461. /**
  19462. * Releases resources associated with this abstract mesh.
  19463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19465. */
  19466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19467. /**
  19468. * Adds the passed mesh as a child to the current mesh
  19469. * @param mesh defines the child mesh
  19470. * @returns the current mesh
  19471. */
  19472. addChild(mesh: AbstractMesh): AbstractMesh;
  19473. /**
  19474. * Removes the passed mesh from the current mesh children list
  19475. * @param mesh defines the child mesh
  19476. * @returns the current mesh
  19477. */
  19478. removeChild(mesh: AbstractMesh): AbstractMesh;
  19479. /** @hidden */
  19480. private _initFacetData();
  19481. /**
  19482. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19483. * This method can be called within the render loop.
  19484. * 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
  19485. * @returns the current mesh
  19486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19487. */
  19488. updateFacetData(): AbstractMesh;
  19489. /**
  19490. * Returns the facetLocalNormals array.
  19491. * The normals are expressed in the mesh local spac
  19492. * @returns an array of Vector3
  19493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19494. */
  19495. getFacetLocalNormals(): Vector3[];
  19496. /**
  19497. * Returns the facetLocalPositions array.
  19498. * The facet positions are expressed in the mesh local space
  19499. * @returns an array of Vector3
  19500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19501. */
  19502. getFacetLocalPositions(): Vector3[];
  19503. /**
  19504. * Returns the facetLocalPartioning array
  19505. * @returns an array of array of numbers
  19506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19507. */
  19508. getFacetLocalPartitioning(): number[][];
  19509. /**
  19510. * Returns the i-th facet position in the world system.
  19511. * This method allocates a new Vector3 per call
  19512. * @param i defines the facet index
  19513. * @returns a new Vector3
  19514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19515. */
  19516. getFacetPosition(i: number): Vector3;
  19517. /**
  19518. * Sets the reference Vector3 with the i-th facet position in the world system
  19519. * @param i defines the facet index
  19520. * @param ref defines the target vector
  19521. * @returns the current mesh
  19522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19523. */
  19524. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19525. /**
  19526. * Returns the i-th facet normal in the world system.
  19527. * This method allocates a new Vector3 per call
  19528. * @param i defines the facet index
  19529. * @returns a new Vector3
  19530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19531. */
  19532. getFacetNormal(i: number): Vector3;
  19533. /**
  19534. * Sets the reference Vector3 with the i-th facet normal in the world system
  19535. * @param i defines the facet index
  19536. * @param ref defines the target vector
  19537. * @returns the current mesh
  19538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19539. */
  19540. getFacetNormalToRef(i: number, ref: Vector3): this;
  19541. /**
  19542. * 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)
  19543. * @param x defines x coordinate
  19544. * @param y defines y coordinate
  19545. * @param z defines z coordinate
  19546. * @returns the array of facet indexes
  19547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19548. */
  19549. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19550. /**
  19551. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19552. * @param projected sets as the (x,y,z) world projection on the facet
  19553. * @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
  19554. * @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
  19555. * @param x defines x coordinate
  19556. * @param y defines y coordinate
  19557. * @param z defines z coordinate
  19558. * @returns the face index if found (or null instead)
  19559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19560. */
  19561. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19562. /**
  19563. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19564. * @param projected sets as the (x,y,z) local projection on the facet
  19565. * @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
  19566. * @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
  19567. * @param x defines x coordinate
  19568. * @param y defines y coordinate
  19569. * @param z defines z coordinate
  19570. * @returns the face index if found (or null instead)
  19571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19572. */
  19573. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19574. /**
  19575. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19576. * @returns the parameters
  19577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19578. */
  19579. getFacetDataParameters(): any;
  19580. /**
  19581. * Disables the feature FacetData and frees the related memory
  19582. * @returns the current mesh
  19583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19584. */
  19585. disableFacetData(): AbstractMesh;
  19586. /**
  19587. * Updates the AbstractMesh indices array
  19588. * @param indices defines the data source
  19589. * @returns the current mesh
  19590. */
  19591. updateIndices(indices: IndicesArray): AbstractMesh;
  19592. /**
  19593. * Creates new normals data for the mesh
  19594. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19595. * @returns the current mesh
  19596. */
  19597. createNormals(updatable: boolean): AbstractMesh;
  19598. /**
  19599. * Align the mesh with a normal
  19600. * @param normal defines the normal to use
  19601. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19602. * @returns the current mesh
  19603. */
  19604. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19605. /** @hidden */
  19606. protected _checkOcclusionQuery(): void;
  19607. }
  19608. }
  19609. declare module BABYLON {
  19610. class Buffer {
  19611. private _engine;
  19612. private _buffer;
  19613. /** @hidden */
  19614. _data: Nullable<DataArray>;
  19615. private _updatable;
  19616. private _instanced;
  19617. /**
  19618. * Gets the byte stride.
  19619. */
  19620. readonly byteStride: number;
  19621. /**
  19622. * Constructor
  19623. * @param engine the engine
  19624. * @param data the data to use for this buffer
  19625. * @param updatable whether the data is updatable
  19626. * @param stride the stride (optional)
  19627. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19628. * @param instanced whether the buffer is instanced (optional)
  19629. * @param useBytes set to true if the stride in in bytes (optional)
  19630. */
  19631. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19632. /**
  19633. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19634. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19635. * @param offset defines offset in the buffer (0 by default)
  19636. * @param size defines the size in floats of attributes (position is 3 for instance)
  19637. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19638. * @param instanced defines if the vertex buffer contains indexed data
  19639. * @param useBytes defines if the offset and stride are in bytes
  19640. * @returns the new vertex buffer
  19641. */
  19642. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19643. isUpdatable(): boolean;
  19644. getData(): Nullable<DataArray>;
  19645. getBuffer(): Nullable<WebGLBuffer>;
  19646. /**
  19647. * Gets the stride in float32 units (i.e. byte stride / 4).
  19648. * May not be an integer if the byte stride is not divisible by 4.
  19649. * DEPRECATED. Use byteStride instead.
  19650. * @returns the stride in float32 units
  19651. */
  19652. getStrideSize(): number;
  19653. create(data?: Nullable<DataArray>): void;
  19654. _rebuild(): void;
  19655. update(data: DataArray): void;
  19656. /**
  19657. * Updates the data directly.
  19658. * @param data the new data
  19659. * @param offset the new offset
  19660. * @param vertexCount the vertex count (optional)
  19661. * @param useBytes set to true if the offset is in bytes
  19662. */
  19663. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19664. dispose(): void;
  19665. }
  19666. }
  19667. declare module BABYLON {
  19668. class CSG {
  19669. private polygons;
  19670. matrix: Matrix;
  19671. position: Vector3;
  19672. rotation: Vector3;
  19673. rotationQuaternion: Nullable<Quaternion>;
  19674. scaling: Vector3;
  19675. static FromMesh(mesh: Mesh): CSG;
  19676. private static FromPolygons(polygons);
  19677. clone(): CSG;
  19678. union(csg: CSG): CSG;
  19679. unionInPlace(csg: CSG): void;
  19680. subtract(csg: CSG): CSG;
  19681. subtractInPlace(csg: CSG): void;
  19682. intersect(csg: CSG): CSG;
  19683. intersectInPlace(csg: CSG): void;
  19684. inverse(): CSG;
  19685. inverseInPlace(): void;
  19686. copyTransformAttributes(csg: CSG): CSG;
  19687. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19688. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19689. }
  19690. }
  19691. declare module BABYLON {
  19692. /**
  19693. * Class used to store geometry data (vertex buffers + index buffer)
  19694. */
  19695. class Geometry implements IGetSetVerticesData {
  19696. /**
  19697. * Gets or sets the unique ID of the geometry
  19698. */
  19699. id: string;
  19700. /**
  19701. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19702. */
  19703. delayLoadState: number;
  19704. /**
  19705. * Gets the file containing the data to load when running in delay load state
  19706. */
  19707. delayLoadingFile: Nullable<string>;
  19708. /**
  19709. * Callback called when the geometry is updated
  19710. */
  19711. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19712. private _scene;
  19713. private _engine;
  19714. private _meshes;
  19715. private _totalVertices;
  19716. /** @hidden */
  19717. _indices: IndicesArray;
  19718. /** @hidden */
  19719. _vertexBuffers: {
  19720. [key: string]: VertexBuffer;
  19721. };
  19722. private _isDisposed;
  19723. private _extend;
  19724. private _boundingBias;
  19725. /** @hidden */
  19726. _delayInfo: Array<string>;
  19727. private _indexBuffer;
  19728. private _indexBufferIsUpdatable;
  19729. /** @hidden */
  19730. _boundingInfo: Nullable<BoundingInfo>;
  19731. /** @hidden */
  19732. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19733. /** @hidden */
  19734. _softwareSkinningRenderId: number;
  19735. private _vertexArrayObjects;
  19736. private _updatable;
  19737. /** @hidden */
  19738. _positions: Nullable<Vector3[]>;
  19739. /**
  19740. * 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
  19741. */
  19742. /**
  19743. * 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
  19744. */
  19745. boundingBias: Vector2;
  19746. /**
  19747. * Static function used to attach a new empty geometry to a mesh
  19748. * @param mesh defines the mesh to attach the geometry to
  19749. * @returns the new {BABYLON.Geometry}
  19750. */
  19751. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19752. /**
  19753. * Creates a new geometry
  19754. * @param id defines the unique ID
  19755. * @param scene defines the hosting scene
  19756. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19757. * @param updatable defines if geometry must be updatable (false by default)
  19758. * @param mesh defines the mesh that will be associated with the geometry
  19759. */
  19760. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19761. /**
  19762. * Gets the current extend of the geometry
  19763. */
  19764. readonly extend: {
  19765. minimum: Vector3;
  19766. maximum: Vector3;
  19767. };
  19768. /**
  19769. * Gets the hosting scene
  19770. * @returns the hosting {BABYLON.Scene}
  19771. */
  19772. getScene(): Scene;
  19773. /**
  19774. * Gets the hosting engine
  19775. * @returns the hosting {BABYLON.Engine}
  19776. */
  19777. getEngine(): Engine;
  19778. /**
  19779. * Defines if the geometry is ready to use
  19780. * @returns true if the geometry is ready to be used
  19781. */
  19782. isReady(): boolean;
  19783. /**
  19784. * Gets a value indicating that the geometry should not be serialized
  19785. */
  19786. readonly doNotSerialize: boolean;
  19787. /** @hidden */
  19788. _rebuild(): void;
  19789. /**
  19790. * Affects all geometry data in one call
  19791. * @param vertexData defines the geometry data
  19792. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19793. */
  19794. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19795. /**
  19796. * Set specific vertex data
  19797. * @param kind defines the data kind (Position, normal, etc...)
  19798. * @param data defines the vertex data to use
  19799. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19800. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19801. */
  19802. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19803. /**
  19804. * Removes a specific vertex data
  19805. * @param kind defines the data kind (Position, normal, etc...)
  19806. */
  19807. removeVerticesData(kind: string): void;
  19808. /**
  19809. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19810. * @param buffer defines the vertex buffer to use
  19811. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19812. */
  19813. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19814. /**
  19815. * Update a specific vertex buffer
  19816. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19817. * It will do nothing if the buffer is not updatable
  19818. * @param kind defines the data kind (Position, normal, etc...)
  19819. * @param data defines the data to use
  19820. * @param offset defines the offset in the target buffer where to store the data
  19821. * @param useBytes set to true if the offset is in bytes
  19822. */
  19823. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19824. /**
  19825. * Update a specific vertex buffer
  19826. * This function will create a new buffer if the current one is not updatable
  19827. * @param kind defines the data kind (Position, normal, etc...)
  19828. * @param data defines the data to use
  19829. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19830. */
  19831. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19832. private _updateBoundingInfo(updateExtends, data);
  19833. /** @hidden */
  19834. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19835. /**
  19836. * Gets total number of vertices
  19837. * @returns the total number of vertices
  19838. */
  19839. getTotalVertices(): number;
  19840. /**
  19841. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19842. * @param kind defines the data kind (Position, normal, etc...)
  19843. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19844. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19845. * @returns a float array containing vertex data
  19846. */
  19847. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19848. /**
  19849. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19850. * @param kind defines the data kind (Position, normal, etc...)
  19851. * @returns true if the vertex buffer with the specified kind is updatable
  19852. */
  19853. isVertexBufferUpdatable(kind: string): boolean;
  19854. /**
  19855. * Gets a specific vertex buffer
  19856. * @param kind defines the data kind (Position, normal, etc...)
  19857. * @returns a {BABYLON.VertexBuffer}
  19858. */
  19859. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19860. /**
  19861. * Returns all vertex buffers
  19862. * @return an object holding all vertex buffers indexed by kind
  19863. */
  19864. getVertexBuffers(): Nullable<{
  19865. [key: string]: VertexBuffer;
  19866. }>;
  19867. /**
  19868. * Gets a boolean indicating if specific vertex buffer is present
  19869. * @param kind defines the data kind (Position, normal, etc...)
  19870. * @returns true if data is present
  19871. */
  19872. isVerticesDataPresent(kind: string): boolean;
  19873. /**
  19874. * Gets a list of all attached data kinds (Position, normal, etc...)
  19875. * @returns a list of string containing all kinds
  19876. */
  19877. getVerticesDataKinds(): string[];
  19878. /**
  19879. * Update index buffer
  19880. * @param indices defines the indices to store in the index buffer
  19881. * @param offset defines the offset in the target buffer where to store the data
  19882. */
  19883. updateIndices(indices: IndicesArray, offset?: number): void;
  19884. /**
  19885. * Creates a new index buffer
  19886. * @param indices defines the indices to store in the index buffer
  19887. * @param totalVertices defines the total number of vertices (could be null)
  19888. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19889. */
  19890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19891. /**
  19892. * Return the total number of indices
  19893. * @returns the total number of indices
  19894. */
  19895. getTotalIndices(): number;
  19896. /**
  19897. * Gets the index buffer array
  19898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19899. * @returns the index buffer array
  19900. */
  19901. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19902. /**
  19903. * Gets the index buffer
  19904. * @return the index buffer
  19905. */
  19906. getIndexBuffer(): Nullable<WebGLBuffer>;
  19907. /** @hidden */
  19908. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19909. /**
  19910. * Release the associated resources for a specific mesh
  19911. * @param mesh defines the source mesh
  19912. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19913. */
  19914. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19915. /**
  19916. * Apply current geometry to a given mesh
  19917. * @param mesh defines the mesh to apply geometry to
  19918. */
  19919. applyToMesh(mesh: Mesh): void;
  19920. private _updateExtend(data?);
  19921. private _applyToMesh(mesh);
  19922. private notifyUpdate(kind?);
  19923. /**
  19924. * Load the geometry if it was flagged as delay loaded
  19925. * @param scene defines the hosting scene
  19926. * @param onLoaded defines a callback called when the geometry is loaded
  19927. */
  19928. load(scene: Scene, onLoaded?: () => void): void;
  19929. private _queueLoad(scene, onLoaded?);
  19930. /**
  19931. * Invert the geometry to move from a right handed system to a left handed one.
  19932. */
  19933. toLeftHanded(): void;
  19934. /** @hidden */
  19935. _resetPointsArrayCache(): void;
  19936. /** @hidden */
  19937. _generatePointsArray(): boolean;
  19938. /**
  19939. * Gets a value indicating if the geometry is disposed
  19940. * @returns true if the geometry was disposed
  19941. */
  19942. isDisposed(): boolean;
  19943. private _disposeVertexArrayObjects();
  19944. /**
  19945. * Free all associated resources
  19946. */
  19947. dispose(): void;
  19948. /**
  19949. * Clone the current geometry into a new geometry
  19950. * @param id defines the unique ID of the new geometry
  19951. * @returns a new geometry object
  19952. */
  19953. copy(id: string): Geometry;
  19954. /**
  19955. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19956. * @return a JSON representation of the current geometry data (without the vertices data)
  19957. */
  19958. serialize(): any;
  19959. private toNumberArray(origin);
  19960. /**
  19961. * Serialize all vertices data into a JSON oject
  19962. * @returns a JSON representation of the current geometry data
  19963. */
  19964. serializeVerticeData(): any;
  19965. /**
  19966. * Extracts a clone of a mesh geometry
  19967. * @param mesh defines the source mesh
  19968. * @param id defines the unique ID of the new geometry object
  19969. * @returns the new geometry object
  19970. */
  19971. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19972. /**
  19973. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19974. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19975. * Be aware Math.random() could cause collisions, but:
  19976. * "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"
  19977. * @returns a string containing a new GUID
  19978. */
  19979. static RandomId(): string;
  19980. /** @hidden */
  19981. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19982. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19983. /**
  19984. * Create a new geometry from persisted data (Using .babylon file format)
  19985. * @param parsedVertexData defines the persisted data
  19986. * @param scene defines the hosting scene
  19987. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19988. * @returns the new geometry object
  19989. */
  19990. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19991. }
  19992. /**
  19993. * Abstract class used to provide common services for all typed geometries
  19994. * @hidden
  19995. */
  19996. class _PrimitiveGeometry extends Geometry {
  19997. private _canBeRegenerated;
  19998. private _beingRegenerated;
  19999. /**
  20000. * Creates a new typed geometry
  20001. * @param id defines the unique ID of the geometry
  20002. * @param scene defines the hosting scene
  20003. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20004. * @param mesh defines the hosting mesh (can be null)
  20005. */
  20006. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20007. /**
  20008. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20009. * @returns true if the geometry can be regenerated
  20010. */
  20011. canBeRegenerated(): boolean;
  20012. /**
  20013. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20014. */
  20015. regenerate(): void;
  20016. /**
  20017. * Clone the geometry
  20018. * @param id defines the unique ID of the new geometry
  20019. * @returns the new geometry
  20020. */
  20021. asNewGeometry(id: string): Geometry;
  20022. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20023. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20024. /** @hidden */
  20025. _regenerateVertexData(): VertexData;
  20026. copy(id: string): Geometry;
  20027. serialize(): any;
  20028. }
  20029. /**
  20030. * Creates a ribbon geometry
  20031. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20032. */
  20033. class RibbonGeometry extends _PrimitiveGeometry {
  20034. /**
  20035. * Defines the array of paths to use
  20036. */
  20037. pathArray: Vector3[][];
  20038. /**
  20039. * Defines if the last and first points of each path in your pathArray must be joined
  20040. */
  20041. closeArray: boolean;
  20042. /**
  20043. * Defines if the last and first points of each path in your pathArray must be joined
  20044. */
  20045. closePath: boolean;
  20046. /**
  20047. * Defines the offset between points
  20048. */
  20049. offset: number;
  20050. /**
  20051. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20052. */
  20053. side: number;
  20054. /**
  20055. * Creates a ribbon geometry
  20056. * @param id defines the unique ID of the geometry
  20057. * @param scene defines the hosting scene
  20058. * @param pathArray defines the array of paths to use
  20059. * @param closeArray defines if the last path and the first path must be joined
  20060. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20061. * @param offset defines the offset between points
  20062. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20063. * @param mesh defines the hosting mesh (can be null)
  20064. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20065. */
  20066. constructor(id: string, scene: Scene,
  20067. /**
  20068. * Defines the array of paths to use
  20069. */
  20070. pathArray: Vector3[][],
  20071. /**
  20072. * Defines if the last and first points of each path in your pathArray must be joined
  20073. */
  20074. closeArray: boolean,
  20075. /**
  20076. * Defines if the last and first points of each path in your pathArray must be joined
  20077. */
  20078. closePath: boolean,
  20079. /**
  20080. * Defines the offset between points
  20081. */
  20082. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20083. /**
  20084. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20085. */
  20086. side?: number);
  20087. /** @hidden */
  20088. _regenerateVertexData(): VertexData;
  20089. copy(id: string): Geometry;
  20090. }
  20091. /**
  20092. * Creates a box geometry
  20093. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20094. */
  20095. class BoxGeometry extends _PrimitiveGeometry {
  20096. /**
  20097. * Defines the zise of the box (width, height and depth are the same)
  20098. */
  20099. size: number;
  20100. /**
  20101. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20102. */
  20103. side: number;
  20104. /**
  20105. * Creates a box geometry
  20106. * @param id defines the unique ID of the geometry
  20107. * @param scene defines the hosting scene
  20108. * @param size defines the zise of the box (width, height and depth are the same)
  20109. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20110. * @param mesh defines the hosting mesh (can be null)
  20111. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20112. */
  20113. constructor(id: string, scene: Scene,
  20114. /**
  20115. * Defines the zise of the box (width, height and depth are the same)
  20116. */
  20117. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20118. /**
  20119. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20120. */
  20121. side?: number);
  20122. _regenerateVertexData(): VertexData;
  20123. copy(id: string): Geometry;
  20124. serialize(): any;
  20125. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20126. }
  20127. /**
  20128. * Creates a sphere geometry
  20129. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20130. */
  20131. class SphereGeometry extends _PrimitiveGeometry {
  20132. /**
  20133. * Defines the number of segments to use to create the sphere
  20134. */
  20135. segments: number;
  20136. /**
  20137. * Defines the diameter of the sphere
  20138. */
  20139. diameter: number;
  20140. /**
  20141. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20142. */
  20143. side: number;
  20144. /**
  20145. * Create a new sphere geometry
  20146. * @param id defines the unique ID of the geometry
  20147. * @param scene defines the hosting scene
  20148. * @param segments defines the number of segments to use to create the sphere
  20149. * @param diameter defines the diameter of the sphere
  20150. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20151. * @param mesh defines the hosting mesh (can be null)
  20152. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20153. */
  20154. constructor(id: string, scene: Scene,
  20155. /**
  20156. * Defines the number of segments to use to create the sphere
  20157. */
  20158. segments: number,
  20159. /**
  20160. * Defines the diameter of the sphere
  20161. */
  20162. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20163. /**
  20164. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20165. */
  20166. side?: number);
  20167. _regenerateVertexData(): VertexData;
  20168. copy(id: string): Geometry;
  20169. serialize(): any;
  20170. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20171. }
  20172. /**
  20173. * Creates a disc geometry
  20174. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20175. */
  20176. class DiscGeometry extends _PrimitiveGeometry {
  20177. /**
  20178. * Defines the radius of the disc
  20179. */
  20180. radius: number;
  20181. /**
  20182. * Defines the tesselation factor to apply to the disc
  20183. */
  20184. tessellation: number;
  20185. /**
  20186. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20187. */
  20188. side: number;
  20189. /**
  20190. * Creates a new disc geometry
  20191. * @param id defines the unique ID of the geometry
  20192. * @param scene defines the hosting scene
  20193. * @param radius defines the radius of the disc
  20194. * @param tessellation defines the tesselation factor to apply to the disc
  20195. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20196. * @param mesh defines the hosting mesh (can be null)
  20197. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20198. */
  20199. constructor(id: string, scene: Scene,
  20200. /**
  20201. * Defines the radius of the disc
  20202. */
  20203. radius: number,
  20204. /**
  20205. * Defines the tesselation factor to apply to the disc
  20206. */
  20207. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20208. /**
  20209. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20210. */
  20211. side?: number);
  20212. _regenerateVertexData(): VertexData;
  20213. copy(id: string): Geometry;
  20214. }
  20215. /**
  20216. * Creates a new cylinder geometry
  20217. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20218. */
  20219. class CylinderGeometry extends _PrimitiveGeometry {
  20220. /**
  20221. * Defines the height of the cylinder
  20222. */
  20223. height: number;
  20224. /**
  20225. * Defines the diameter of the cylinder's top cap
  20226. */
  20227. diameterTop: number;
  20228. /**
  20229. * Defines the diameter of the cylinder's bottom cap
  20230. */
  20231. diameterBottom: number;
  20232. /**
  20233. * Defines the tessellation factor to apply to the cylinder
  20234. */
  20235. tessellation: number;
  20236. /**
  20237. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20238. */
  20239. subdivisions: number;
  20240. /**
  20241. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20242. */
  20243. side: number;
  20244. /**
  20245. * Creates a new cylinder geometry
  20246. * @param id defines the unique ID of the geometry
  20247. * @param scene defines the hosting scene
  20248. * @param height defines the height of the cylinder
  20249. * @param diameterTop defines the diameter of the cylinder's top cap
  20250. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20251. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20252. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20253. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20254. * @param mesh defines the hosting mesh (can be null)
  20255. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20256. */
  20257. constructor(id: string, scene: Scene,
  20258. /**
  20259. * Defines the height of the cylinder
  20260. */
  20261. height: number,
  20262. /**
  20263. * Defines the diameter of the cylinder's top cap
  20264. */
  20265. diameterTop: number,
  20266. /**
  20267. * Defines the diameter of the cylinder's bottom cap
  20268. */
  20269. diameterBottom: number,
  20270. /**
  20271. * Defines the tessellation factor to apply to the cylinder
  20272. */
  20273. tessellation: number,
  20274. /**
  20275. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20276. */
  20277. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20278. /**
  20279. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20280. */
  20281. side?: number);
  20282. _regenerateVertexData(): VertexData;
  20283. copy(id: string): Geometry;
  20284. serialize(): any;
  20285. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20286. }
  20287. /**
  20288. * Creates a new torus geometry
  20289. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20290. */
  20291. class TorusGeometry extends _PrimitiveGeometry {
  20292. /**
  20293. * Defines the diameter of the torus
  20294. */
  20295. diameter: number;
  20296. /**
  20297. * Defines the thickness of the torus (ie. internal diameter)
  20298. */
  20299. thickness: number;
  20300. /**
  20301. * Defines the tesselation factor to apply to the torus
  20302. */
  20303. tessellation: number;
  20304. /**
  20305. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20306. */
  20307. side: number;
  20308. /**
  20309. * Creates a new torus geometry
  20310. * @param id defines the unique ID of the geometry
  20311. * @param scene defines the hosting scene
  20312. * @param diameter defines the diameter of the torus
  20313. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20314. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20315. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20316. * @param mesh defines the hosting mesh (can be null)
  20317. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20318. */
  20319. constructor(id: string, scene: Scene,
  20320. /**
  20321. * Defines the diameter of the torus
  20322. */
  20323. diameter: number,
  20324. /**
  20325. * Defines the thickness of the torus (ie. internal diameter)
  20326. */
  20327. thickness: number,
  20328. /**
  20329. * Defines the tesselation factor to apply to the torus
  20330. */
  20331. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20332. /**
  20333. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20334. */
  20335. side?: number);
  20336. _regenerateVertexData(): VertexData;
  20337. copy(id: string): Geometry;
  20338. serialize(): any;
  20339. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20340. }
  20341. /**
  20342. * Creates a new ground geometry
  20343. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20344. */
  20345. class GroundGeometry extends _PrimitiveGeometry {
  20346. /**
  20347. * Defines the width of the ground
  20348. */
  20349. width: number;
  20350. /**
  20351. * Defines the height of the ground
  20352. */
  20353. height: number;
  20354. /**
  20355. * Defines the subdivisions to apply to the ground
  20356. */
  20357. subdivisions: number;
  20358. /**
  20359. * Creates a new ground geometry
  20360. * @param id defines the unique ID of the geometry
  20361. * @param scene defines the hosting scene
  20362. * @param width defines the width of the ground
  20363. * @param height defines the height of the ground
  20364. * @param subdivisions defines the subdivisions to apply to the ground
  20365. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20366. * @param mesh defines the hosting mesh (can be null)
  20367. */
  20368. constructor(id: string, scene: Scene,
  20369. /**
  20370. * Defines the width of the ground
  20371. */
  20372. width: number,
  20373. /**
  20374. * Defines the height of the ground
  20375. */
  20376. height: number,
  20377. /**
  20378. * Defines the subdivisions to apply to the ground
  20379. */
  20380. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20381. _regenerateVertexData(): VertexData;
  20382. copy(id: string): Geometry;
  20383. serialize(): any;
  20384. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20385. }
  20386. /**
  20387. * Creates a tiled ground geometry
  20388. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20389. */
  20390. class TiledGroundGeometry extends _PrimitiveGeometry {
  20391. /**
  20392. * Defines the minimum value on X axis
  20393. */
  20394. xmin: number;
  20395. /**
  20396. * Defines the minimum value on Z axis
  20397. */
  20398. zmin: number;
  20399. /**
  20400. * Defines the maximum value on X axis
  20401. */
  20402. xmax: number;
  20403. /**
  20404. * Defines the maximum value on Z axis
  20405. */
  20406. zmax: number;
  20407. /**
  20408. * Defines the subdivisions to apply to the ground
  20409. */
  20410. subdivisions: {
  20411. w: number;
  20412. h: number;
  20413. };
  20414. /**
  20415. * Defines the precision to use when computing the tiles
  20416. */
  20417. precision: {
  20418. w: number;
  20419. h: number;
  20420. };
  20421. /**
  20422. * Creates a tiled ground geometry
  20423. * @param id defines the unique ID of the geometry
  20424. * @param scene defines the hosting scene
  20425. * @param xmin defines the minimum value on X axis
  20426. * @param zmin defines the minimum value on Z axis
  20427. * @param xmax defines the maximum value on X axis
  20428. * @param zmax defines the maximum value on Z axis
  20429. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20430. * @param precision defines the precision to use when computing the tiles
  20431. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20432. * @param mesh defines the hosting mesh (can be null)
  20433. */
  20434. constructor(id: string, scene: Scene,
  20435. /**
  20436. * Defines the minimum value on X axis
  20437. */
  20438. xmin: number,
  20439. /**
  20440. * Defines the minimum value on Z axis
  20441. */
  20442. zmin: number,
  20443. /**
  20444. * Defines the maximum value on X axis
  20445. */
  20446. xmax: number,
  20447. /**
  20448. * Defines the maximum value on Z axis
  20449. */
  20450. zmax: number,
  20451. /**
  20452. * Defines the subdivisions to apply to the ground
  20453. */
  20454. subdivisions: {
  20455. w: number;
  20456. h: number;
  20457. },
  20458. /**
  20459. * Defines the precision to use when computing the tiles
  20460. */
  20461. precision: {
  20462. w: number;
  20463. h: number;
  20464. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20465. _regenerateVertexData(): VertexData;
  20466. copy(id: string): Geometry;
  20467. }
  20468. /**
  20469. * Creates a plane geometry
  20470. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20471. */
  20472. class PlaneGeometry extends _PrimitiveGeometry {
  20473. /**
  20474. * Defines the size of the plane (width === height)
  20475. */
  20476. size: number;
  20477. /**
  20478. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20479. */
  20480. side: number;
  20481. /**
  20482. * Creates a plane geometry
  20483. * @param id defines the unique ID of the geometry
  20484. * @param scene defines the hosting scene
  20485. * @param size defines the size of the plane (width === height)
  20486. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20487. * @param mesh defines the hosting mesh (can be null)
  20488. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20489. */
  20490. constructor(id: string, scene: Scene,
  20491. /**
  20492. * Defines the size of the plane (width === height)
  20493. */
  20494. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20495. /**
  20496. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20497. */
  20498. side?: number);
  20499. _regenerateVertexData(): VertexData;
  20500. copy(id: string): Geometry;
  20501. serialize(): any;
  20502. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20503. }
  20504. /**
  20505. * Creates a torus knot geometry
  20506. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20507. */
  20508. class TorusKnotGeometry extends _PrimitiveGeometry {
  20509. /**
  20510. * Defines the radius of the torus knot
  20511. */
  20512. radius: number;
  20513. /**
  20514. * Defines the thickness of the torus knot tube
  20515. */
  20516. tube: number;
  20517. /**
  20518. * Defines the number of radial segments
  20519. */
  20520. radialSegments: number;
  20521. /**
  20522. * Defines the number of tubular segments
  20523. */
  20524. tubularSegments: number;
  20525. /**
  20526. * Defines the first number of windings
  20527. */
  20528. p: number;
  20529. /**
  20530. * Defines the second number of windings
  20531. */
  20532. q: number;
  20533. /**
  20534. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20535. */
  20536. side: number;
  20537. /**
  20538. * Creates a torus knot geometry
  20539. * @param id defines the unique ID of the geometry
  20540. * @param scene defines the hosting scene
  20541. * @param radius defines the radius of the torus knot
  20542. * @param tube defines the thickness of the torus knot tube
  20543. * @param radialSegments defines the number of radial segments
  20544. * @param tubularSegments defines the number of tubular segments
  20545. * @param p defines the first number of windings
  20546. * @param q defines the second number of windings
  20547. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20548. * @param mesh defines the hosting mesh (can be null)
  20549. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20550. */
  20551. constructor(id: string, scene: Scene,
  20552. /**
  20553. * Defines the radius of the torus knot
  20554. */
  20555. radius: number,
  20556. /**
  20557. * Defines the thickness of the torus knot tube
  20558. */
  20559. tube: number,
  20560. /**
  20561. * Defines the number of radial segments
  20562. */
  20563. radialSegments: number,
  20564. /**
  20565. * Defines the number of tubular segments
  20566. */
  20567. tubularSegments: number,
  20568. /**
  20569. * Defines the first number of windings
  20570. */
  20571. p: number,
  20572. /**
  20573. * Defines the second number of windings
  20574. */
  20575. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20576. /**
  20577. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20578. */
  20579. side?: number);
  20580. _regenerateVertexData(): VertexData;
  20581. copy(id: string): Geometry;
  20582. serialize(): any;
  20583. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20584. }
  20585. }
  20586. declare module BABYLON {
  20587. class GroundMesh extends Mesh {
  20588. generateOctree: boolean;
  20589. private _heightQuads;
  20590. _subdivisionsX: number;
  20591. _subdivisionsY: number;
  20592. _width: number;
  20593. _height: number;
  20594. _minX: number;
  20595. _maxX: number;
  20596. _minZ: number;
  20597. _maxZ: number;
  20598. constructor(name: string, scene: Scene);
  20599. getClassName(): string;
  20600. readonly subdivisions: number;
  20601. readonly subdivisionsX: number;
  20602. readonly subdivisionsY: number;
  20603. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20604. /**
  20605. * Returns a height (y) value in the Worl system :
  20606. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20607. * Returns the ground y position if (x, z) are outside the ground surface.
  20608. */
  20609. getHeightAtCoordinates(x: number, z: number): number;
  20610. /**
  20611. * Returns a normalized vector (Vector3) orthogonal to the ground
  20612. * at the ground coordinates (x, z) expressed in the World system.
  20613. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20614. */
  20615. getNormalAtCoordinates(x: number, z: number): Vector3;
  20616. /**
  20617. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20618. * at the ground coordinates (x, z) expressed in the World system.
  20619. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20620. * Returns the GroundMesh.
  20621. */
  20622. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20623. /**
  20624. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20625. * if the ground has been updated.
  20626. * This can be used in the render loop.
  20627. * Returns the GroundMesh.
  20628. */
  20629. updateCoordinateHeights(): GroundMesh;
  20630. private _getFacetAt(x, z);
  20631. private _initHeightQuads();
  20632. private _computeHeightQuads();
  20633. serialize(serializationObject: any): void;
  20634. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20635. }
  20636. }
  20637. declare module BABYLON {
  20638. /**
  20639. * Creates an instance based on a source mesh.
  20640. */
  20641. class InstancedMesh extends AbstractMesh {
  20642. private _sourceMesh;
  20643. private _currentLOD;
  20644. constructor(name: string, source: Mesh);
  20645. /**
  20646. * Returns the string "InstancedMesh".
  20647. */
  20648. getClassName(): string;
  20649. readonly receiveShadows: boolean;
  20650. readonly material: Nullable<Material>;
  20651. readonly visibility: number;
  20652. readonly skeleton: Nullable<Skeleton>;
  20653. renderingGroupId: number;
  20654. /**
  20655. * Returns the total number of vertices (integer).
  20656. */
  20657. getTotalVertices(): number;
  20658. readonly sourceMesh: Mesh;
  20659. /**
  20660. * Is this node ready to be used/rendered
  20661. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20662. * @return {boolean} is it ready
  20663. */
  20664. isReady(completeCheck?: boolean): boolean;
  20665. /**
  20666. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20667. */
  20668. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20669. /**
  20670. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20671. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20672. * The `data` are either a numeric array either a Float32Array.
  20673. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20674. * 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).
  20675. * Note that a new underlying VertexBuffer object is created each call.
  20676. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20677. *
  20678. * Possible `kind` values :
  20679. * - BABYLON.VertexBuffer.PositionKind
  20680. * - BABYLON.VertexBuffer.UVKind
  20681. * - BABYLON.VertexBuffer.UV2Kind
  20682. * - BABYLON.VertexBuffer.UV3Kind
  20683. * - BABYLON.VertexBuffer.UV4Kind
  20684. * - BABYLON.VertexBuffer.UV5Kind
  20685. * - BABYLON.VertexBuffer.UV6Kind
  20686. * - BABYLON.VertexBuffer.ColorKind
  20687. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20688. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20689. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20690. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20691. *
  20692. * Returns the Mesh.
  20693. */
  20694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20695. /**
  20696. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20697. * If the mesh has no geometry, it is simply returned as it is.
  20698. * The `data` are either a numeric array either a Float32Array.
  20699. * No new underlying VertexBuffer object is created.
  20700. * 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.
  20701. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20702. *
  20703. * Possible `kind` values :
  20704. * - BABYLON.VertexBuffer.PositionKind
  20705. * - BABYLON.VertexBuffer.UVKind
  20706. * - BABYLON.VertexBuffer.UV2Kind
  20707. * - BABYLON.VertexBuffer.UV3Kind
  20708. * - BABYLON.VertexBuffer.UV4Kind
  20709. * - BABYLON.VertexBuffer.UV5Kind
  20710. * - BABYLON.VertexBuffer.UV6Kind
  20711. * - BABYLON.VertexBuffer.ColorKind
  20712. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20713. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20714. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20715. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20716. *
  20717. * Returns the Mesh.
  20718. */
  20719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20720. /**
  20721. * Sets the mesh indices.
  20722. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20723. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20724. * This method creates a new index buffer each call.
  20725. * Returns the Mesh.
  20726. */
  20727. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20728. /**
  20729. * Boolean : True if the mesh owns the requested kind of data.
  20730. */
  20731. isVerticesDataPresent(kind: string): boolean;
  20732. /**
  20733. * Returns an array of indices (IndicesArray).
  20734. */
  20735. getIndices(): Nullable<IndicesArray>;
  20736. readonly _positions: Nullable<Vector3[]>;
  20737. /**
  20738. * Sets a new updated BoundingInfo to the mesh.
  20739. * Returns the mesh.
  20740. */
  20741. refreshBoundingInfo(): InstancedMesh;
  20742. _preActivate(): InstancedMesh;
  20743. _activate(renderId: number): InstancedMesh;
  20744. /**
  20745. * Returns the current associated LOD AbstractMesh.
  20746. */
  20747. getLOD(camera: Camera): AbstractMesh;
  20748. _syncSubMeshes(): InstancedMesh;
  20749. _generatePointsArray(): boolean;
  20750. /**
  20751. * Creates a new InstancedMesh from the current mesh.
  20752. * - name (string) : the cloned mesh name
  20753. * - newParent (optional Node) : the optional Node to parent the clone to.
  20754. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20755. *
  20756. * Returns the clone.
  20757. */
  20758. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20759. /**
  20760. * Disposes the InstancedMesh.
  20761. * Returns nothing.
  20762. */
  20763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20764. }
  20765. }
  20766. declare module BABYLON {
  20767. class LinesMesh extends Mesh {
  20768. useVertexColor: boolean | undefined;
  20769. useVertexAlpha: boolean | undefined;
  20770. color: Color3;
  20771. alpha: number;
  20772. /**
  20773. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20774. * This margin is expressed in world space coordinates, so its value may vary.
  20775. * Default value is 0.1
  20776. * @returns the intersection Threshold value.
  20777. */
  20778. /**
  20779. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20780. * This margin is expressed in world space coordinates, so its value may vary.
  20781. * @param value the new threshold to apply
  20782. */
  20783. intersectionThreshold: number;
  20784. private _intersectionThreshold;
  20785. private _colorShader;
  20786. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20787. /**
  20788. * Returns the string "LineMesh"
  20789. */
  20790. getClassName(): string;
  20791. material: Material;
  20792. readonly checkCollisions: boolean;
  20793. createInstance(name: string): InstancedMesh;
  20794. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20795. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20796. dispose(doNotRecurse?: boolean): void;
  20797. /**
  20798. * Returns a new LineMesh object cloned from the current one.
  20799. */
  20800. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20801. }
  20802. }
  20803. declare module BABYLON {
  20804. /**
  20805. * @hidden
  20806. **/
  20807. class _InstancesBatch {
  20808. mustReturn: boolean;
  20809. visibleInstances: Nullable<InstancedMesh[]>[];
  20810. renderSelf: boolean[];
  20811. }
  20812. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20813. static _FRONTSIDE: number;
  20814. static _BACKSIDE: number;
  20815. static _DOUBLESIDE: number;
  20816. static _DEFAULTSIDE: number;
  20817. static _NO_CAP: number;
  20818. static _CAP_START: number;
  20819. static _CAP_END: number;
  20820. static _CAP_ALL: number;
  20821. /**
  20822. * Mesh side orientation : usually the external or front surface
  20823. */
  20824. static readonly FRONTSIDE: number;
  20825. /**
  20826. * Mesh side orientation : usually the internal or back surface
  20827. */
  20828. static readonly BACKSIDE: number;
  20829. /**
  20830. * Mesh side orientation : both internal and external or front and back surfaces
  20831. */
  20832. static readonly DOUBLESIDE: number;
  20833. /**
  20834. * Mesh side orientation : by default, `FRONTSIDE`
  20835. */
  20836. static readonly DEFAULTSIDE: number;
  20837. /**
  20838. * Mesh cap setting : no cap
  20839. */
  20840. static readonly NO_CAP: number;
  20841. /**
  20842. * Mesh cap setting : one cap at the beginning of the mesh
  20843. */
  20844. static readonly CAP_START: number;
  20845. /**
  20846. * Mesh cap setting : one cap at the end of the mesh
  20847. */
  20848. static readonly CAP_END: number;
  20849. /**
  20850. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20851. */
  20852. static readonly CAP_ALL: number;
  20853. /**
  20854. * An event triggered before rendering the mesh
  20855. */
  20856. onBeforeRenderObservable: Observable<Mesh>;
  20857. /**
  20858. * An event triggered after rendering the mesh
  20859. */
  20860. onAfterRenderObservable: Observable<Mesh>;
  20861. /**
  20862. * An event triggered before drawing the mesh
  20863. */
  20864. onBeforeDrawObservable: Observable<Mesh>;
  20865. private _onBeforeDrawObserver;
  20866. onBeforeDraw: () => void;
  20867. delayLoadState: number;
  20868. instances: InstancedMesh[];
  20869. delayLoadingFile: string;
  20870. _binaryInfo: any;
  20871. private _LODLevels;
  20872. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20873. private _morphTargetManager;
  20874. morphTargetManager: Nullable<MorphTargetManager>;
  20875. _geometry: Nullable<Geometry>;
  20876. _delayInfo: Array<string>;
  20877. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20878. _visibleInstances: any;
  20879. private _renderIdForInstances;
  20880. private _batchCache;
  20881. private _instancesBufferSize;
  20882. private _instancesBuffer;
  20883. private _instancesData;
  20884. private _overridenInstanceCount;
  20885. private _effectiveMaterial;
  20886. _shouldGenerateFlatShading: boolean;
  20887. private _preActivateId;
  20888. _originalBuilderSideOrientation: number;
  20889. overrideMaterialSideOrientation: Nullable<number>;
  20890. private _areNormalsFrozen;
  20891. private _sourcePositions;
  20892. private _sourceNormals;
  20893. private _source;
  20894. readonly source: Nullable<Mesh>;
  20895. isUnIndexed: boolean;
  20896. /**
  20897. * @constructor
  20898. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20899. * @param {Scene} scene The scene to add this mesh to.
  20900. * @param {Node} parent The parent of this mesh, if it has one
  20901. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20902. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20903. * When false, achieved by calling a clone(), also passing False.
  20904. * This will make creation of children, recursive.
  20905. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20906. */
  20907. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20908. /**
  20909. * Returns the string "Mesh".
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Returns a string.
  20914. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20915. */
  20916. toString(fullDetails?: boolean): string;
  20917. _unBindEffect(): void;
  20918. /**
  20919. * True if the mesh has some Levels Of Details (LOD).
  20920. * Returns a boolean.
  20921. */
  20922. readonly hasLODLevels: boolean;
  20923. /**
  20924. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20925. * @returns an array of {BABYLON.MeshLODLevel}
  20926. */
  20927. getLODLevels(): MeshLODLevel[];
  20928. private _sortLODLevels();
  20929. /**
  20930. * Add a mesh as LOD level triggered at the given distance.
  20931. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20932. * @param distance The distance from the center of the object to show this level
  20933. * @param mesh The mesh to be added as LOD level (can be null)
  20934. * @return This mesh (for chaining)
  20935. */
  20936. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20937. /**
  20938. * Returns the LOD level mesh at the passed distance or null if not found.
  20939. * It is related to the method `addLODLevel(distance, mesh)`.
  20940. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20941. * Returns an object Mesh or `null`.
  20942. */
  20943. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20944. /**
  20945. * Remove a mesh from the LOD array
  20946. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20947. * @param {Mesh} mesh The mesh to be removed.
  20948. * @return {Mesh} This mesh (for chaining)
  20949. */
  20950. removeLODLevel(mesh: Mesh): Mesh;
  20951. /**
  20952. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20953. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  20954. */
  20955. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20956. /**
  20957. * Returns the mesh internal Geometry object.
  20958. */
  20959. readonly geometry: Nullable<Geometry>;
  20960. /**
  20961. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20962. */
  20963. getTotalVertices(): number;
  20964. /**
  20965. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20966. * 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.
  20967. * You can force the copy with forceCopy === true
  20968. * Returns null if the mesh has no geometry or no vertex buffer.
  20969. * Possible `kind` values :
  20970. * - BABYLON.VertexBuffer.PositionKind
  20971. * - BABYLON.VertexBuffer.UVKind
  20972. * - BABYLON.VertexBuffer.UV2Kind
  20973. * - BABYLON.VertexBuffer.UV3Kind
  20974. * - BABYLON.VertexBuffer.UV4Kind
  20975. * - BABYLON.VertexBuffer.UV5Kind
  20976. * - BABYLON.VertexBuffer.UV6Kind
  20977. * - BABYLON.VertexBuffer.ColorKind
  20978. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20979. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20980. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20981. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20982. */
  20983. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20984. /**
  20985. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20986. * Returns `null` if the mesh has no geometry.
  20987. * Possible `kind` values :
  20988. * - BABYLON.VertexBuffer.PositionKind
  20989. * - BABYLON.VertexBuffer.UVKind
  20990. * - BABYLON.VertexBuffer.UV2Kind
  20991. * - BABYLON.VertexBuffer.UV3Kind
  20992. * - BABYLON.VertexBuffer.UV4Kind
  20993. * - BABYLON.VertexBuffer.UV5Kind
  20994. * - BABYLON.VertexBuffer.UV6Kind
  20995. * - BABYLON.VertexBuffer.ColorKind
  20996. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20997. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20998. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20999. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21000. */
  21001. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21002. isVerticesDataPresent(kind: string): boolean;
  21003. /**
  21004. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21005. * Possible `kind` values :
  21006. * - BABYLON.VertexBuffer.PositionKind
  21007. * - BABYLON.VertexBuffer.UVKind
  21008. * - BABYLON.VertexBuffer.UV2Kind
  21009. * - BABYLON.VertexBuffer.UV3Kind
  21010. * - BABYLON.VertexBuffer.UV4Kind
  21011. * - BABYLON.VertexBuffer.UV5Kind
  21012. * - BABYLON.VertexBuffer.UV6Kind
  21013. * - BABYLON.VertexBuffer.ColorKind
  21014. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21015. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21016. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21017. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21018. */
  21019. isVertexBufferUpdatable(kind: string): boolean;
  21020. /**
  21021. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21022. * Possible `kind` values :
  21023. * - BABYLON.VertexBuffer.PositionKind
  21024. * - BABYLON.VertexBuffer.UVKind
  21025. * - BABYLON.VertexBuffer.UV2Kind
  21026. * - BABYLON.VertexBuffer.UV3Kind
  21027. * - BABYLON.VertexBuffer.UV4Kind
  21028. * - BABYLON.VertexBuffer.UV5Kind
  21029. * - BABYLON.VertexBuffer.UV6Kind
  21030. * - BABYLON.VertexBuffer.ColorKind
  21031. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21032. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21033. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21034. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21035. */
  21036. getVerticesDataKinds(): string[];
  21037. /**
  21038. * Returns a positive integer : the total number of indices in this mesh geometry.
  21039. * Returns zero if the mesh has no geometry.
  21040. */
  21041. getTotalIndices(): number;
  21042. /**
  21043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21044. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21045. * Returns an empty array if the mesh has no geometry.
  21046. */
  21047. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21048. readonly isBlocked: boolean;
  21049. /**
  21050. * Determine if the current mesh is ready to be rendered
  21051. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21052. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21053. * @returns true if all associated assets are ready (material, textures, shaders)
  21054. */
  21055. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21056. /**
  21057. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21058. * This property is pertinent only for updatable parametric shapes.
  21059. */
  21060. readonly areNormalsFrozen: boolean;
  21061. /**
  21062. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21063. * It has no effect at all on other shapes.
  21064. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21065. * Returns the Mesh.
  21066. */
  21067. freezeNormals(): Mesh;
  21068. /**
  21069. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21070. * It has no effect at all on other shapes.
  21071. * It reactivates the mesh normals computation if it was previously frozen.
  21072. * Returns the Mesh.
  21073. */
  21074. unfreezeNormals(): Mesh;
  21075. /**
  21076. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21077. */
  21078. overridenInstanceCount: number;
  21079. _preActivate(): Mesh;
  21080. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21081. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21082. /**
  21083. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21084. * This means the mesh underlying bounding box and sphere are recomputed.
  21085. * Returns the Mesh.
  21086. */
  21087. refreshBoundingInfo(): Mesh;
  21088. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21089. private _getPositionData(applySkeleton);
  21090. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21091. subdivide(count: number): void;
  21092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21093. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21094. /**
  21095. * Sets the mesh VertexBuffer.
  21096. * Returns the Mesh.
  21097. */
  21098. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21100. /**
  21101. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21102. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21103. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21104. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21105. * Returns the Mesh.
  21106. */
  21107. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21108. /**
  21109. * Creates a un-shared specific occurence of the geometry for the mesh.
  21110. * Returns the Mesh.
  21111. */
  21112. makeGeometryUnique(): Mesh;
  21113. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21114. /**
  21115. * Update the current index buffer
  21116. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21117. * Returns the Mesh.
  21118. */
  21119. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21120. /**
  21121. * Invert the geometry to move from a right handed system to a left handed one.
  21122. * Returns the Mesh.
  21123. */
  21124. toLeftHanded(): Mesh;
  21125. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21126. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21127. /**
  21128. * Registers for this mesh a javascript function called just before the rendering process.
  21129. * This function is passed the current mesh.
  21130. * Return the Mesh.
  21131. */
  21132. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21133. /**
  21134. * Disposes a previously registered javascript function called before the rendering.
  21135. * This function is passed the current mesh.
  21136. * Returns the Mesh.
  21137. */
  21138. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21139. /**
  21140. * Registers for this mesh a javascript function called just after the rendering is complete.
  21141. * This function is passed the current mesh.
  21142. * Returns the Mesh.
  21143. */
  21144. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21145. /**
  21146. * Disposes a previously registered javascript function called after the rendering.
  21147. * This function is passed the current mesh.
  21148. * Return the Mesh.
  21149. */
  21150. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21151. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21152. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21153. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21154. /**
  21155. * 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
  21156. * @param subMesh defines the subMesh to render
  21157. * @param enableAlphaMode defines if alpha mode can be changed
  21158. * @returns the current mesh
  21159. */
  21160. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21161. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21162. /**
  21163. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21164. */
  21165. getEmittedParticleSystems(): IParticleSystem[];
  21166. /**
  21167. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21168. */
  21169. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21170. /**
  21171. * Normalize matrix weights so that all vertices have a total weight set to 1
  21172. */
  21173. cleanMatrixWeights(): void;
  21174. _checkDelayState(): Mesh;
  21175. private _queueLoad(scene);
  21176. /**
  21177. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21178. */
  21179. isInFrustum(frustumPlanes: Plane[]): boolean;
  21180. /**
  21181. * Sets the mesh material by the material or multiMaterial `id` property.
  21182. * The material `id` is a string identifying the material or the multiMaterial.
  21183. * This method returns the Mesh.
  21184. */
  21185. setMaterialByID(id: string): Mesh;
  21186. /**
  21187. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21188. */
  21189. getAnimatables(): IAnimatable[];
  21190. /**
  21191. * Modifies the mesh geometry according to the passed transformation matrix.
  21192. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21193. * The mesh normals are modified accordingly the same transformation.
  21194. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21195. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21196. * Returns the Mesh.
  21197. */
  21198. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21199. /**
  21200. * Modifies the mesh geometry according to its own current World Matrix.
  21201. * The mesh World Matrix is then reset.
  21202. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21203. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21204. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21205. * Returns the Mesh.
  21206. */
  21207. bakeCurrentTransformIntoVertices(): Mesh;
  21208. readonly _positions: Nullable<Vector3[]>;
  21209. _resetPointsArrayCache(): Mesh;
  21210. _generatePointsArray(): boolean;
  21211. /**
  21212. * Returns a new Mesh object generated from the current mesh properties.
  21213. * This method must not get confused with createInstance().
  21214. * The parameter `name` is a string, the name given to the new mesh.
  21215. * The optional parameter `newParent` can be any Node object (default `null`).
  21216. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21217. * 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.
  21218. */
  21219. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21220. /**
  21221. * Releases resources associated with this mesh.
  21222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21224. */
  21225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21226. /**
  21227. * Modifies the mesh geometry according to a displacement map.
  21228. * 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.
  21229. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21230. * This method returns nothing.
  21231. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21232. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21233. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21234. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21235. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21236. *
  21237. * Returns the Mesh.
  21238. */
  21239. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21240. /**
  21241. * Modifies the mesh geometry according to a displacementMap buffer.
  21242. * 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.
  21243. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21244. * This method returns nothing.
  21245. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21246. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21247. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21248. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21249. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21250. *
  21251. * Returns the Mesh.
  21252. */
  21253. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21254. /**
  21255. * Modify the mesh to get a flat shading rendering.
  21256. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21257. * This method returns the Mesh.
  21258. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21259. */
  21260. convertToFlatShadedMesh(): Mesh;
  21261. /**
  21262. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21263. * In other words, more vertices, no more indices and a single bigger VBO.
  21264. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21265. * Returns the Mesh.
  21266. */
  21267. convertToUnIndexedMesh(): Mesh;
  21268. /**
  21269. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21270. * This method returns the Mesh.
  21271. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21272. */
  21273. flipFaces(flipNormals?: boolean): Mesh;
  21274. /**
  21275. * Creates a new InstancedMesh object from the mesh model.
  21276. * An instance shares the same properties and the same material than its model.
  21277. * Only these properties of each instance can then be set individually :
  21278. * - position
  21279. * - rotation
  21280. * - rotationQuaternion
  21281. * - setPivotMatrix
  21282. * - scaling
  21283. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21284. * Warning : this method is not supported for Line mesh and LineSystem
  21285. */
  21286. createInstance(name: string): InstancedMesh;
  21287. /**
  21288. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21289. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21290. * This method returns the Mesh.
  21291. */
  21292. synchronizeInstances(): Mesh;
  21293. /**
  21294. * Simplify the mesh according to the given array of settings.
  21295. * Function will return immediately and will simplify async. It returns the Mesh.
  21296. * @param settings a collection of simplification settings.
  21297. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21298. * @param type the type of simplification to run.
  21299. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21300. */
  21301. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21302. /**
  21303. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21304. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21305. * This should be used together with the simplification to avoid disappearing triangles.
  21306. * Returns the Mesh.
  21307. * @param successCallback an optional success callback to be called after the optimization finished.
  21308. */
  21309. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21310. serialize(serializationObject: any): void;
  21311. _syncGeometryWithMorphTargetManager(): void;
  21312. /**
  21313. * Returns a new Mesh object parsed from the source provided.
  21314. * The parameter `parsedMesh` is the source.
  21315. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21316. */
  21317. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21318. /**
  21319. * Creates a ribbon mesh.
  21320. * Please consider using the same method from the MeshBuilder class instead.
  21321. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21322. *
  21323. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21324. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21325. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21326. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21327. * 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.
  21328. * 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.
  21329. * 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
  21330. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21331. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21332. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21333. */
  21334. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21335. /**
  21336. * Creates a plane polygonal mesh. By default, this is a disc.
  21337. * Please consider using the same method from the MeshBuilder class instead.
  21338. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21339. * 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.
  21340. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21341. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21342. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21343. */
  21344. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21345. /**
  21346. * Creates a box mesh.
  21347. * Please consider using the same method from the MeshBuilder class instead.
  21348. * The parameter `size` sets the size (float) of each box side (default 1).
  21349. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21350. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21351. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21352. */
  21353. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21354. /**
  21355. * Creates a sphere mesh.
  21356. * Please consider using the same method from the MeshBuilder class instead.
  21357. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21358. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21359. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21360. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21362. */
  21363. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21364. /**
  21365. * Creates a cylinder or a cone mesh.
  21366. * Please consider using the same method from the MeshBuilder class instead.
  21367. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21368. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21369. * 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.
  21370. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21371. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21372. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21373. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21374. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21375. */
  21376. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21377. /**
  21378. * Creates a torus mesh.
  21379. * Please consider using the same method from the MeshBuilder class instead.
  21380. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21381. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21382. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21383. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21384. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21385. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21386. */
  21387. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21388. /**
  21389. * Creates a torus knot mesh.
  21390. * Please consider using the same method from the MeshBuilder class instead.
  21391. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21392. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21393. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21394. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21395. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21396. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21397. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21398. */
  21399. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21400. /**
  21401. * Creates a line mesh.
  21402. * Please consider using the same method from the MeshBuilder class instead.
  21403. * 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.
  21404. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21405. * The parameter `points` is an array successive Vector3.
  21406. * 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
  21407. * When updating an instance, remember that only point positions can change, not the number of points.
  21408. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21409. */
  21410. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21411. /**
  21412. * Creates a dashed line mesh.
  21413. * Please consider using the same method from the MeshBuilder class instead.
  21414. * 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.
  21415. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21416. * The parameter `points` is an array successive Vector3.
  21417. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21418. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21419. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21420. * 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
  21421. * When updating an instance, remember that only point positions can change, not the number of points.
  21422. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21423. */
  21424. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21425. /**
  21426. * Creates a polygon mesh.
  21427. * Please consider using the same method from the MeshBuilder class instead.
  21428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21429. * 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.
  21430. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21431. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21432. * Remember you can only change the shape positions, not their number when updating a polygon.
  21433. */
  21434. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21435. /**
  21436. * Creates an extruded polygon mesh, with depth in the Y direction.
  21437. * Please consider using the same method from the MeshBuilder class instead.
  21438. */
  21439. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21440. /**
  21441. * Creates an extruded shape mesh.
  21442. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21443. * Please consider using the same method from the MeshBuilder class instead.
  21444. *
  21445. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21446. * 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
  21447. * extruded along the Z axis.
  21448. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21449. * 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.
  21450. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21451. * 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
  21452. * 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
  21453. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21454. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21455. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21456. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21457. */
  21458. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21459. /**
  21460. * Creates an custom extruded shape mesh.
  21461. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21462. * Please consider using the same method from the MeshBuilder class instead.
  21463. *
  21464. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21465. * 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
  21466. * extruded along the Z axis.
  21467. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21468. * 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
  21469. * and the distance of this point from the begining of the path :
  21470. * ```javascript
  21471. * var rotationFunction = function(i, distance) {
  21472. * // do things
  21473. * return rotationValue; }
  21474. * ```
  21475. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21476. * 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
  21477. * and the distance of this point from the begining of the path :
  21478. * ```javascript
  21479. * var scaleFunction = function(i, distance) {
  21480. * // do things
  21481. * return scaleValue;}
  21482. * ```
  21483. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21484. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21485. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21486. * 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
  21487. * 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
  21488. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21489. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21490. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21491. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21492. */
  21493. 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;
  21494. /**
  21495. * Creates lathe mesh.
  21496. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21497. * Please consider using the same method from the MeshBuilder class instead.
  21498. * 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
  21499. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21500. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21501. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21502. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21503. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21504. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21505. */
  21506. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21507. /**
  21508. * Creates a plane mesh.
  21509. * Please consider using the same method from the MeshBuilder class instead.
  21510. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21511. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21512. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21513. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21514. */
  21515. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21516. /**
  21517. * Creates a ground mesh.
  21518. * Please consider using the same method from the MeshBuilder class instead.
  21519. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21520. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21521. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21522. */
  21523. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21524. /**
  21525. * Creates a tiled ground mesh.
  21526. * Please consider using the same method from the MeshBuilder class instead.
  21527. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21528. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21529. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21530. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21531. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21532. * numbers of subdivisions on the ground width and height of each tile.
  21533. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21534. */
  21535. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21536. w: number;
  21537. h: number;
  21538. }, precision: {
  21539. w: number;
  21540. h: number;
  21541. }, scene: Scene, updatable?: boolean): Mesh;
  21542. /**
  21543. * Creates a ground mesh from a height map.
  21544. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21545. * Please consider using the same method from the MeshBuilder class instead.
  21546. * The parameter `url` sets the URL of the height map image resource.
  21547. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21548. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21549. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21550. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21551. * 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).
  21552. * This function is passed the newly built mesh :
  21553. * ```javascript
  21554. * function(mesh) { // do things
  21555. * return; }
  21556. * ```
  21557. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21558. */
  21559. 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;
  21560. /**
  21561. * Creates a tube mesh.
  21562. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21563. * Please consider using the same method from the MeshBuilder class instead.
  21564. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21565. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21566. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21567. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21568. * 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.
  21569. * It must return a radius value (positive float) :
  21570. * ```javascript
  21571. * var radiusFunction = function(i, distance) {
  21572. * // do things
  21573. * return radius; }
  21574. * ```
  21575. * 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
  21576. * 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
  21577. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21578. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21579. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21580. */
  21581. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21582. (i: number, distance: number): number;
  21583. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21584. /**
  21585. * Creates a polyhedron mesh.
  21586. * Please consider using the same method from the MeshBuilder class instead.
  21587. * 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
  21588. * to choose the wanted type.
  21589. * The parameter `size` (positive float, default 1) sets the polygon size.
  21590. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21591. * 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`.
  21592. * 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
  21593. * 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)`).
  21594. * 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
  21595. * 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.
  21596. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21597. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21599. */
  21600. static CreatePolyhedron(name: string, options: {
  21601. type?: number;
  21602. size?: number;
  21603. sizeX?: number;
  21604. sizeY?: number;
  21605. sizeZ?: number;
  21606. custom?: any;
  21607. faceUV?: Vector4[];
  21608. faceColors?: Color4[];
  21609. updatable?: boolean;
  21610. sideOrientation?: number;
  21611. }, scene: Scene): Mesh;
  21612. /**
  21613. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21614. * Please consider using the same method from the MeshBuilder class instead.
  21615. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21616. * 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`).
  21617. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21618. * 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.
  21619. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21620. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21622. */
  21623. static CreateIcoSphere(name: string, options: {
  21624. radius?: number;
  21625. flat?: boolean;
  21626. subdivisions?: number;
  21627. sideOrientation?: number;
  21628. updatable?: boolean;
  21629. }, scene: Scene): Mesh;
  21630. /**
  21631. * Creates a decal mesh.
  21632. * Please consider using the same method from the MeshBuilder class instead.
  21633. * 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.
  21634. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21635. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21636. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21637. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21638. */
  21639. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21640. /**
  21641. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21642. */
  21643. setPositionsForCPUSkinning(): Float32Array;
  21644. /**
  21645. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21646. */
  21647. setNormalsForCPUSkinning(): Float32Array;
  21648. /**
  21649. * Updates the vertex buffer by applying transformation from the bones.
  21650. * Returns the Mesh.
  21651. *
  21652. * @param {skeleton} skeleton to apply
  21653. */
  21654. applySkeleton(skeleton: Skeleton): Mesh;
  21655. /**
  21656. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21657. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21658. */
  21659. static MinMax(meshes: AbstractMesh[]): {
  21660. min: Vector3;
  21661. max: Vector3;
  21662. };
  21663. /**
  21664. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21665. */
  21666. static Center(meshesOrMinMaxVector: {
  21667. min: Vector3;
  21668. max: Vector3;
  21669. } | AbstractMesh[]): Vector3;
  21670. /**
  21671. * Merge the array of meshes into a single mesh for performance reasons.
  21672. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21673. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21674. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21675. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21676. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21677. */
  21678. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21679. }
  21680. }
  21681. declare module BABYLON {
  21682. /**
  21683. * Define an interface for all classes that will get and set the data on vertices
  21684. */
  21685. interface IGetSetVerticesData {
  21686. isVerticesDataPresent(kind: string): boolean;
  21687. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21688. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21689. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21691. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21692. }
  21693. /**
  21694. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21695. */
  21696. class VertexData {
  21697. /**
  21698. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21699. */
  21700. positions: Nullable<FloatArray>;
  21701. /**
  21702. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21703. */
  21704. normals: Nullable<FloatArray>;
  21705. /**
  21706. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21707. */
  21708. tangents: Nullable<FloatArray>;
  21709. /**
  21710. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21711. */
  21712. uvs: Nullable<FloatArray>;
  21713. /**
  21714. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21715. */
  21716. uvs2: Nullable<FloatArray>;
  21717. /**
  21718. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21719. */
  21720. uvs3: Nullable<FloatArray>;
  21721. /**
  21722. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21723. */
  21724. uvs4: Nullable<FloatArray>;
  21725. /**
  21726. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21727. */
  21728. uvs5: Nullable<FloatArray>;
  21729. /**
  21730. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21731. */
  21732. uvs6: Nullable<FloatArray>;
  21733. /**
  21734. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21735. */
  21736. colors: Nullable<FloatArray>;
  21737. /**
  21738. * 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).
  21739. */
  21740. matricesIndices: Nullable<FloatArray>;
  21741. /**
  21742. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21743. */
  21744. matricesWeights: Nullable<FloatArray>;
  21745. /**
  21746. * An array extending the number of possible indices
  21747. */
  21748. matricesIndicesExtra: Nullable<FloatArray>;
  21749. /**
  21750. * An array extending the number of possible weights when the number of indices is extended
  21751. */
  21752. matricesWeightsExtra: Nullable<FloatArray>;
  21753. /**
  21754. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21755. */
  21756. indices: Nullable<IndicesArray>;
  21757. /**
  21758. * Uses the passed data array to set the set the values for the specified kind of data
  21759. * @param data a linear array of floating numbers
  21760. * @param kind the type of data that is being set, eg positions, colors etc
  21761. */
  21762. set(data: FloatArray, kind: string): void;
  21763. /**
  21764. * Associates the vertexData to the passed Mesh.
  21765. * Sets it as updatable or not (default `false`)
  21766. * @param mesh the mesh the vertexData is applied to
  21767. * @param updatable when used and having the value true allows new data to update the vertexData
  21768. * @returns the VertexData
  21769. */
  21770. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21771. /**
  21772. * Associates the vertexData to the passed Geometry.
  21773. * Sets it as updatable or not (default `false`)
  21774. * @param geometry the geometry the vertexData is applied to
  21775. * @param updatable when used and having the value true allows new data to update the vertexData
  21776. * @returns VertexData
  21777. */
  21778. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21779. /**
  21780. * Updates the associated mesh
  21781. * @param mesh the mesh to be updated
  21782. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21783. * @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
  21784. * @returns VertexData
  21785. */
  21786. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21787. /**
  21788. * Updates the associated geometry
  21789. * @param geometry the geometry to be updated
  21790. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21791. * @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
  21792. * @returns VertexData.
  21793. */
  21794. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21795. private _applyTo(meshOrGeometry, updatable?);
  21796. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21797. /**
  21798. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21799. * @param matrix the transforming matrix
  21800. * @returns the VertexData
  21801. */
  21802. transform(matrix: Matrix): VertexData;
  21803. /**
  21804. * Merges the passed VertexData into the current one
  21805. * @param other the VertexData to be merged into the current one
  21806. * @returns the modified VertexData
  21807. */
  21808. merge(other: VertexData): VertexData;
  21809. private _mergeElement(source, other);
  21810. private _validate();
  21811. /**
  21812. * Serializes the VertexData
  21813. * @returns a serialized object
  21814. */
  21815. serialize(): any;
  21816. /**
  21817. * Extracts the vertexData from a mesh
  21818. * @param mesh the mesh from which to extract the VertexData
  21819. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21820. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21821. * @returns the object VertexData associated to the passed mesh
  21822. */
  21823. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21824. /**
  21825. * Extracts the vertexData from the geometry
  21826. * @param geometry the geometry from which to extract the VertexData
  21827. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21828. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21829. * @returns the object VertexData associated to the passed mesh
  21830. */
  21831. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21832. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21833. /**
  21834. * Creates the VertexData for a Ribbon
  21835. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21836. * * pathArray array of paths, each of which an array of successive Vector3
  21837. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21838. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21839. * * 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
  21840. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21841. * * 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)
  21842. * * 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)
  21843. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21844. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21845. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21846. * @returns the VertexData of the ribbon
  21847. */
  21848. static CreateRibbon(options: {
  21849. pathArray: Vector3[][];
  21850. closeArray?: boolean;
  21851. closePath?: boolean;
  21852. offset?: number;
  21853. sideOrientation?: number;
  21854. frontUVs?: Vector4;
  21855. backUVs?: Vector4;
  21856. invertUV?: boolean;
  21857. uvs?: Vector2[];
  21858. colors?: Color4[];
  21859. }): VertexData;
  21860. /**
  21861. * Creates the VertexData for a box
  21862. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21863. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21864. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21865. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21866. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21867. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21868. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21869. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21870. * * 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)
  21871. * * 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)
  21872. * @returns the VertexData of the box
  21873. */
  21874. static CreateBox(options: {
  21875. size?: number;
  21876. width?: number;
  21877. height?: number;
  21878. depth?: number;
  21879. faceUV?: Vector4[];
  21880. faceColors?: Color4[];
  21881. sideOrientation?: number;
  21882. frontUVs?: Vector4;
  21883. backUVs?: Vector4;
  21884. }): VertexData;
  21885. /**
  21886. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21887. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21888. * * segments sets the number of horizontal strips optional, default 32
  21889. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21890. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21891. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21892. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21893. * * 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
  21894. * * 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
  21895. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21896. * * 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)
  21897. * * 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)
  21898. * @returns the VertexData of the ellipsoid
  21899. */
  21900. static CreateSphere(options: {
  21901. segments?: number;
  21902. diameter?: number;
  21903. diameterX?: number;
  21904. diameterY?: number;
  21905. diameterZ?: number;
  21906. arc?: number;
  21907. slice?: number;
  21908. sideOrientation?: number;
  21909. frontUVs?: Vector4;
  21910. backUVs?: Vector4;
  21911. }): VertexData;
  21912. /**
  21913. * Creates the VertexData for a cylinder, cone or prism
  21914. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21915. * * height sets the height (y direction) of the cylinder, optional, default 2
  21916. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21917. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21918. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21919. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21920. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21921. * * 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
  21922. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21923. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21924. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21925. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21926. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21927. * * 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)
  21928. * * 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)
  21929. * @returns the VertexData of the cylinder, cone or prism
  21930. */
  21931. static CreateCylinder(options: {
  21932. height?: number;
  21933. diameterTop?: number;
  21934. diameterBottom?: number;
  21935. diameter?: number;
  21936. tessellation?: number;
  21937. subdivisions?: number;
  21938. arc?: number;
  21939. faceColors?: Color4[];
  21940. faceUV?: Vector4[];
  21941. hasRings?: boolean;
  21942. enclose?: boolean;
  21943. sideOrientation?: number;
  21944. frontUVs?: Vector4;
  21945. backUVs?: Vector4;
  21946. }): VertexData;
  21947. /**
  21948. * Creates the VertexData for a torus
  21949. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21950. * * diameter the diameter of the torus, optional default 1
  21951. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21952. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21953. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21954. * * 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)
  21955. * * 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)
  21956. * @returns the VertexData of the torus
  21957. */
  21958. static CreateTorus(options: {
  21959. diameter?: number;
  21960. thickness?: number;
  21961. tessellation?: number;
  21962. sideOrientation?: number;
  21963. frontUVs?: Vector4;
  21964. backUVs?: Vector4;
  21965. }): VertexData;
  21966. /**
  21967. * Creates the VertexData of the LineSystem
  21968. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21969. * - lines an array of lines, each line being an array of successive Vector3
  21970. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21971. * @returns the VertexData of the LineSystem
  21972. */
  21973. static CreateLineSystem(options: {
  21974. lines: Vector3[][];
  21975. colors?: Nullable<Color4[][]>;
  21976. }): VertexData;
  21977. /**
  21978. * Create the VertexData for a DashedLines
  21979. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21980. * - points an array successive Vector3
  21981. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21982. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21983. * - dashNb the intended total number of dashes, optional, default 200
  21984. * @returns the VertexData for the DashedLines
  21985. */
  21986. static CreateDashedLines(options: {
  21987. points: Vector3[];
  21988. dashSize?: number;
  21989. gapSize?: number;
  21990. dashNb?: number;
  21991. }): VertexData;
  21992. /**
  21993. * Creates the VertexData for a Ground
  21994. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21995. * - width the width (x direction) of the ground, optional, default 1
  21996. * - height the height (z direction) of the ground, optional, default 1
  21997. * - subdivisions the number of subdivisions per side, optional, default 1
  21998. * @returns the VertexData of the Ground
  21999. */
  22000. static CreateGround(options: {
  22001. width?: number;
  22002. height?: number;
  22003. subdivisions?: number;
  22004. subdivisionsX?: number;
  22005. subdivisionsY?: number;
  22006. }): VertexData;
  22007. /**
  22008. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22009. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22010. * * xmin the ground minimum X coordinate, optional, default -1
  22011. * * zmin the ground minimum Z coordinate, optional, default -1
  22012. * * xmax the ground maximum X coordinate, optional, default 1
  22013. * * zmax the ground maximum Z coordinate, optional, default 1
  22014. * * 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}
  22015. * * 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}
  22016. * @returns the VertexData of the TiledGround
  22017. */
  22018. static CreateTiledGround(options: {
  22019. xmin: number;
  22020. zmin: number;
  22021. xmax: number;
  22022. zmax: number;
  22023. subdivisions?: {
  22024. w: number;
  22025. h: number;
  22026. };
  22027. precision?: {
  22028. w: number;
  22029. h: number;
  22030. };
  22031. }): VertexData;
  22032. /**
  22033. * Creates the VertexData of the Ground designed from a heightmap
  22034. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22035. * * width the width (x direction) of the ground
  22036. * * height the height (z direction) of the ground
  22037. * * subdivisions the number of subdivisions per side
  22038. * * minHeight the minimum altitude on the ground, optional, default 0
  22039. * * maxHeight the maximum altitude on the ground, optional default 1
  22040. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22041. * * buffer the array holding the image color data
  22042. * * bufferWidth the width of image
  22043. * * bufferHeight the height of image
  22044. * @returns the VertexData of the Ground designed from a heightmap
  22045. */
  22046. static CreateGroundFromHeightMap(options: {
  22047. width: number;
  22048. height: number;
  22049. subdivisions: number;
  22050. minHeight: number;
  22051. maxHeight: number;
  22052. colorFilter: Color3;
  22053. buffer: Uint8Array;
  22054. bufferWidth: number;
  22055. bufferHeight: number;
  22056. }): VertexData;
  22057. /**
  22058. * Creates the VertexData for a Plane
  22059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22060. * * size sets the width and height of the plane to the value of size, optional default 1
  22061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22063. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22064. * * 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)
  22065. * * 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)
  22066. * @returns the VertexData of the box
  22067. */
  22068. static CreatePlane(options: {
  22069. size?: number;
  22070. width?: number;
  22071. height?: number;
  22072. sideOrientation?: number;
  22073. frontUVs?: Vector4;
  22074. backUVs?: Vector4;
  22075. }): VertexData;
  22076. /**
  22077. * Creates the VertexData of the Disc or regular Polygon
  22078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22079. * * radius the radius of the disc, optional default 0.5
  22080. * * tessellation the number of polygon sides, optional, default 64
  22081. * * 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
  22082. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22083. * * 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)
  22084. * * 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)
  22085. * @returns the VertexData of the box
  22086. */
  22087. static CreateDisc(options: {
  22088. radius?: number;
  22089. tessellation?: number;
  22090. arc?: number;
  22091. sideOrientation?: number;
  22092. frontUVs?: Vector4;
  22093. backUVs?: Vector4;
  22094. }): VertexData;
  22095. /**
  22096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22098. * @param polygon a mesh built from polygonTriangulation.build()
  22099. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22102. * @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)
  22103. * @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)
  22104. * @returns the VertexData of the Polygon
  22105. */
  22106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22107. /**
  22108. * Creates the VertexData of the IcoSphere
  22109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22110. * * radius the radius of the IcoSphere, optional default 1
  22111. * * radiusX allows stretching in the x direction, optional, default radius
  22112. * * radiusY allows stretching in the y direction, optional, default radius
  22113. * * radiusZ allows stretching in the z direction, optional, default radius
  22114. * * flat when true creates a flat shaded mesh, optional, default true
  22115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22116. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22117. * * 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)
  22118. * * 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)
  22119. * @returns the VertexData of the IcoSphere
  22120. */
  22121. static CreateIcoSphere(options: {
  22122. radius?: number;
  22123. radiusX?: number;
  22124. radiusY?: number;
  22125. radiusZ?: number;
  22126. flat?: boolean;
  22127. subdivisions?: number;
  22128. sideOrientation?: number;
  22129. frontUVs?: Vector4;
  22130. backUVs?: Vector4;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a Polyhedron
  22134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22135. * * type provided types are:
  22136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22137. * * 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)
  22138. * * size the size of the IcoSphere, optional default 1
  22139. * * sizeX allows stretching in the x direction, optional, default size
  22140. * * sizeY allows stretching in the y direction, optional, default size
  22141. * * sizeZ allows stretching in the z direction, optional, default size
  22142. * * 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
  22143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22145. * * flat when true creates a flat shaded mesh, optional, default true
  22146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22147. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22148. * * 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)
  22149. * * 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)
  22150. * @returns the VertexData of the Polyhedron
  22151. */
  22152. static CreatePolyhedron(options: {
  22153. type?: number;
  22154. size?: number;
  22155. sizeX?: number;
  22156. sizeY?: number;
  22157. sizeZ?: number;
  22158. custom?: any;
  22159. faceUV?: Vector4[];
  22160. faceColors?: Color4[];
  22161. flat?: boolean;
  22162. sideOrientation?: number;
  22163. frontUVs?: Vector4;
  22164. backUVs?: Vector4;
  22165. }): VertexData;
  22166. /**
  22167. * Creates the VertexData for a TorusKnot
  22168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22169. * * radius the radius of the torus knot, optional, default 2
  22170. * * tube the thickness of the tube, optional, default 0.5
  22171. * * radialSegments the number of sides on each tube segments, optional, default 32
  22172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22173. * * p the number of windings around the z axis, optional, default 2
  22174. * * q the number of windings around the x axis, optional, default 3
  22175. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22176. * * 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)
  22177. * * 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)
  22178. * @returns the VertexData of the Torus Knot
  22179. */
  22180. static CreateTorusKnot(options: {
  22181. radius?: number;
  22182. tube?: number;
  22183. radialSegments?: number;
  22184. tubularSegments?: number;
  22185. p?: number;
  22186. q?: number;
  22187. sideOrientation?: number;
  22188. frontUVs?: Vector4;
  22189. backUVs?: Vector4;
  22190. }): VertexData;
  22191. /**
  22192. * Compute normals for given positions and indices
  22193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22197. * * facetNormals : optional array of facet normals (vector3)
  22198. * * facetPositions : optional array of facet positions (vector3)
  22199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22201. * * bInfo : optional bounding info, required for facetPartitioning computation
  22202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22204. * * useRightHandedSystem: optional boolean to for right handed system computation
  22205. * * depthSort : optional boolean to enable the facet depth sort computation
  22206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22208. */
  22209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22210. facetNormals?: any;
  22211. facetPositions?: any;
  22212. facetPartitioning?: any;
  22213. ratio?: number;
  22214. bInfo?: any;
  22215. bbSize?: Vector3;
  22216. subDiv?: any;
  22217. useRightHandedSystem?: boolean;
  22218. depthSort?: boolean;
  22219. distanceTo?: Vector3;
  22220. depthSortedFacets?: any;
  22221. }): void;
  22222. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22223. /**
  22224. * Applies VertexData created from the imported parameters to the geometry
  22225. * @param parsedVertexData the parsed data from an imported file
  22226. * @param geometry the geometry to apply the VertexData to
  22227. */
  22228. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22229. }
  22230. }
  22231. declare module BABYLON {
  22232. /**
  22233. * Class containing static functions to help procedurally build meshes
  22234. */
  22235. class MeshBuilder {
  22236. private static updateSideOrientation(orientation?);
  22237. /**
  22238. * Creates a box mesh
  22239. * * The parameter `size` sets the size (float) of each box side (default 1)
  22240. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22241. * * 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)
  22242. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22244. * * 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
  22245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22246. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22247. * @param name defines the name of the mesh
  22248. * @param options defines the options used to create the mesh
  22249. * @param scene defines the hosting scene
  22250. * @returns the box mesh
  22251. */
  22252. static CreateBox(name: string, options: {
  22253. size?: number;
  22254. width?: number;
  22255. height?: number;
  22256. depth?: number;
  22257. faceUV?: Vector4[];
  22258. faceColors?: Color4[];
  22259. sideOrientation?: number;
  22260. frontUVs?: Vector4;
  22261. backUVs?: Vector4;
  22262. updatable?: boolean;
  22263. }, scene?: Nullable<Scene>): Mesh;
  22264. /**
  22265. * Creates a sphere mesh
  22266. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22267. * * 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`)
  22268. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22269. * * 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
  22270. * * 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)
  22271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22272. * * 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
  22273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22274. * @param name defines the name of the mesh
  22275. * @param options defines the options used to create the mesh
  22276. * @param scene defines the hosting scene
  22277. * @returns the sphere mesh
  22278. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22279. */
  22280. static CreateSphere(name: string, options: {
  22281. segments?: number;
  22282. diameter?: number;
  22283. diameterX?: number;
  22284. diameterY?: number;
  22285. diameterZ?: number;
  22286. arc?: number;
  22287. slice?: number;
  22288. sideOrientation?: number;
  22289. frontUVs?: Vector4;
  22290. backUVs?: Vector4;
  22291. updatable?: boolean;
  22292. }, scene: any): Mesh;
  22293. /**
  22294. * Creates a plane polygonal mesh. By default, this is a disc
  22295. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22296. * * 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
  22297. * * 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
  22298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22299. * * 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
  22300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22301. * @param name defines the name of the mesh
  22302. * @param options defines the options used to create the mesh
  22303. * @param scene defines the hosting scene
  22304. * @returns the plane polygonal mesh
  22305. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22306. */
  22307. static CreateDisc(name: string, options: {
  22308. radius?: number;
  22309. tessellation?: number;
  22310. arc?: number;
  22311. updatable?: boolean;
  22312. sideOrientation?: number;
  22313. frontUVs?: Vector4;
  22314. backUVs?: Vector4;
  22315. }, scene?: Nullable<Scene>): Mesh;
  22316. /**
  22317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22319. * * 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`)
  22320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22321. * * 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
  22322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22323. * * 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
  22324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22325. * @param name defines the name of the mesh
  22326. * @param options defines the options used to create the mesh
  22327. * @param scene defines the hosting scene
  22328. * @returns the icosahedron mesh
  22329. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22330. */
  22331. static CreateIcoSphere(name: string, options: {
  22332. radius?: number;
  22333. radiusX?: number;
  22334. radiusY?: number;
  22335. radiusZ?: number;
  22336. flat?: boolean;
  22337. subdivisions?: number;
  22338. sideOrientation?: number;
  22339. frontUVs?: Vector4;
  22340. backUVs?: Vector4;
  22341. updatable?: boolean;
  22342. }, scene: Scene): Mesh;
  22343. /**
  22344. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22345. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22346. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22347. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22348. * * 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
  22349. * * 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
  22350. * * 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
  22351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22352. * * 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
  22353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22354. * * 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
  22355. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22356. * * 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
  22357. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22359. * @param name defines the name of the mesh
  22360. * @param options defines the options used to create the mesh
  22361. * @param scene defines the hosting scene
  22362. * @returns the ribbon mesh
  22363. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22364. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22365. */
  22366. static CreateRibbon(name: string, options: {
  22367. pathArray: Vector3[][];
  22368. closeArray?: boolean;
  22369. closePath?: boolean;
  22370. offset?: number;
  22371. updatable?: boolean;
  22372. sideOrientation?: number;
  22373. frontUVs?: Vector4;
  22374. backUVs?: Vector4;
  22375. instance?: Mesh;
  22376. invertUV?: boolean;
  22377. uvs?: Vector2[];
  22378. colors?: Color4[];
  22379. }, scene?: Nullable<Scene>): Mesh;
  22380. /**
  22381. * Creates a cylinder or a cone mesh
  22382. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22383. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22384. * * 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.
  22385. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22386. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22387. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22388. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22389. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22390. * * 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).
  22391. * * 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
  22392. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22393. * * 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
  22394. * * 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.
  22395. * * If `enclose` is false, a ring surface is one element.
  22396. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22397. * * 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
  22398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22399. * * 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
  22400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22401. * @param name defines the name of the mesh
  22402. * @param options defines the options used to create the mesh
  22403. * @param scene defines the hosting scene
  22404. * @returns the cylinder mesh
  22405. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22406. */
  22407. static CreateCylinder(name: string, options: {
  22408. height?: number;
  22409. diameterTop?: number;
  22410. diameterBottom?: number;
  22411. diameter?: number;
  22412. tessellation?: number;
  22413. subdivisions?: number;
  22414. arc?: number;
  22415. faceColors?: Color4[];
  22416. faceUV?: Vector4[];
  22417. updatable?: boolean;
  22418. hasRings?: boolean;
  22419. enclose?: boolean;
  22420. sideOrientation?: number;
  22421. frontUVs?: Vector4;
  22422. backUVs?: Vector4;
  22423. }, scene: any): Mesh;
  22424. /**
  22425. * Creates a torus mesh
  22426. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22427. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22428. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22430. * * 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
  22431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22432. * @param name defines the name of the mesh
  22433. * @param options defines the options used to create the mesh
  22434. * @param scene defines the hosting scene
  22435. * @returns the torus mesh
  22436. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22437. */
  22438. static CreateTorus(name: string, options: {
  22439. diameter?: number;
  22440. thickness?: number;
  22441. tessellation?: number;
  22442. updatable?: boolean;
  22443. sideOrientation?: number;
  22444. frontUVs?: Vector4;
  22445. backUVs?: Vector4;
  22446. }, scene: any): Mesh;
  22447. /**
  22448. * Creates a torus knot mesh
  22449. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22450. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22451. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22452. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22454. * * 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
  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. * @param name defines the name of the mesh
  22457. * @param options defines the options used to create the mesh
  22458. * @param scene defines the hosting scene
  22459. * @returns the torus knot mesh
  22460. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22461. */
  22462. static CreateTorusKnot(name: string, options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. updatable?: boolean;
  22470. sideOrientation?: number;
  22471. frontUVs?: Vector4;
  22472. backUVs?: Vector4;
  22473. }, scene: any): Mesh;
  22474. /**
  22475. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22476. * * 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
  22477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22478. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22479. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22480. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22482. * * 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
  22483. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22485. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22486. * @param name defines the name of the new line system
  22487. * @param options defines the options used to create the line system
  22488. * @param scene defines the hosting scene
  22489. * @returns a new line system mesh
  22490. */
  22491. static CreateLineSystem(name: string, options: {
  22492. lines: Vector3[][];
  22493. updatable?: boolean;
  22494. instance?: Nullable<LinesMesh>;
  22495. colors?: Nullable<Color4[][]>;
  22496. useVertexAlpha?: boolean;
  22497. }, scene: Nullable<Scene>): LinesMesh;
  22498. /**
  22499. * Creates a line mesh
  22500. * 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
  22501. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22502. * * The parameter `points` is an array successive Vector3
  22503. * * 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
  22504. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22505. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22506. * * When updating an instance, remember that only point positions can change, not the number of points
  22507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22508. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22509. * @param name defines the name of the new line system
  22510. * @param options defines the options used to create the line system
  22511. * @param scene defines the hosting scene
  22512. * @returns a new line mesh
  22513. */
  22514. static CreateLines(name: string, options: {
  22515. points: Vector3[];
  22516. updatable?: boolean;
  22517. instance?: Nullable<LinesMesh>;
  22518. colors?: Color4[];
  22519. useVertexAlpha?: boolean;
  22520. }, scene?: Nullable<Scene>): LinesMesh;
  22521. /**
  22522. * Creates a dashed line mesh
  22523. * * 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
  22524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22525. * * The parameter `points` is an array successive Vector3
  22526. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22527. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22528. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22529. * * 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
  22530. * * When updating an instance, remember that only point positions can change, not the number of points
  22531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22532. * @param name defines the name of the mesh
  22533. * @param options defines the options used to create the mesh
  22534. * @param scene defines the hosting scene
  22535. * @returns the dashed line mesh
  22536. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22537. */
  22538. static CreateDashedLines(name: string, options: {
  22539. points: Vector3[];
  22540. dashSize?: number;
  22541. gapSize?: number;
  22542. dashNb?: number;
  22543. updatable?: boolean;
  22544. instance?: LinesMesh;
  22545. }, scene?: Nullable<Scene>): LinesMesh;
  22546. /**
  22547. * 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.
  22548. * * 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.
  22549. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22550. * * 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.
  22551. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22552. * * 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
  22553. * * 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
  22554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22556. * * 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
  22557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22559. * @param name defines the name of the mesh
  22560. * @param options defines the options used to create the mesh
  22561. * @param scene defines the hosting scene
  22562. * @returns the extruded shape mesh
  22563. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22564. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22565. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22566. */
  22567. static ExtrudeShape(name: string, options: {
  22568. shape: Vector3[];
  22569. path: Vector3[];
  22570. scale?: number;
  22571. rotation?: number;
  22572. cap?: number;
  22573. updatable?: boolean;
  22574. sideOrientation?: number;
  22575. frontUVs?: Vector4;
  22576. backUVs?: Vector4;
  22577. instance?: Mesh;
  22578. invertUV?: boolean;
  22579. }, scene?: Nullable<Scene>): Mesh;
  22580. /**
  22581. * Creates an custom extruded shape mesh.
  22582. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22583. * * 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.
  22584. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22585. * * 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
  22586. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22587. * * 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
  22588. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22589. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22590. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22591. * * 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
  22592. * * 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
  22593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22595. * * 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
  22596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22598. * @param name defines the name of the mesh
  22599. * @param options defines the options used to create the mesh
  22600. * @param scene defines the hosting scene
  22601. * @returns the custom extruded shape mesh
  22602. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22603. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22604. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22605. */
  22606. static ExtrudeShapeCustom(name: string, options: {
  22607. shape: Vector3[];
  22608. path: Vector3[];
  22609. scaleFunction?: any;
  22610. rotationFunction?: any;
  22611. ribbonCloseArray?: boolean;
  22612. ribbonClosePath?: boolean;
  22613. cap?: number;
  22614. updatable?: boolean;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. instance?: Mesh;
  22619. invertUV?: boolean;
  22620. }, scene: Scene): Mesh;
  22621. /**
  22622. * Creates lathe mesh.
  22623. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22624. * * 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
  22625. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22626. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22627. * * 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
  22628. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22629. * * 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
  22630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22631. * * 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
  22632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22634. * @param name defines the name of the mesh
  22635. * @param options defines the options used to create the mesh
  22636. * @param scene defines the hosting scene
  22637. * @returns the lathe mesh
  22638. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22639. */
  22640. static CreateLathe(name: string, options: {
  22641. shape: Vector3[];
  22642. radius?: number;
  22643. tessellation?: number;
  22644. arc?: number;
  22645. closed?: boolean;
  22646. updatable?: boolean;
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. cap?: number;
  22651. invertUV?: boolean;
  22652. }, scene: Scene): Mesh;
  22653. /**
  22654. * Creates a plane mesh
  22655. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22656. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22657. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22659. * * 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
  22660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22661. * @param name defines the name of the mesh
  22662. * @param options defines the options used to create the mesh
  22663. * @param scene defines the hosting scene
  22664. * @returns the plane mesh
  22665. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22666. */
  22667. static CreatePlane(name: string, options: {
  22668. size?: number;
  22669. width?: number;
  22670. height?: number;
  22671. sideOrientation?: number;
  22672. frontUVs?: Vector4;
  22673. backUVs?: Vector4;
  22674. updatable?: boolean;
  22675. sourcePlane?: Plane;
  22676. }, scene: Scene): Mesh;
  22677. /**
  22678. * Creates a ground mesh
  22679. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22680. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22682. * @param name defines the name of the mesh
  22683. * @param options defines the options used to create the mesh
  22684. * @param scene defines the hosting scene
  22685. * @returns the ground mesh
  22686. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22687. */
  22688. static CreateGround(name: string, options: {
  22689. width?: number;
  22690. height?: number;
  22691. subdivisions?: number;
  22692. subdivisionsX?: number;
  22693. subdivisionsY?: number;
  22694. updatable?: boolean;
  22695. }, scene: any): Mesh;
  22696. /**
  22697. * Creates a tiled ground mesh
  22698. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22699. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22700. * * 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
  22701. * * 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
  22702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22703. * @param name defines the name of the mesh
  22704. * @param options defines the options used to create the mesh
  22705. * @param scene defines the hosting scene
  22706. * @returns the tiled ground mesh
  22707. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22708. */
  22709. static CreateTiledGround(name: string, options: {
  22710. xmin: number;
  22711. zmin: number;
  22712. xmax: number;
  22713. zmax: number;
  22714. subdivisions?: {
  22715. w: number;
  22716. h: number;
  22717. };
  22718. precision?: {
  22719. w: number;
  22720. h: number;
  22721. };
  22722. updatable?: boolean;
  22723. }, scene: Scene): Mesh;
  22724. /**
  22725. * Creates a ground mesh from a height map
  22726. * * The parameter `url` sets the URL of the height map image resource.
  22727. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22728. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22729. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22730. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22731. * * 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.
  22732. * * 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).
  22733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22734. * @param name defines the name of the mesh
  22735. * @param url defines the url to the height map
  22736. * @param options defines the options used to create the mesh
  22737. * @param scene defines the hosting scene
  22738. * @returns the ground mesh
  22739. * @see http://doc.babylonjs.com/babylon101/height_map
  22740. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22741. */
  22742. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22743. width?: number;
  22744. height?: number;
  22745. subdivisions?: number;
  22746. minHeight?: number;
  22747. maxHeight?: number;
  22748. colorFilter?: Color3;
  22749. updatable?: boolean;
  22750. onReady?: (mesh: GroundMesh) => void;
  22751. }, scene: Scene): GroundMesh;
  22752. /**
  22753. * Creates a polygon mesh
  22754. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22755. * * 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
  22756. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22758. * * 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)
  22759. * * Remember you can only change the shape positions, not their number when updating a polygon
  22760. * @param name defines the name of the mesh
  22761. * @param options defines the options used to create the mesh
  22762. * @param scene defines the hosting scene
  22763. * @returns the polygon mesh
  22764. */
  22765. static CreatePolygon(name: string, options: {
  22766. shape: Vector3[];
  22767. holes?: Vector3[][];
  22768. depth?: number;
  22769. faceUV?: Vector4[];
  22770. faceColors?: Color4[];
  22771. updatable?: boolean;
  22772. sideOrientation?: number;
  22773. frontUVs?: Vector4;
  22774. backUVs?: Vector4;
  22775. }, scene: Scene): Mesh;
  22776. /**
  22777. * Creates an extruded polygon mesh, with depth in the Y direction.
  22778. * * 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)
  22779. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22780. * @param name defines the name of the mesh
  22781. * @param options defines the options used to create the mesh
  22782. * @param scene defines the hosting scene
  22783. * @returns the polygon mesh
  22784. */
  22785. static ExtrudePolygon(name: string, options: {
  22786. shape: Vector3[];
  22787. holes?: Vector3[][];
  22788. depth?: number;
  22789. faceUV?: Vector4[];
  22790. faceColors?: Color4[];
  22791. updatable?: boolean;
  22792. sideOrientation?: number;
  22793. frontUVs?: Vector4;
  22794. backUVs?: Vector4;
  22795. }, scene: Scene): Mesh;
  22796. /**
  22797. * Creates a tube mesh.
  22798. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22799. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22800. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22801. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22802. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22803. * * 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)
  22804. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22805. * * 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
  22806. * * 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
  22807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22808. * * 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
  22809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22811. * @param name defines the name of the mesh
  22812. * @param options defines the options used to create the mesh
  22813. * @param scene defines the hosting scene
  22814. * @returns the tube mesh
  22815. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22816. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22817. */
  22818. static CreateTube(name: string, options: {
  22819. path: Vector3[];
  22820. radius?: number;
  22821. tessellation?: number;
  22822. radiusFunction?: {
  22823. (i: number, distance: number): number;
  22824. };
  22825. cap?: number;
  22826. arc?: number;
  22827. updatable?: boolean;
  22828. sideOrientation?: number;
  22829. frontUVs?: Vector4;
  22830. backUVs?: Vector4;
  22831. instance?: Mesh;
  22832. invertUV?: boolean;
  22833. }, scene: Scene): Mesh;
  22834. /**
  22835. * Creates a polyhedron mesh
  22836. * * 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
  22837. * * The parameter `size` (positive float, default 1) sets the polygon size
  22838. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22839. * * 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`
  22840. * * 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
  22841. * * 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)`)
  22842. * * 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
  22843. * * 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
  22844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22845. * * 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
  22846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22847. * @param name defines the name of the mesh
  22848. * @param options defines the options used to create the mesh
  22849. * @param scene defines the hosting scene
  22850. * @returns the polyhedron mesh
  22851. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22852. */
  22853. static CreatePolyhedron(name: string, options: {
  22854. type?: number;
  22855. size?: number;
  22856. sizeX?: number;
  22857. sizeY?: number;
  22858. sizeZ?: number;
  22859. custom?: any;
  22860. faceUV?: Vector4[];
  22861. faceColors?: Color4[];
  22862. flat?: boolean;
  22863. updatable?: boolean;
  22864. sideOrientation?: number;
  22865. frontUVs?: Vector4;
  22866. backUVs?: Vector4;
  22867. }, scene: Scene): Mesh;
  22868. /**
  22869. * Creates a decal mesh.
  22870. * 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
  22871. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22872. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22873. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22874. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22875. * @param name defines the name of the mesh
  22876. * @param sourceMesh defines the mesh where the decal must be applied
  22877. * @param options defines the options used to create the mesh
  22878. * @param scene defines the hosting scene
  22879. * @returns the decal mesh
  22880. * @see http://doc.babylonjs.com/how_to/decals
  22881. */
  22882. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22883. position?: Vector3;
  22884. normal?: Vector3;
  22885. size?: Vector3;
  22886. angle?: number;
  22887. }): Mesh;
  22888. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22889. }
  22890. }
  22891. declare module BABYLON {
  22892. class MeshLODLevel {
  22893. distance: number;
  22894. mesh: Nullable<Mesh>;
  22895. constructor(distance: number, mesh: Nullable<Mesh>);
  22896. }
  22897. }
  22898. declare module BABYLON {
  22899. /**
  22900. * A simplifier interface for future simplification implementations.
  22901. */
  22902. interface ISimplifier {
  22903. /**
  22904. * Simplification of a given mesh according to the given settings.
  22905. * Since this requires computation, it is assumed that the function runs async.
  22906. * @param settings The settings of the simplification, including quality and distance
  22907. * @param successCallback A callback that will be called after the mesh was simplified.
  22908. * @param errorCallback in case of an error, this callback will be called. optional.
  22909. */
  22910. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22911. }
  22912. /**
  22913. * Expected simplification settings.
  22914. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22915. */
  22916. interface ISimplificationSettings {
  22917. quality: number;
  22918. distance: number;
  22919. optimizeMesh?: boolean;
  22920. }
  22921. class SimplificationSettings implements ISimplificationSettings {
  22922. quality: number;
  22923. distance: number;
  22924. optimizeMesh: boolean | undefined;
  22925. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22926. }
  22927. interface ISimplificationTask {
  22928. settings: Array<ISimplificationSettings>;
  22929. simplificationType: SimplificationType;
  22930. mesh: Mesh;
  22931. successCallback?: () => void;
  22932. parallelProcessing: boolean;
  22933. }
  22934. class SimplificationQueue {
  22935. private _simplificationArray;
  22936. running: boolean;
  22937. constructor();
  22938. addTask(task: ISimplificationTask): void;
  22939. executeNext(): void;
  22940. runSimplification(task: ISimplificationTask): void;
  22941. private getSimplifier(task);
  22942. }
  22943. /**
  22944. * The implemented types of simplification
  22945. * At the moment only Quadratic Error Decimation is implemented
  22946. */
  22947. enum SimplificationType {
  22948. /** Quadratic error decimation */
  22949. QUADRATIC = 0,
  22950. }
  22951. class DecimationTriangle {
  22952. vertices: Array<DecimationVertex>;
  22953. normal: Vector3;
  22954. error: Array<number>;
  22955. deleted: boolean;
  22956. isDirty: boolean;
  22957. borderFactor: number;
  22958. deletePending: boolean;
  22959. originalOffset: number;
  22960. constructor(vertices: Array<DecimationVertex>);
  22961. }
  22962. class DecimationVertex {
  22963. position: Vector3;
  22964. id: number;
  22965. q: QuadraticMatrix;
  22966. isBorder: boolean;
  22967. triangleStart: number;
  22968. triangleCount: number;
  22969. originalOffsets: Array<number>;
  22970. constructor(position: Vector3, id: number);
  22971. updatePosition(newPosition: Vector3): void;
  22972. }
  22973. class QuadraticMatrix {
  22974. data: Array<number>;
  22975. constructor(data?: Array<number>);
  22976. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22977. addInPlace(matrix: QuadraticMatrix): void;
  22978. addArrayInPlace(data: Array<number>): void;
  22979. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22980. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22981. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22982. }
  22983. class Reference {
  22984. vertexId: number;
  22985. triangleId: number;
  22986. constructor(vertexId: number, triangleId: number);
  22987. }
  22988. /**
  22989. * An implementation of the Quadratic Error simplification algorithm.
  22990. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22991. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22992. * @author RaananW
  22993. */
  22994. class QuadraticErrorSimplification implements ISimplifier {
  22995. private _mesh;
  22996. private triangles;
  22997. private vertices;
  22998. private references;
  22999. private _reconstructedMesh;
  23000. syncIterations: number;
  23001. aggressiveness: number;
  23002. decimationIterations: number;
  23003. boundingBoxEpsilon: number;
  23004. constructor(_mesh: Mesh);
  23005. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23006. private runDecimation(settings, submeshIndex, successCallback);
  23007. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23008. private init(callback);
  23009. private reconstructMesh(submeshIndex);
  23010. private initDecimatedMesh();
  23011. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23012. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23013. private identifyBorder();
  23014. private updateMesh(identifyBorders?);
  23015. private vertexError(q, point);
  23016. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23017. }
  23018. }
  23019. declare module BABYLON {
  23020. class Polygon {
  23021. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23022. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23023. static Parse(input: string): Vector2[];
  23024. static StartingAt(x: number, y: number): Path2;
  23025. }
  23026. class PolygonMeshBuilder {
  23027. private _points;
  23028. private _outlinepoints;
  23029. private _holes;
  23030. private _name;
  23031. private _scene;
  23032. private _epoints;
  23033. private _eholes;
  23034. private _addToepoint(points);
  23035. constructor(name: string, contours: Path2, scene: Scene);
  23036. constructor(name: string, contours: Vector2[], scene: Scene);
  23037. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23038. build(updatable?: boolean, depth?: number): Mesh;
  23039. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. class BaseSubMesh {
  23044. _materialDefines: Nullable<MaterialDefines>;
  23045. _materialEffect: Nullable<Effect>;
  23046. readonly effect: Nullable<Effect>;
  23047. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23048. }
  23049. class SubMesh extends BaseSubMesh implements ICullable {
  23050. materialIndex: number;
  23051. verticesStart: number;
  23052. verticesCount: number;
  23053. indexStart: number;
  23054. indexCount: number;
  23055. linesIndexCount: number;
  23056. private _mesh;
  23057. private _renderingMesh;
  23058. private _boundingInfo;
  23059. private _linesIndexBuffer;
  23060. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23061. _trianglePlanes: Plane[];
  23062. _lastColliderTransformMatrix: Matrix;
  23063. _renderId: number;
  23064. _alphaIndex: number;
  23065. _distanceToCamera: number;
  23066. _id: number;
  23067. private _currentMaterial;
  23068. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23069. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23070. readonly IsGlobal: boolean;
  23071. /**
  23072. * Returns the submesh BoudingInfo object.
  23073. */
  23074. getBoundingInfo(): BoundingInfo;
  23075. /**
  23076. * Sets the submesh BoundingInfo.
  23077. * Return the SubMesh.
  23078. */
  23079. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23080. /**
  23081. * Returns the mesh of the current submesh.
  23082. */
  23083. getMesh(): AbstractMesh;
  23084. /**
  23085. * Returns the rendering mesh of the submesh.
  23086. */
  23087. getRenderingMesh(): Mesh;
  23088. /**
  23089. * Returns the submesh material.
  23090. */
  23091. getMaterial(): Nullable<Material>;
  23092. /**
  23093. * Sets a new updated BoundingInfo object to the submesh.
  23094. * Returns the SubMesh.
  23095. */
  23096. refreshBoundingInfo(): SubMesh;
  23097. _checkCollision(collider: Collider): boolean;
  23098. /**
  23099. * Updates the submesh BoundingInfo.
  23100. * Returns the Submesh.
  23101. */
  23102. updateBoundingInfo(world: Matrix): SubMesh;
  23103. /**
  23104. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23105. * Boolean returned.
  23106. */
  23107. isInFrustum(frustumPlanes: Plane[]): boolean;
  23108. /**
  23109. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23110. * Boolean returned.
  23111. */
  23112. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23113. /**
  23114. * Renders the submesh.
  23115. * Returns it.
  23116. */
  23117. render(enableAlphaMode: boolean): SubMesh;
  23118. /**
  23119. * Returns a new Index Buffer.
  23120. * Type returned : WebGLBuffer.
  23121. */
  23122. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23123. /**
  23124. * True is the passed Ray intersects the submesh bounding box.
  23125. * Boolean returned.
  23126. */
  23127. canIntersects(ray: Ray): boolean;
  23128. /**
  23129. * Returns an object IntersectionInfo.
  23130. */
  23131. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23132. _rebuild(): void;
  23133. /**
  23134. * Creates a new Submesh from the passed Mesh.
  23135. */
  23136. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23137. /**
  23138. * Disposes the Submesh.
  23139. * Returns nothing.
  23140. */
  23141. dispose(): void;
  23142. /**
  23143. * Creates a new Submesh from the passed parameters :
  23144. * - materialIndex (integer) : the index of the main mesh material.
  23145. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23146. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23147. * - mesh (Mesh) : the main mesh to create the submesh from.
  23148. * - renderingMesh (optional Mesh) : rendering mesh.
  23149. */
  23150. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23151. }
  23152. }
  23153. declare module BABYLON {
  23154. class TransformNode extends Node {
  23155. static BILLBOARDMODE_NONE: number;
  23156. static BILLBOARDMODE_X: number;
  23157. static BILLBOARDMODE_Y: number;
  23158. static BILLBOARDMODE_Z: number;
  23159. static BILLBOARDMODE_ALL: number;
  23160. private _forward;
  23161. private _forwardInverted;
  23162. private _up;
  23163. private _right;
  23164. private _rightInverted;
  23165. private _rotation;
  23166. private _rotationQuaternion;
  23167. protected _scaling: Vector3;
  23168. protected _isDirty: boolean;
  23169. private _transformToBoneReferal;
  23170. /**
  23171. * Set the billboard mode. Default is 0.
  23172. *
  23173. * | Value | Type | Description |
  23174. * | --- | --- | --- |
  23175. * | 0 | BILLBOARDMODE_NONE | |
  23176. * | 1 | BILLBOARDMODE_X | |
  23177. * | 2 | BILLBOARDMODE_Y | |
  23178. * | 4 | BILLBOARDMODE_Z | |
  23179. * | 7 | BILLBOARDMODE_ALL | |
  23180. *
  23181. */
  23182. billboardMode: number;
  23183. scalingDeterminant: number;
  23184. infiniteDistance: boolean;
  23185. /**
  23186. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23187. * By default the system will update normals to compensate
  23188. */
  23189. ignoreNonUniformScaling: boolean;
  23190. position: Vector3;
  23191. _poseMatrix: Matrix;
  23192. private _localWorld;
  23193. _worldMatrix: Matrix;
  23194. _worldMatrixDeterminant: number;
  23195. private _absolutePosition;
  23196. private _pivotMatrix;
  23197. private _pivotMatrixInverse;
  23198. private _postMultiplyPivotMatrix;
  23199. protected _isWorldMatrixFrozen: boolean;
  23200. /**
  23201. * An event triggered after the world matrix is updated
  23202. */
  23203. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23204. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23205. /**
  23206. * Gets a string idenfifying the name of the class
  23207. * @returns "TransformNode" string
  23208. */
  23209. getClassName(): string;
  23210. /**
  23211. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23212. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23213. * Default : (0.0, 0.0, 0.0)
  23214. */
  23215. rotation: Vector3;
  23216. /**
  23217. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23218. * Default : (1.0, 1.0, 1.0)
  23219. */
  23220. /**
  23221. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23222. * Default : (1.0, 1.0, 1.0)
  23223. */
  23224. scaling: Vector3;
  23225. /**
  23226. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23227. * It's null by default.
  23228. * 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)
  23229. */
  23230. rotationQuaternion: Nullable<Quaternion>;
  23231. /**
  23232. * The forward direction of that transform in world space.
  23233. */
  23234. readonly forward: Vector3;
  23235. /**
  23236. * The up direction of that transform in world space.
  23237. */
  23238. readonly up: Vector3;
  23239. /**
  23240. * The right direction of that transform in world space.
  23241. */
  23242. readonly right: Vector3;
  23243. /**
  23244. * Returns the latest update of the World matrix
  23245. * Returns a Matrix.
  23246. */
  23247. getWorldMatrix(): Matrix;
  23248. /** @hidden */
  23249. _getWorldMatrixDeterminant(): number;
  23250. /**
  23251. * Returns directly the latest state of the mesh World matrix.
  23252. * A Matrix is returned.
  23253. */
  23254. readonly worldMatrixFromCache: Matrix;
  23255. /**
  23256. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23257. * Returns the TransformNode.
  23258. */
  23259. updatePoseMatrix(matrix: Matrix): TransformNode;
  23260. /**
  23261. * Returns the mesh Pose matrix.
  23262. * Returned object : Matrix
  23263. */
  23264. getPoseMatrix(): Matrix;
  23265. _isSynchronized(): boolean;
  23266. _initCache(): void;
  23267. markAsDirty(property: string): TransformNode;
  23268. /**
  23269. * Returns the current mesh absolute position.
  23270. * Retuns a Vector3.
  23271. */
  23272. readonly absolutePosition: Vector3;
  23273. /**
  23274. * Sets a new matrix to apply before all other transformation
  23275. * @param matrix defines the transform matrix
  23276. * @returns the current TransformNode
  23277. */
  23278. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23279. /**
  23280. * Sets a new pivot matrix to the current node
  23281. * @param matrix defines the new pivot matrix to use
  23282. * @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
  23283. * @returns the current TransformNode
  23284. */
  23285. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23286. /**
  23287. * Returns the mesh pivot matrix.
  23288. * Default : Identity.
  23289. * A Matrix is returned.
  23290. */
  23291. getPivotMatrix(): Matrix;
  23292. /**
  23293. * Prevents the World matrix to be computed any longer.
  23294. * Returns the TransformNode.
  23295. */
  23296. freezeWorldMatrix(): TransformNode;
  23297. /**
  23298. * Allows back the World matrix computation.
  23299. * Returns the TransformNode.
  23300. */
  23301. unfreezeWorldMatrix(): this;
  23302. /**
  23303. * True if the World matrix has been frozen.
  23304. * Returns a boolean.
  23305. */
  23306. readonly isWorldMatrixFrozen: boolean;
  23307. /**
  23308. * Retuns the mesh absolute position in the World.
  23309. * Returns a Vector3.
  23310. */
  23311. getAbsolutePosition(): Vector3;
  23312. /**
  23313. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23314. * Returns the TransformNode.
  23315. */
  23316. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23317. /**
  23318. * Sets the mesh position in its local space.
  23319. * Returns the TransformNode.
  23320. */
  23321. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23322. /**
  23323. * Returns the mesh position in the local space from the current World matrix values.
  23324. * Returns a new Vector3.
  23325. */
  23326. getPositionExpressedInLocalSpace(): Vector3;
  23327. /**
  23328. * Translates the mesh along the passed Vector3 in its local space.
  23329. * Returns the TransformNode.
  23330. */
  23331. locallyTranslate(vector3: Vector3): TransformNode;
  23332. private static _lookAtVectorCache;
  23333. /**
  23334. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23335. * @param targetPoint the position (must be in same space as current mesh) to look at
  23336. * @param yawCor optional yaw (y-axis) correction in radians
  23337. * @param pitchCor optional pitch (x-axis) correction in radians
  23338. * @param rollCor optional roll (z-axis) correction in radians
  23339. * @param space the choosen space of the target
  23340. * @returns the TransformNode.
  23341. */
  23342. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23343. /**
  23344. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23345. * This Vector3 is expressed in the World space.
  23346. */
  23347. getDirection(localAxis: Vector3): Vector3;
  23348. /**
  23349. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23350. * localAxis is expressed in the mesh local space.
  23351. * result is computed in the Wordl space from the mesh World matrix.
  23352. * Returns the TransformNode.
  23353. */
  23354. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23355. /**
  23356. * Sets a new pivot point to the current node
  23357. * @param point defines the new pivot point to use
  23358. * @param space defines if the point is in world or local space (local by default)
  23359. * @returns the current TransformNode
  23360. */
  23361. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23362. /**
  23363. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23364. */
  23365. getPivotPoint(): Vector3;
  23366. /**
  23367. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23368. * Returns the TransformNode.
  23369. */
  23370. getPivotPointToRef(result: Vector3): TransformNode;
  23371. /**
  23372. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23373. */
  23374. getAbsolutePivotPoint(): Vector3;
  23375. /**
  23376. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23377. * Returns the TransformNode.
  23378. */
  23379. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23380. /**
  23381. * Defines the passed node as the parent of the current node.
  23382. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23383. * Returns the TransformNode.
  23384. */
  23385. setParent(node: Nullable<Node>): TransformNode;
  23386. private _nonUniformScaling;
  23387. readonly nonUniformScaling: boolean;
  23388. _updateNonUniformScalingState(value: boolean): boolean;
  23389. /**
  23390. * Attach the current TransformNode to another TransformNode associated with a bone
  23391. * @param bone Bone affecting the TransformNode
  23392. * @param affectedTransformNode TransformNode associated with the bone
  23393. */
  23394. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23395. detachFromBone(): TransformNode;
  23396. private static _rotationAxisCache;
  23397. /**
  23398. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23399. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23400. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23401. * The passed axis is also normalized.
  23402. * Returns the TransformNode.
  23403. */
  23404. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23405. /**
  23406. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23407. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23408. * The passed axis is also normalized.
  23409. * Returns the TransformNode.
  23410. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23411. */
  23412. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23413. /**
  23414. * Translates the mesh along the axis vector for the passed distance in the given space.
  23415. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23416. * Returns the TransformNode.
  23417. */
  23418. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23419. /**
  23420. * Adds a rotation step to the mesh current rotation.
  23421. * x, y, z are Euler angles expressed in radians.
  23422. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23423. * This means this rotation is made in the mesh local space only.
  23424. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23425. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23426. * ```javascript
  23427. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23428. * ```
  23429. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23430. * 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.
  23431. * Returns the TransformNode.
  23432. */
  23433. addRotation(x: number, y: number, z: number): TransformNode;
  23434. /**
  23435. * Computes the mesh World matrix and returns it.
  23436. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23437. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23438. * If the parameter `force`is set to `true`, the actual computation is done.
  23439. * Returns the mesh World Matrix.
  23440. */
  23441. computeWorldMatrix(force?: boolean): Matrix;
  23442. protected _afterComputeWorldMatrix(): void;
  23443. /**
  23444. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23445. * @param func: callback function to add
  23446. *
  23447. * Returns the TransformNode.
  23448. */
  23449. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23450. /**
  23451. * Removes a registered callback function.
  23452. * Returns the TransformNode.
  23453. */
  23454. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23455. /**
  23456. * Clone the current transform node
  23457. * Returns the new transform node
  23458. * @param name Name of the new clone
  23459. * @param newParent New parent for the clone
  23460. * @param doNotCloneChildren Do not clone children hierarchy
  23461. */
  23462. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23463. serialize(currentSerializationObject?: any): any;
  23464. /**
  23465. * Returns a new TransformNode object parsed from the source provided.
  23466. * The parameter `parsedMesh` is the source.
  23467. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23468. */
  23469. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23470. /**
  23471. * Releases resources associated with this transform node.
  23472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23474. */
  23475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23476. }
  23477. }
  23478. declare module BABYLON {
  23479. class VertexBuffer {
  23480. /** @hidden */
  23481. _buffer: Buffer;
  23482. private _kind;
  23483. private _size;
  23484. private _ownsBuffer;
  23485. private _instanced;
  23486. private _instanceDivisor;
  23487. /**
  23488. * The byte type.
  23489. */
  23490. static readonly BYTE: number;
  23491. /**
  23492. * The unsigned byte type.
  23493. */
  23494. static readonly UNSIGNED_BYTE: number;
  23495. /**
  23496. * The short type.
  23497. */
  23498. static readonly SHORT: number;
  23499. /**
  23500. * The unsigned short type.
  23501. */
  23502. static readonly UNSIGNED_SHORT: number;
  23503. /**
  23504. * The integer type.
  23505. */
  23506. static readonly INT: number;
  23507. /**
  23508. * The unsigned integer type.
  23509. */
  23510. static readonly UNSIGNED_INT: number;
  23511. /**
  23512. * The float type.
  23513. */
  23514. static readonly FLOAT: number;
  23515. /**
  23516. * Gets or sets the instance divisor when in instanced mode
  23517. */
  23518. instanceDivisor: number;
  23519. /**
  23520. * Gets the byte stride.
  23521. */
  23522. readonly byteStride: number;
  23523. /**
  23524. * Gets the byte offset.
  23525. */
  23526. readonly byteOffset: number;
  23527. /**
  23528. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23529. */
  23530. readonly normalized: boolean;
  23531. /**
  23532. * Gets the data type of each component in the array.
  23533. */
  23534. readonly type: number;
  23535. /**
  23536. * Constructor
  23537. * @param engine the engine
  23538. * @param data the data to use for this vertex buffer
  23539. * @param kind the vertex buffer kind
  23540. * @param updatable whether the data is updatable
  23541. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23542. * @param stride the stride (optional)
  23543. * @param instanced whether the buffer is instanced (optional)
  23544. * @param offset the offset of the data (optional)
  23545. * @param size the number of components (optional)
  23546. * @param type the type of the component (optional)
  23547. * @param normalized whether the data contains normalized data (optional)
  23548. * @param useBytes set to true if stride and offset are in bytes (optional)
  23549. */
  23550. 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);
  23551. _rebuild(): void;
  23552. /**
  23553. * Returns the kind of the VertexBuffer (string).
  23554. */
  23555. getKind(): string;
  23556. /**
  23557. * Boolean : is the VertexBuffer updatable ?
  23558. */
  23559. isUpdatable(): boolean;
  23560. /**
  23561. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23562. */
  23563. getData(): Nullable<DataArray>;
  23564. /**
  23565. * Returns the WebGLBuffer associated to the VertexBuffer.
  23566. */
  23567. getBuffer(): Nullable<WebGLBuffer>;
  23568. /**
  23569. * Returns the stride as a multiple of the type byte length.
  23570. * DEPRECATED. Use byteStride instead.
  23571. */
  23572. getStrideSize(): number;
  23573. /**
  23574. * Returns the offset as a multiple of the type byte length.
  23575. * DEPRECATED. Use byteOffset instead.
  23576. */
  23577. getOffset(): number;
  23578. /**
  23579. * Returns the number of components per vertex attribute (integer).
  23580. */
  23581. getSize(): number;
  23582. /**
  23583. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23584. */
  23585. getIsInstanced(): boolean;
  23586. /**
  23587. * Returns the instancing divisor, zero for non-instanced (integer).
  23588. */
  23589. getInstanceDivisor(): number;
  23590. /**
  23591. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23592. * Returns the created WebGLBuffer.
  23593. */
  23594. create(data?: DataArray): void;
  23595. /**
  23596. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23597. * This function will create a new buffer if the current one is not updatable
  23598. * Returns the updated WebGLBuffer.
  23599. */
  23600. update(data: DataArray): void;
  23601. /**
  23602. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23603. * Returns the directly updated WebGLBuffer.
  23604. * @param data the new data
  23605. * @param offset the new offset
  23606. * @param useBytes set to true if the offset is in bytes
  23607. */
  23608. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23609. /**
  23610. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23611. */
  23612. dispose(): void;
  23613. /**
  23614. * Enumerates each value of this vertex buffer as numbers.
  23615. * @param count the number of values to enumerate
  23616. * @param callback the callback function called for each value
  23617. */
  23618. forEach(count: number, callback: (value: number, index: number) => void): void;
  23619. private static _PositionKind;
  23620. private static _NormalKind;
  23621. private static _TangentKind;
  23622. private static _UVKind;
  23623. private static _UV2Kind;
  23624. private static _UV3Kind;
  23625. private static _UV4Kind;
  23626. private static _UV5Kind;
  23627. private static _UV6Kind;
  23628. private static _ColorKind;
  23629. private static _MatricesIndicesKind;
  23630. private static _MatricesWeightsKind;
  23631. private static _MatricesIndicesExtraKind;
  23632. private static _MatricesWeightsExtraKind;
  23633. static readonly PositionKind: string;
  23634. static readonly NormalKind: string;
  23635. static readonly TangentKind: string;
  23636. static readonly UVKind: string;
  23637. static readonly UV2Kind: string;
  23638. static readonly UV3Kind: string;
  23639. static readonly UV4Kind: string;
  23640. static readonly UV5Kind: string;
  23641. static readonly UV6Kind: string;
  23642. static readonly ColorKind: string;
  23643. static readonly MatricesIndicesKind: string;
  23644. static readonly MatricesWeightsKind: string;
  23645. static readonly MatricesIndicesExtraKind: string;
  23646. static readonly MatricesWeightsExtraKind: string;
  23647. /**
  23648. * Deduces the stride given a kind.
  23649. * @param kind The kind string to deduce
  23650. * @returns The deduced stride
  23651. */
  23652. static DeduceStride(kind: string): number;
  23653. /**
  23654. * Gets the byte length of the given type.
  23655. * @param type the type
  23656. * @returns the number of bytes
  23657. */
  23658. static GetTypeByteLength(type: number): number;
  23659. /**
  23660. * Enumerates each value of the given parameters as numbers.
  23661. * @param data the data to enumerate
  23662. * @param byteOffset the byte offset of the data
  23663. * @param byteStride the byte stride of the data
  23664. * @param componentCount the number of components per element
  23665. * @param componentType the type of the component
  23666. * @param count the total number of components
  23667. * @param normalized whether the data is normalized
  23668. * @param callback the callback function called for each value
  23669. */
  23670. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23671. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23672. }
  23673. }
  23674. declare module BABYLON {
  23675. /**
  23676. * Defines a target to use with MorphTargetManager
  23677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23678. */
  23679. class MorphTarget implements IAnimatable {
  23680. /** defines the name of the target */
  23681. name: string;
  23682. /**
  23683. * Gets or sets the list of animations
  23684. */
  23685. animations: Animation[];
  23686. private _scene;
  23687. private _positions;
  23688. private _normals;
  23689. private _tangents;
  23690. private _influence;
  23691. /**
  23692. * Observable raised when the influence changes
  23693. */
  23694. onInfluenceChanged: Observable<boolean>;
  23695. /**
  23696. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23697. */
  23698. influence: number;
  23699. private _animationPropertiesOverride;
  23700. /**
  23701. * Gets or sets the animation properties override
  23702. */
  23703. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23704. /**
  23705. * Creates a new MorphTarget
  23706. * @param name defines the name of the target
  23707. * @param influence defines the influence to use
  23708. */
  23709. constructor(
  23710. /** defines the name of the target */
  23711. name: string, influence?: number, scene?: Nullable<Scene>);
  23712. /**
  23713. * Gets a boolean defining if the target contains position data
  23714. */
  23715. readonly hasPositions: boolean;
  23716. /**
  23717. * Gets a boolean defining if the target contains normal data
  23718. */
  23719. readonly hasNormals: boolean;
  23720. /**
  23721. * Gets a boolean defining if the target contains tangent data
  23722. */
  23723. readonly hasTangents: boolean;
  23724. /**
  23725. * Affects position data to this target
  23726. * @param data defines the position data to use
  23727. */
  23728. setPositions(data: Nullable<FloatArray>): void;
  23729. /**
  23730. * Gets the position data stored in this target
  23731. * @returns a FloatArray containing the position data (or null if not present)
  23732. */
  23733. getPositions(): Nullable<FloatArray>;
  23734. /**
  23735. * Affects normal data to this target
  23736. * @param data defines the normal data to use
  23737. */
  23738. setNormals(data: Nullable<FloatArray>): void;
  23739. /**
  23740. * Gets the normal data stored in this target
  23741. * @returns a FloatArray containing the normal data (or null if not present)
  23742. */
  23743. getNormals(): Nullable<FloatArray>;
  23744. /**
  23745. * Affects tangent data to this target
  23746. * @param data defines the tangent data to use
  23747. */
  23748. setTangents(data: Nullable<FloatArray>): void;
  23749. /**
  23750. * Gets the tangent data stored in this target
  23751. * @returns a FloatArray containing the tangent data (or null if not present)
  23752. */
  23753. getTangents(): Nullable<FloatArray>;
  23754. /**
  23755. * Serializes the current target into a Serialization object
  23756. * @returns the serialized object
  23757. */
  23758. serialize(): any;
  23759. /**
  23760. * Creates a new target from serialized data
  23761. * @param serializationObject defines the serialized data to use
  23762. * @returns a new MorphTarget
  23763. */
  23764. static Parse(serializationObject: any): MorphTarget;
  23765. /**
  23766. * Creates a MorphTarget from mesh data
  23767. * @param mesh defines the source mesh
  23768. * @param name defines the name to use for the new target
  23769. * @param influence defines the influence to attach to the target
  23770. * @returns a new MorphTarget
  23771. */
  23772. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23773. }
  23774. }
  23775. declare module BABYLON {
  23776. /**
  23777. * This class is used to deform meshes using morphing between different targets
  23778. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23779. */
  23780. class MorphTargetManager {
  23781. private _targets;
  23782. private _targetObservable;
  23783. private _activeTargets;
  23784. private _scene;
  23785. private _influences;
  23786. private _supportsNormals;
  23787. private _supportsTangents;
  23788. private _vertexCount;
  23789. private _uniqueId;
  23790. private _tempInfluences;
  23791. /**
  23792. * Creates a new MorphTargetManager
  23793. * @param scene defines the current scene
  23794. */
  23795. constructor(scene?: Nullable<Scene>);
  23796. /**
  23797. * Gets the unique ID of this manager
  23798. */
  23799. readonly uniqueId: number;
  23800. /**
  23801. * Gets the number of vertices handled by this manager
  23802. */
  23803. readonly vertexCount: number;
  23804. /**
  23805. * Gets a boolean indicating if this manager supports morphing of normals
  23806. */
  23807. readonly supportsNormals: boolean;
  23808. /**
  23809. * Gets a boolean indicating if this manager supports morphing of tangents
  23810. */
  23811. readonly supportsTangents: boolean;
  23812. /**
  23813. * Gets the number of targets stored in this manager
  23814. */
  23815. readonly numTargets: number;
  23816. /**
  23817. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23818. */
  23819. readonly numInfluencers: number;
  23820. /**
  23821. * Gets the list of influences (one per target)
  23822. */
  23823. readonly influences: Float32Array;
  23824. /**
  23825. * Gets the active target at specified index. An active target is a target with an influence > 0
  23826. * @param index defines the index to check
  23827. * @returns the requested target
  23828. */
  23829. getActiveTarget(index: number): MorphTarget;
  23830. /**
  23831. * Gets the target at specified index
  23832. * @param index defines the index to check
  23833. * @returns the requested target
  23834. */
  23835. getTarget(index: number): MorphTarget;
  23836. /**
  23837. * Add a new target to this manager
  23838. * @param target defines the target to add
  23839. */
  23840. addTarget(target: MorphTarget): void;
  23841. /**
  23842. * Removes a target from the manager
  23843. * @param target defines the target to remove
  23844. */
  23845. removeTarget(target: MorphTarget): void;
  23846. /**
  23847. * Serializes the current manager into a Serialization object
  23848. * @returns the serialized object
  23849. */
  23850. serialize(): any;
  23851. private _syncActiveTargets(needUpdate);
  23852. /**
  23853. * Syncrhonize the targets with all the meshes using this morph target manager
  23854. */
  23855. synchronize(): void;
  23856. /**
  23857. * Creates a new MorphTargetManager from serialized data
  23858. * @param serializationObject defines the serialized data
  23859. * @param scene defines the hosting scene
  23860. * @returns the new MorphTargetManager
  23861. */
  23862. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23863. }
  23864. }
  23865. declare module BABYLON {
  23866. /**
  23867. * This represents a GPU particle system in Babylon
  23868. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23869. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23870. */
  23871. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23872. /**
  23873. * The id of the Particle system.
  23874. */
  23875. id: string;
  23876. /**
  23877. * The friendly name of the Particle system.
  23878. */
  23879. name: string;
  23880. /**
  23881. * The emitter represents the Mesh or position we are attaching the particle system to.
  23882. */
  23883. emitter: Nullable<AbstractMesh | Vector3>;
  23884. /**
  23885. * The rendering group used by the Particle system to chose when to render.
  23886. */
  23887. renderingGroupId: number;
  23888. /**
  23889. * The layer mask we are rendering the particles through.
  23890. */
  23891. layerMask: number;
  23892. private _capacity;
  23893. private _activeCount;
  23894. private _currentActiveCount;
  23895. private _accumulatedCount;
  23896. private _renderEffect;
  23897. private _updateEffect;
  23898. private _buffer0;
  23899. private _buffer1;
  23900. private _spriteBuffer;
  23901. private _updateVAO;
  23902. private _renderVAO;
  23903. private _targetIndex;
  23904. private _sourceBuffer;
  23905. private _targetBuffer;
  23906. private _scene;
  23907. private _engine;
  23908. private _currentRenderId;
  23909. private _started;
  23910. private _stopped;
  23911. private _timeDelta;
  23912. private _randomTexture;
  23913. private _randomTexture2;
  23914. private _attributesStrideSize;
  23915. private _updateEffectOptions;
  23916. private _randomTextureSize;
  23917. private _actualFrame;
  23918. private readonly _rawTextureWidth;
  23919. /**
  23920. * List of animations used by the particle system.
  23921. */
  23922. animations: Animation[];
  23923. /**
  23924. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23925. */
  23926. static readonly IsSupported: boolean;
  23927. /**
  23928. * An event triggered when the system is disposed.
  23929. */
  23930. onDisposeObservable: Observable<GPUParticleSystem>;
  23931. /**
  23932. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23933. */
  23934. updateSpeed: number;
  23935. /**
  23936. * The amount of time the particle system is running (depends of the overall update speed).
  23937. */
  23938. targetStopDuration: number;
  23939. /**
  23940. * The texture used to render each particle. (this can be a spritesheet)
  23941. */
  23942. particleTexture: Nullable<Texture>;
  23943. /**
  23944. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23945. */
  23946. blendMode: number;
  23947. /**
  23948. * Minimum life time of emitting particles.
  23949. */
  23950. minLifeTime: number;
  23951. /**
  23952. * Maximum life time of emitting particles.
  23953. */
  23954. maxLifeTime: number;
  23955. /**
  23956. * Minimum Size of emitting particles.
  23957. */
  23958. minSize: number;
  23959. /**
  23960. * Maximum Size of emitting particles.
  23961. */
  23962. maxSize: number;
  23963. /**
  23964. * Minimum scale of emitting particles on X axis.
  23965. */
  23966. minScaleX: number;
  23967. /**
  23968. * Maximum scale of emitting particles on X axis.
  23969. */
  23970. maxScaleX: number;
  23971. /**
  23972. * Minimum scale of emitting particles on Y axis.
  23973. */
  23974. minScaleY: number;
  23975. /**
  23976. * Maximum scale of emitting particles on Y axis.
  23977. */
  23978. maxScaleY: number;
  23979. /**
  23980. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23981. */
  23982. color1: Color4;
  23983. /**
  23984. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23985. */
  23986. color2: Color4;
  23987. /**
  23988. * Color the particle will have at the end of its lifetime.
  23989. */
  23990. colorDead: Color4;
  23991. /**
  23992. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23993. */
  23994. emitRate: number;
  23995. /**
  23996. * You can use gravity if you want to give an orientation to your particles.
  23997. */
  23998. gravity: Vector3;
  23999. /**
  24000. * Minimum power of emitting particles.
  24001. */
  24002. minEmitPower: number;
  24003. /**
  24004. * Maximum power of emitting particles.
  24005. */
  24006. maxEmitPower: number;
  24007. /**
  24008. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24009. */
  24010. minAngularSpeed: number;
  24011. /**
  24012. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24013. */
  24014. maxAngularSpeed: number;
  24015. /**
  24016. * The particle emitter type defines the emitter used by the particle system.
  24017. * It can be for example box, sphere, or cone...
  24018. */
  24019. particleEmitterType: Nullable<IParticleEmitterType>;
  24020. /**
  24021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24023. */
  24024. direction1: Vector3;
  24025. /**
  24026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24027. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24028. */
  24029. direction2: Vector3;
  24030. /**
  24031. * 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.
  24032. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24033. */
  24034. minEmitBox: Vector3;
  24035. /**
  24036. * 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.
  24037. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24038. */
  24039. maxEmitBox: Vector3;
  24040. /**
  24041. * Gets the maximum number of particles active at the same time.
  24042. * @returns The max number of active particles.
  24043. */
  24044. getCapacity(): number;
  24045. /**
  24046. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24047. * to override the particles.
  24048. */
  24049. forceDepthWrite: boolean;
  24050. /**
  24051. * Gets or set the number of active particles
  24052. */
  24053. activeParticleCount: number;
  24054. private _preWarmDone;
  24055. /** 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 */
  24056. preWarmCycles: number;
  24057. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24058. preWarmStepOffset: number;
  24059. /**
  24060. * Gets or sets the minimal initial rotation in radians.
  24061. */
  24062. minInitialRotation: number;
  24063. /**
  24064. * Gets or sets the maximal initial rotation in radians.
  24065. */
  24066. maxInitialRotation: number;
  24067. /**
  24068. * 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)
  24069. */
  24070. spriteCellChangeSpeed: number;
  24071. /**
  24072. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24073. */
  24074. startSpriteCellID: number;
  24075. /**
  24076. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24077. */
  24078. endSpriteCellID: number;
  24079. /**
  24080. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24081. */
  24082. spriteCellWidth: number;
  24083. /**
  24084. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24085. */
  24086. spriteCellHeight: number;
  24087. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24088. translationPivot: Vector2;
  24089. /**
  24090. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24091. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24092. */
  24093. billboardMode: number;
  24094. private _isAnimationSheetEnabled;
  24095. /**
  24096. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24097. */
  24098. readonly isAnimationSheetEnabled: boolean;
  24099. /**
  24100. * Is this system ready to be used/rendered
  24101. * @return true if the system is ready
  24102. */
  24103. isReady(): boolean;
  24104. /**
  24105. * Gets Wether the system has been started.
  24106. * @returns True if it has been started, otherwise false.
  24107. */
  24108. isStarted(): boolean;
  24109. /**
  24110. * Starts the particle system and begins to emit.
  24111. */
  24112. start(): void;
  24113. /**
  24114. * Stops the particle system.
  24115. */
  24116. stop(): void;
  24117. /**
  24118. * Remove all active particles
  24119. */
  24120. reset(): void;
  24121. /**
  24122. * Returns the string "GPUParticleSystem"
  24123. * @returns a string containing the class name
  24124. */
  24125. getClassName(): string;
  24126. private _isBillboardBased;
  24127. /**
  24128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24129. */
  24130. isBillboardBased: boolean;
  24131. private _colorGradients;
  24132. private _colorGradientsTexture;
  24133. /**
  24134. * Gets the current list of color gradients.
  24135. * You must use addColorGradient and removeColorGradient to udpate this list
  24136. * @returns the list of color gradients
  24137. */
  24138. getColorGradients(): Nullable<Array<ColorGradient>>;
  24139. /**
  24140. * Gets the current list of size gradients.
  24141. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24142. * @returns the list of size gradients
  24143. */
  24144. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24145. /**
  24146. * Gets the current list of angular speed gradients.
  24147. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24148. * @returns the list of angular speed gradients
  24149. */
  24150. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24151. /**
  24152. * Gets the current list of velocity gradients.
  24153. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24154. * @returns the list of angular speed gradients
  24155. */
  24156. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24157. private _removeGradient(gradient, gradients, texture);
  24158. /**
  24159. * Adds a new color gradient
  24160. * @param gradient defines the gradient to use (between 0 and 1)
  24161. * @param color defines the color to affect to the specified gradient
  24162. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24163. * @returns the current particle system
  24164. */
  24165. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24166. /**
  24167. * Remove a specific color gradient
  24168. * @param gradient defines the gradient to remove
  24169. * @returns the current particle system
  24170. */
  24171. removeColorGradient(gradient: number): GPUParticleSystem;
  24172. private _angularSpeedGradients;
  24173. private _angularSpeedGradientsTexture;
  24174. private _sizeGradients;
  24175. private _sizeGradientsTexture;
  24176. private _velocityGradients;
  24177. private _velocityGradientsTexture;
  24178. private _addFactorGradient(factorGradients, gradient, factor);
  24179. /**
  24180. * Adds a new size gradient
  24181. * @param gradient defines the gradient to use (between 0 and 1)
  24182. * @param factor defines the size factor to affect to the specified gradient
  24183. * @returns the current particle system
  24184. */
  24185. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24186. /**
  24187. * Remove a specific size gradient
  24188. * @param gradient defines the gradient to remove
  24189. * @returns the current particle system
  24190. */
  24191. removeSizeGradient(gradient: number): GPUParticleSystem;
  24192. /**
  24193. * Adds a new angular speed gradient
  24194. * @param gradient defines the gradient to use (between 0 and 1)
  24195. * @param factor defines the size factor to affect to the specified gradient
  24196. * @returns the current particle system
  24197. */
  24198. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  24199. /**
  24200. * Remove a specific angular speed gradient
  24201. * @param gradient defines the gradient to remove
  24202. * @returns the current particle system
  24203. */
  24204. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  24205. /**
  24206. * Adds a new velocity gradient
  24207. * @param gradient defines the gradient to use (between 0 and 1)
  24208. * @param factor defines the size factor to affect to the specified gradient
  24209. * @returns the current particle system
  24210. */
  24211. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  24212. /**
  24213. * Remove a specific velocity gradient
  24214. * @param gradient defines the gradient to remove
  24215. * @returns the current particle system
  24216. */
  24217. removeVelocityGradient(gradient: number): GPUParticleSystem;
  24218. /**
  24219. * Instantiates a GPU particle system.
  24220. * 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.
  24221. * @param name The name of the particle system
  24222. * @param options The options used to create the system
  24223. * @param scene The scene the particle system belongs to
  24224. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24225. */
  24226. constructor(name: string, options: Partial<{
  24227. capacity: number;
  24228. randomTextureSize: number;
  24229. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  24230. private _createUpdateVAO(source);
  24231. private _createRenderVAO(source, spriteSource);
  24232. private _initialize(force?);
  24233. /** @hidden */
  24234. _recreateUpdateEffect(): void;
  24235. /** @hidden */
  24236. _recreateRenderEffect(): void;
  24237. /**
  24238. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24239. * @param preWarm defines if we are in the pre-warmimg phase
  24240. */
  24241. animate(preWarm?: boolean): void;
  24242. private _createFactorGradientTexture(factorGradients, textureName);
  24243. private _createSizeGradientTexture();
  24244. private _createAngularSpeedGradientTexture();
  24245. private _createVelocityGradientTexture();
  24246. private _createColorGradientTexture();
  24247. /**
  24248. * Renders the particle system in its current state
  24249. * @param preWarm defines if the system should only update the particles but not render them
  24250. * @returns the current number of particles
  24251. */
  24252. render(preWarm?: boolean): number;
  24253. /**
  24254. * Rebuilds the particle system
  24255. */
  24256. rebuild(): void;
  24257. private _releaseBuffers();
  24258. private _releaseVAOs();
  24259. /**
  24260. * Disposes the particle system and free the associated resources
  24261. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24262. */
  24263. dispose(disposeTexture?: boolean): void;
  24264. /**
  24265. * Clones the particle system.
  24266. * @param name The name of the cloned object
  24267. * @param newEmitter The new emitter to use
  24268. * @returns the cloned particle system
  24269. */
  24270. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  24271. /**
  24272. * Serializes the particle system to a JSON object.
  24273. * @returns the JSON object
  24274. */
  24275. serialize(): any;
  24276. /**
  24277. * Parses a JSON object to create a GPU particle system.
  24278. * @param parsedParticleSystem The JSON object to parse
  24279. * @param scene The scene to create the particle system in
  24280. * @param rootUrl The root url to use to load external dependencies like texture
  24281. * @returns the parsed GPU particle system
  24282. */
  24283. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24284. }
  24285. }
  24286. declare module BABYLON {
  24287. /**
  24288. * Interface representing a particle system in Babylon.
  24289. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24290. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24291. */
  24292. interface IParticleSystem {
  24293. /**
  24294. * List of animations used by the particle system.
  24295. */
  24296. animations: Animation[];
  24297. /**
  24298. * The id of the Particle system.
  24299. */
  24300. id: string;
  24301. /**
  24302. * The name of the Particle system.
  24303. */
  24304. name: string;
  24305. /**
  24306. * The emitter represents the Mesh or position we are attaching the particle system to.
  24307. */
  24308. emitter: Nullable<AbstractMesh | Vector3>;
  24309. /**
  24310. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24311. */
  24312. isBillboardBased: boolean;
  24313. /**
  24314. * The rendering group used by the Particle system to chose when to render.
  24315. */
  24316. renderingGroupId: number;
  24317. /**
  24318. * The layer mask we are rendering the particles through.
  24319. */
  24320. layerMask: number;
  24321. /**
  24322. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24323. */
  24324. updateSpeed: number;
  24325. /**
  24326. * The amount of time the particle system is running (depends of the overall update speed).
  24327. */
  24328. targetStopDuration: number;
  24329. /**
  24330. * The texture used to render each particle. (this can be a spritesheet)
  24331. */
  24332. particleTexture: Nullable<Texture>;
  24333. /**
  24334. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  24335. */
  24336. blendMode: number;
  24337. /**
  24338. * Minimum life time of emitting particles.
  24339. */
  24340. minLifeTime: number;
  24341. /**
  24342. * Maximum life time of emitting particles.
  24343. */
  24344. maxLifeTime: number;
  24345. /**
  24346. * Minimum Size of emitting particles.
  24347. */
  24348. minSize: number;
  24349. /**
  24350. * Maximum Size of emitting particles.
  24351. */
  24352. maxSize: number;
  24353. /**
  24354. * Minimum scale of emitting particles on X axis.
  24355. */
  24356. minScaleX: number;
  24357. /**
  24358. * Maximum scale of emitting particles on X axis.
  24359. */
  24360. maxScaleX: number;
  24361. /**
  24362. * Minimum scale of emitting particles on Y axis.
  24363. */
  24364. minScaleY: number;
  24365. /**
  24366. * Maximum scale of emitting particles on Y axis.
  24367. */
  24368. maxScaleY: number;
  24369. /**
  24370. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24371. */
  24372. color1: Color4;
  24373. /**
  24374. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24375. */
  24376. color2: Color4;
  24377. /**
  24378. * Color the particle will have at the end of its lifetime.
  24379. */
  24380. colorDead: Color4;
  24381. /**
  24382. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24383. */
  24384. emitRate: number;
  24385. /**
  24386. * You can use gravity if you want to give an orientation to your particles.
  24387. */
  24388. gravity: Vector3;
  24389. /**
  24390. * Minimum power of emitting particles.
  24391. */
  24392. minEmitPower: number;
  24393. /**
  24394. * Maximum power of emitting particles.
  24395. */
  24396. maxEmitPower: number;
  24397. /**
  24398. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24399. */
  24400. minAngularSpeed: number;
  24401. /**
  24402. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24403. */
  24404. maxAngularSpeed: number;
  24405. /**
  24406. * Gets or sets the minimal initial rotation in radians.
  24407. */
  24408. minInitialRotation: number;
  24409. /**
  24410. * Gets or sets the maximal initial rotation in radians.
  24411. */
  24412. maxInitialRotation: number;
  24413. /**
  24414. * The particle emitter type defines the emitter used by the particle system.
  24415. * It can be for example box, sphere, or cone...
  24416. */
  24417. particleEmitterType: Nullable<IParticleEmitterType>;
  24418. /**
  24419. * 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
  24420. */
  24421. preWarmCycles: number;
  24422. /**
  24423. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  24424. */
  24425. preWarmStepOffset: number;
  24426. /**
  24427. * 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)
  24428. */
  24429. spriteCellChangeSpeed: number;
  24430. /**
  24431. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24432. */
  24433. startSpriteCellID: number;
  24434. /**
  24435. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24436. */
  24437. endSpriteCellID: number;
  24438. /**
  24439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24440. */
  24441. spriteCellWidth: number;
  24442. /**
  24443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24444. */
  24445. spriteCellHeight: number;
  24446. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24447. translationPivot: Vector2;
  24448. /**
  24449. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24450. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24451. */
  24452. billboardMode: number;
  24453. /**
  24454. * Gets the maximum number of particles active at the same time.
  24455. * @returns The max number of active particles.
  24456. */
  24457. getCapacity(): number;
  24458. /**
  24459. * Gets Wether the system has been started.
  24460. * @returns True if it has been started, otherwise false.
  24461. */
  24462. isStarted(): boolean;
  24463. /**
  24464. * Gets if the particle system has been started.
  24465. * @return true if the system has been started, otherwise false.
  24466. */
  24467. isStarted(): boolean;
  24468. /**
  24469. * Animates the particle system for this frame.
  24470. */
  24471. animate(): void;
  24472. /**
  24473. * Renders the particle system in its current state.
  24474. * @returns the current number of particles
  24475. */
  24476. render(): number;
  24477. /**
  24478. * Dispose the particle system and frees its associated resources.
  24479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24480. */
  24481. dispose(disposeTexture?: boolean): void;
  24482. /**
  24483. * Clones the particle system.
  24484. * @param name The name of the cloned object
  24485. * @param newEmitter The new emitter to use
  24486. * @returns the cloned particle system
  24487. */
  24488. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  24489. /**
  24490. * Serializes the particle system to a JSON object.
  24491. * @returns the JSON object
  24492. */
  24493. serialize(): any;
  24494. /**
  24495. * Rebuild the particle system
  24496. */
  24497. rebuild(): void;
  24498. /**
  24499. * Starts the particle system and begins to emit.
  24500. */
  24501. start(): void;
  24502. /**
  24503. * Stops the particle system.
  24504. */
  24505. stop(): void;
  24506. /**
  24507. * Remove all active particles
  24508. */
  24509. reset(): void;
  24510. /**
  24511. * Is this system ready to be used/rendered
  24512. * @return true if the system is ready
  24513. */
  24514. isReady(): boolean;
  24515. /**
  24516. * Adds a new color gradient
  24517. * @param gradient defines the gradient to use (between 0 and 1)
  24518. * @param color defines the color to affect to the specified gradient
  24519. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24520. * @returns the current particle system
  24521. */
  24522. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  24523. /**
  24524. * Remove a specific color gradient
  24525. * @param gradient defines the gradient to remove
  24526. * @returns the current particle system
  24527. */
  24528. removeColorGradient(gradient: number): IParticleSystem;
  24529. /**
  24530. * Adds a new size gradient
  24531. * @param gradient defines the gradient to use (between 0 and 1)
  24532. * @param factor defines the size factor to affect to the specified gradient
  24533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24534. * @returns the current particle system
  24535. */
  24536. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24537. /**
  24538. * Remove a specific size gradient
  24539. * @param gradient defines the gradient to remove
  24540. * @returns the current particle system
  24541. */
  24542. removeSizeGradient(gradient: number): IParticleSystem;
  24543. /**
  24544. * Gets the current list of color gradients.
  24545. * You must use addColorGradient and removeColorGradient to udpate this list
  24546. * @returns the list of color gradients
  24547. */
  24548. getColorGradients(): Nullable<Array<ColorGradient>>;
  24549. /**
  24550. * Gets the current list of size gradients.
  24551. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24552. * @returns the list of size gradients
  24553. */
  24554. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24555. /**
  24556. * Gets the current list of angular speed gradients.
  24557. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24558. * @returns the list of angular speed gradients
  24559. */
  24560. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24561. /**
  24562. * Adds a new angular speed gradient
  24563. * @param gradient defines the gradient to use (between 0 and 1)
  24564. * @param factor defines the size factor to affect to the specified gradient
  24565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24566. * @returns the current particle system
  24567. */
  24568. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24569. /**
  24570. * Remove a specific angular speed gradient
  24571. * @param gradient defines the gradient to remove
  24572. * @returns the current particle system
  24573. */
  24574. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  24575. /**
  24576. * Gets the current list of velocity gradients.
  24577. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24578. * @returns the list of velocity gradients
  24579. */
  24580. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24581. /**
  24582. * Adds a new velocity gradient
  24583. * @param gradient defines the gradient to use (between 0 and 1)
  24584. * @param factor defines the size factor to affect to the specified gradient
  24585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  24586. * @returns the current particle system
  24587. */
  24588. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  24589. /**
  24590. * Remove a specific velocity gradient
  24591. * @param gradient defines the gradient to remove
  24592. * @returns the current particle system
  24593. */
  24594. removeVelocityGradient(gradient: number): IParticleSystem;
  24595. }
  24596. }
  24597. declare module BABYLON {
  24598. /**
  24599. * A particle represents one of the element emitted by a particle system.
  24600. * This is mainly define by its coordinates, direction, velocity and age.
  24601. */
  24602. class Particle {
  24603. /**
  24604. * particleSystem the particle system the particle belongs to.
  24605. */
  24606. particleSystem: ParticleSystem;
  24607. /**
  24608. * The world position of the particle in the scene.
  24609. */
  24610. position: Vector3;
  24611. /**
  24612. * The world direction of the particle in the scene.
  24613. */
  24614. direction: Vector3;
  24615. /**
  24616. * The color of the particle.
  24617. */
  24618. color: Color4;
  24619. /**
  24620. * The color change of the particle per step.
  24621. */
  24622. colorStep: Color4;
  24623. /**
  24624. * Defines how long will the life of the particle be.
  24625. */
  24626. lifeTime: number;
  24627. /**
  24628. * The current age of the particle.
  24629. */
  24630. age: number;
  24631. /**
  24632. * The current size of the particle.
  24633. */
  24634. size: number;
  24635. /**
  24636. * The current scale of the particle.
  24637. */
  24638. scale: Vector2;
  24639. /**
  24640. * The current angle of the particle.
  24641. */
  24642. angle: number;
  24643. /**
  24644. * Defines how fast is the angle changing.
  24645. */
  24646. angularSpeed: number;
  24647. /**
  24648. * Defines the cell index used by the particle to be rendered from a sprite.
  24649. */
  24650. cellIndex: number;
  24651. /** @hidden */
  24652. _initialDirection: Nullable<Vector3>;
  24653. /** @hidden */
  24654. _initialStartSpriteCellID: number;
  24655. _initialEndSpriteCellID: number;
  24656. /** @hidden */
  24657. _currentColorGradient: Nullable<ColorGradient>;
  24658. /** @hidden */
  24659. _currentColor1: Color4;
  24660. /** @hidden */
  24661. _currentColor2: Color4;
  24662. /** @hidden */
  24663. _currentSizeGradient: Nullable<FactorGradient>;
  24664. /** @hidden */
  24665. _currentSize1: number;
  24666. /** @hidden */
  24667. _currentSize2: number;
  24668. /** @hidden */
  24669. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  24670. /** @hidden */
  24671. _currentAngularSpeed1: number;
  24672. /** @hidden */
  24673. _currentAngularSpeed2: number;
  24674. /** @hidden */
  24675. _currentVelocityGradient: Nullable<FactorGradient>;
  24676. /** @hidden */
  24677. _currentVelocity1: number;
  24678. /** @hidden */
  24679. _currentVelocity2: number;
  24680. /**
  24681. * Creates a new instance Particle
  24682. * @param particleSystem the particle system the particle belongs to
  24683. */
  24684. constructor(
  24685. /**
  24686. * particleSystem the particle system the particle belongs to.
  24687. */
  24688. particleSystem: ParticleSystem);
  24689. private updateCellInfoFromSystem();
  24690. /**
  24691. * Defines how the sprite cell index is updated for the particle
  24692. */
  24693. updateCellIndex(): void;
  24694. /**
  24695. * Copy the properties of particle to another one.
  24696. * @param other the particle to copy the information to.
  24697. */
  24698. copyTo(other: Particle): void;
  24699. }
  24700. }
  24701. declare module BABYLON {
  24702. /**
  24703. * This class is made for on one-liner static method to help creating particle system set.
  24704. */
  24705. class ParticleHelper {
  24706. /**
  24707. * Gets or sets base Assets URL
  24708. */
  24709. static BaseAssetsUrl: string;
  24710. /**
  24711. * This is the main static method (one-liner) of this helper to create different particle systems
  24712. * @param type This string represents the type to the particle system to create
  24713. * @param scene The scene where the particle system should live
  24714. * @param gpu If the system will use gpu
  24715. * @returns the ParticleSystemSet created
  24716. */
  24717. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  24718. /**
  24719. * Static function used to export a particle system to a ParticleSystemSet variable.
  24720. * Please note that the emitter shape is not exported
  24721. * @param system defines the particle systems to export
  24722. */
  24723. static ExportSet(systems: ParticleSystem[]): ParticleSystemSet;
  24724. }
  24725. }
  24726. declare module BABYLON {
  24727. /**
  24728. * This represents a particle system in Babylon.
  24729. * 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.
  24730. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24731. * @example https://doc.babylonjs.com/babylon101/particles
  24732. */
  24733. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  24734. /**
  24735. * Source color is added to the destination color without alpha affecting the result.
  24736. */
  24737. static BLENDMODE_ONEONE: number;
  24738. /**
  24739. * Blend current color and particle color using particle’s alpha.
  24740. */
  24741. static BLENDMODE_STANDARD: number;
  24742. /**
  24743. * Add current color and particle color multiplied by particle’s alpha.
  24744. */
  24745. static BLENDMODE_ADD: number;
  24746. /**
  24747. * List of animations used by the particle system.
  24748. */
  24749. animations: Animation[];
  24750. /**
  24751. * The id of the Particle system.
  24752. */
  24753. id: string;
  24754. /**
  24755. * The friendly name of the Particle system.
  24756. */
  24757. name: string;
  24758. /**
  24759. * The rendering group used by the Particle system to chose when to render.
  24760. */
  24761. renderingGroupId: number;
  24762. /**
  24763. * The emitter represents the Mesh or position we are attaching the particle system to.
  24764. */
  24765. emitter: Nullable<AbstractMesh | Vector3>;
  24766. /**
  24767. * The maximum number of particles to emit per frame
  24768. */
  24769. emitRate: number;
  24770. /**
  24771. * If you want to launch only a few particles at once, that can be done, as well.
  24772. */
  24773. manualEmitCount: number;
  24774. /**
  24775. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24776. */
  24777. updateSpeed: number;
  24778. /**
  24779. * The amount of time the particle system is running (depends of the overall update speed).
  24780. */
  24781. targetStopDuration: number;
  24782. /**
  24783. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24784. */
  24785. disposeOnStop: boolean;
  24786. /**
  24787. * Minimum power of emitting particles.
  24788. */
  24789. minEmitPower: number;
  24790. /**
  24791. * Maximum power of emitting particles.
  24792. */
  24793. maxEmitPower: number;
  24794. /**
  24795. * Minimum life time of emitting particles.
  24796. */
  24797. minLifeTime: number;
  24798. /**
  24799. * Maximum life time of emitting particles.
  24800. */
  24801. maxLifeTime: number;
  24802. /**
  24803. * Minimum Size of emitting particles.
  24804. */
  24805. minSize: number;
  24806. /**
  24807. * Maximum Size of emitting particles.
  24808. */
  24809. maxSize: number;
  24810. /**
  24811. * Minimum scale of emitting particles on X axis.
  24812. */
  24813. minScaleX: number;
  24814. /**
  24815. * Maximum scale of emitting particles on X axis.
  24816. */
  24817. maxScaleX: number;
  24818. /**
  24819. * Minimum scale of emitting particles on Y axis.
  24820. */
  24821. minScaleY: number;
  24822. /**
  24823. * Maximum scale of emitting particles on Y axis.
  24824. */
  24825. maxScaleY: number;
  24826. /**
  24827. * Gets or sets the minimal initial rotation in radians.
  24828. */
  24829. minInitialRotation: number;
  24830. /**
  24831. * Gets or sets the maximal initial rotation in radians.
  24832. */
  24833. maxInitialRotation: number;
  24834. /**
  24835. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24836. */
  24837. minAngularSpeed: number;
  24838. /**
  24839. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24840. */
  24841. maxAngularSpeed: number;
  24842. /**
  24843. * The texture used to render each particle. (this can be a spritesheet)
  24844. */
  24845. particleTexture: Nullable<Texture>;
  24846. /**
  24847. * The layer mask we are rendering the particles through.
  24848. */
  24849. layerMask: number;
  24850. /**
  24851. * This can help using your own shader to render the particle system.
  24852. * The according effect will be created
  24853. */
  24854. customShader: any;
  24855. /**
  24856. * By default particle system starts as soon as they are created. This prevents the
  24857. * automatic start to happen and let you decide when to start emitting particles.
  24858. */
  24859. preventAutoStart: boolean;
  24860. /**
  24861. * This function can be defined to provide custom update for active particles.
  24862. * This function will be called instead of regular update (age, position, color, etc.).
  24863. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  24864. */
  24865. updateFunction: (particles: Particle[]) => void;
  24866. /**
  24867. * Callback triggered when the particle animation is ending.
  24868. */
  24869. onAnimationEnd: Nullable<() => void>;
  24870. /**
  24871. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24872. */
  24873. blendMode: number;
  24874. /**
  24875. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24876. * to override the particles.
  24877. */
  24878. forceDepthWrite: boolean;
  24879. /**
  24880. * You can use gravity if you want to give an orientation to your particles.
  24881. */
  24882. gravity: Vector3;
  24883. private _colorGradients;
  24884. private _sizeGradients;
  24885. private _lifeTimeGradients;
  24886. private _angularSpeedGradients;
  24887. private _velocityGradients;
  24888. /**
  24889. * Gets the current list of color gradients.
  24890. * You must use addColorGradient and removeColorGradient to udpate this list
  24891. * @returns the list of color gradients
  24892. */
  24893. getColorGradients(): Nullable<Array<ColorGradient>>;
  24894. /**
  24895. * Gets the current list of size gradients.
  24896. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24897. * @returns the list of size gradients
  24898. */
  24899. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24900. /**
  24901. * Gets the current list of life time gradients.
  24902. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24903. * @returns the list of life time gradients
  24904. */
  24905. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24906. /**
  24907. * Gets the current list of angular speed gradients.
  24908. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24909. * @returns the list of angular speed gradients
  24910. */
  24911. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24912. /**
  24913. * Gets the current list of velocity gradients.
  24914. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24915. * @returns the list of velocity gradients
  24916. */
  24917. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24918. /**
  24919. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24920. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24921. */
  24922. direction1: Vector3;
  24923. /**
  24924. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24925. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24926. */
  24927. direction2: Vector3;
  24928. /**
  24929. * 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.
  24930. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24931. */
  24932. minEmitBox: Vector3;
  24933. /**
  24934. * 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.
  24935. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24936. */
  24937. maxEmitBox: Vector3;
  24938. /**
  24939. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24940. */
  24941. color1: Color4;
  24942. /**
  24943. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24944. */
  24945. color2: Color4;
  24946. /**
  24947. * Color the particle will have at the end of its lifetime
  24948. */
  24949. colorDead: Color4;
  24950. /**
  24951. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24952. */
  24953. textureMask: Color4;
  24954. /**
  24955. * The particle emitter type defines the emitter used by the particle system.
  24956. * It can be for example box, sphere, or cone...
  24957. */
  24958. particleEmitterType: IParticleEmitterType;
  24959. /**
  24960. * This function can be defined to specify initial direction for every new particle.
  24961. * It by default use the emitterType defined function
  24962. */
  24963. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  24964. /**
  24965. * This function can be defined to specify initial position for every new particle.
  24966. * It by default use the emitterType defined function
  24967. */
  24968. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  24969. /**
  24970. * 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)
  24971. */
  24972. spriteCellChangeSpeed: number;
  24973. /**
  24974. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24975. */
  24976. startSpriteCellID: number;
  24977. /**
  24978. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24979. */
  24980. endSpriteCellID: number;
  24981. /**
  24982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24983. */
  24984. spriteCellWidth: number;
  24985. /**
  24986. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24987. */
  24988. spriteCellHeight: number;
  24989. /** 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 */
  24990. preWarmCycles: number;
  24991. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24992. preWarmStepOffset: number;
  24993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24994. translationPivot: Vector2;
  24995. /**
  24996. * An event triggered when the system is disposed
  24997. */
  24998. onDisposeObservable: Observable<ParticleSystem>;
  24999. private _onDisposeObserver;
  25000. /**
  25001. * Sets a callback that will be triggered when the system is disposed
  25002. */
  25003. onDispose: () => void;
  25004. /**
  25005. * Gets whether an animation sprite sheet is enabled or not on the particle system
  25006. */
  25007. readonly isAnimationSheetEnabled: boolean;
  25008. /**
  25009. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25010. */
  25011. isBillboardBased: boolean;
  25012. /**
  25013. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25014. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25015. */
  25016. billboardMode: number;
  25017. private _particles;
  25018. private _epsilon;
  25019. private _capacity;
  25020. private _scene;
  25021. private _stockParticles;
  25022. private _newPartsExcess;
  25023. private _vertexData;
  25024. private _vertexBuffer;
  25025. private _vertexBuffers;
  25026. private _spriteBuffer;
  25027. private _indexBuffer;
  25028. private _effect;
  25029. private _customEffect;
  25030. private _cachedDefines;
  25031. private _scaledColorStep;
  25032. private _colorDiff;
  25033. private _scaledDirection;
  25034. private _scaledGravity;
  25035. private _currentRenderId;
  25036. private _alive;
  25037. private _useInstancing;
  25038. private _started;
  25039. private _stopped;
  25040. private _actualFrame;
  25041. private _scaledUpdateSpeed;
  25042. private _vertexBufferSize;
  25043. private _isAnimationSheetEnabled;
  25044. private _isBillboardBased;
  25045. /**
  25046. * 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.
  25047. */
  25048. subEmitters: ParticleSystem[];
  25049. /**
  25050. * The current active Sub-systems, this property is used by the root particle system only.
  25051. */
  25052. activeSubSystems: Array<ParticleSystem>;
  25053. private _rootParticleSystem;
  25054. /**
  25055. * Gets the current list of active particles
  25056. */
  25057. readonly particles: Particle[];
  25058. /**
  25059. * Returns the string "ParticleSystem"
  25060. * @returns a string containing the class name
  25061. */
  25062. getClassName(): string;
  25063. /**
  25064. * Instantiates a particle system.
  25065. * 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.
  25066. * @param name The name of the particle system
  25067. * @param capacity The max number of particles alive at the same time
  25068. * @param scene The scene the particle system belongs to
  25069. * @param customEffect a custom effect used to change the way particles are rendered by default
  25070. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25071. * @param epsilon Offset used to render the particles
  25072. */
  25073. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25074. private _addFactorGradient(factorGradients, gradient, factor, factor2?);
  25075. private _removeFactorGradient(factorGradients, gradient);
  25076. /**
  25077. * Adds a new life time gradient
  25078. * @param gradient defines the gradient to use (between 0 and 1)
  25079. * @param factor defines the life time factor to affect to the specified gradient
  25080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25081. * @returns the current particle system
  25082. */
  25083. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25084. /**
  25085. * Remove a specific life time gradient
  25086. * @param gradient defines the gradient to remove
  25087. * @returns the current particle system
  25088. */
  25089. removeLifeTimeGradient(gradient: number): ParticleSystem;
  25090. /**
  25091. * Adds a new size gradient
  25092. * @param gradient defines the gradient to use (between 0 and 1)
  25093. * @param factor defines the size factor to affect to the specified gradient
  25094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25095. * @returns the current particle system
  25096. */
  25097. addSizeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25098. /**
  25099. * Remove a specific size gradient
  25100. * @param gradient defines the gradient to remove
  25101. * @returns the current particle system
  25102. */
  25103. removeSizeGradient(gradient: number): ParticleSystem;
  25104. /**
  25105. * Adds a new angular speed gradient
  25106. * @param gradient defines the gradient to use (between 0 and 1)
  25107. * @param factor defines the size factor to affect to the specified gradient
  25108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25109. * @returns the current particle system
  25110. */
  25111. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25112. /**
  25113. * Remove a specific angular speed gradient
  25114. * @param gradient defines the gradient to remove
  25115. * @returns the current particle system
  25116. */
  25117. removeAngularSpeedGradient(gradient: number): ParticleSystem;
  25118. /**
  25119. * Adds a new velocity gradient
  25120. * @param gradient defines the gradient to use (between 0 and 1)
  25121. * @param factor defines the size factor to affect to the specified gradient
  25122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25123. * @returns the current particle system
  25124. */
  25125. addVelocityGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25126. /**
  25127. * Remove a specific velocity gradient
  25128. * @param gradient defines the gradient to remove
  25129. * @returns the current particle system
  25130. */
  25131. removeVelocityGradient(gradient: number): ParticleSystem;
  25132. /**
  25133. * Adds a new color gradient
  25134. * @param gradient defines the gradient to use (between 0 and 1)
  25135. * @param color defines the color to affect to the specified gradient
  25136. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25137. */
  25138. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  25139. /**
  25140. * Remove a specific color gradient
  25141. * @param gradient defines the gradient to remove
  25142. */
  25143. removeColorGradient(gradient: number): ParticleSystem;
  25144. private _resetEffect();
  25145. private _createVertexBuffers();
  25146. private _createIndexBuffer();
  25147. /**
  25148. * Gets the maximum number of particles active at the same time.
  25149. * @returns The max number of active particles.
  25150. */
  25151. getCapacity(): number;
  25152. /**
  25153. * Gets Wether there are still active particles in the system.
  25154. * @returns True if it is alive, otherwise false.
  25155. */
  25156. isAlive(): boolean;
  25157. /**
  25158. * Gets Wether the system has been started.
  25159. * @returns True if it has been started, otherwise false.
  25160. */
  25161. isStarted(): boolean;
  25162. /**
  25163. * Starts the particle system and begins to emit.
  25164. */
  25165. start(): void;
  25166. /**
  25167. * Stops the particle system.
  25168. * @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.
  25169. */
  25170. stop(stopSubEmitters?: boolean): void;
  25171. /**
  25172. * Remove all active particles
  25173. */
  25174. reset(): void;
  25175. /**
  25176. * @hidden (for internal use only)
  25177. */
  25178. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25179. /**
  25180. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25181. * Its lifetime will start back at 0.
  25182. */
  25183. recycleParticle: (particle: Particle) => void;
  25184. private _stopSubEmitters();
  25185. private _createParticle;
  25186. private _removeFromRoot();
  25187. private _emitFromParticle;
  25188. private _update(newParticles);
  25189. /** @hidden */
  25190. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25191. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25192. private _getEffect();
  25193. /**
  25194. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25195. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25196. */
  25197. animate(preWarmOnly?: boolean): void;
  25198. private _appendParticleVertices(offset, particle);
  25199. /**
  25200. * Rebuilds the particle system.
  25201. */
  25202. rebuild(): void;
  25203. /**
  25204. * Is this system ready to be used/rendered
  25205. * @return true if the system is ready
  25206. */
  25207. isReady(): boolean;
  25208. /**
  25209. * Renders the particle system in its current state.
  25210. * @returns the current number of particles
  25211. */
  25212. render(): number;
  25213. /**
  25214. * Disposes the particle system and free the associated resources
  25215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25216. */
  25217. dispose(disposeTexture?: boolean): void;
  25218. /**
  25219. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  25220. * @param radius The radius of the sphere to emit from
  25221. * @returns the emitter
  25222. */
  25223. createSphereEmitter(radius?: number): SphereParticleEmitter;
  25224. /**
  25225. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  25226. * @param radius The radius of the sphere to emit from
  25227. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25228. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25229. * @returns the emitter
  25230. */
  25231. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25232. /**
  25233. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  25234. * @param radius The radius of the cone to emit from
  25235. * @param angle The base angle of the cone
  25236. * @returns the emitter
  25237. */
  25238. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25239. /**
  25240. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25241. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25242. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25243. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25244. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25245. * @returns the emitter
  25246. */
  25247. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25248. /**
  25249. * Clones the particle system.
  25250. * @param name The name of the cloned object
  25251. * @param newEmitter The new emitter to use
  25252. * @returns the cloned particle system
  25253. */
  25254. clone(name: string, newEmitter: any): ParticleSystem;
  25255. /**
  25256. * Serializes the particle system to a JSON object.
  25257. * @returns the JSON object
  25258. */
  25259. serialize(): any;
  25260. /** @hidden */
  25261. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25262. /** @hidden */
  25263. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25264. /**
  25265. * Parses a JSON object to create a particle system.
  25266. * @param parsedParticleSystem The JSON object to parse
  25267. * @param scene The scene to create the particle system in
  25268. * @param rootUrl The root url to use to load external dependencies like texture
  25269. * @returns the Parsed particle system
  25270. */
  25271. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25272. }
  25273. }
  25274. declare module BABYLON {
  25275. /**
  25276. * Represents a set of particle systems working together to create a specific effect
  25277. */
  25278. class ParticleSystemSet implements IDisposable {
  25279. private _emitterCreationOptions;
  25280. private _emitterNode;
  25281. /**
  25282. * Gets the particle system list
  25283. */
  25284. systems: IParticleSystem[];
  25285. /**
  25286. * Gets the emitter node used with this set
  25287. */
  25288. readonly emitterNode: Nullable<TransformNode>;
  25289. /**
  25290. * Creates a new emitter mesh as a sphere
  25291. * @param options defines the options used to create the sphere
  25292. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25293. * @param scene defines the hosting scene
  25294. */
  25295. setEmitterAsSphere(options: {
  25296. diameter: number;
  25297. segments: number;
  25298. color: Color3;
  25299. }, renderingGroupId: number, scene: Scene): void;
  25300. /**
  25301. * Starts all particle systems of the set
  25302. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25303. */
  25304. start(emitter?: AbstractMesh): void;
  25305. /**
  25306. * Release all associated resources
  25307. */
  25308. dispose(): void;
  25309. /**
  25310. * Serialize the set into a JSON compatible object
  25311. * @returns a JSON compatible representation of the set
  25312. */
  25313. serialize(): any;
  25314. /**
  25315. * Parse a new ParticleSystemSet from a serialized source
  25316. * @param data defines a JSON compatible representation of the set
  25317. * @param scene defines the hosting scene
  25318. * @param gpu defines if we want GPU particles or CPU particles
  25319. * @returns a new ParticleSystemSet
  25320. */
  25321. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25322. }
  25323. }
  25324. declare module BABYLON {
  25325. /**
  25326. * Represents one particle of a solid particle system.
  25327. */
  25328. class SolidParticle {
  25329. /**
  25330. * particle global index
  25331. */
  25332. idx: number;
  25333. /**
  25334. * The color of the particle
  25335. */
  25336. color: Nullable<Color4>;
  25337. /**
  25338. * The world space position of the particle.
  25339. */
  25340. position: Vector3;
  25341. /**
  25342. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25343. */
  25344. rotation: Vector3;
  25345. /**
  25346. * The world space rotation quaternion of the particle.
  25347. */
  25348. rotationQuaternion: Nullable<Quaternion>;
  25349. /**
  25350. * The scaling of the particle.
  25351. */
  25352. scaling: Vector3;
  25353. /**
  25354. * The uvs of the particle.
  25355. */
  25356. uvs: Vector4;
  25357. /**
  25358. * The current speed of the particle.
  25359. */
  25360. velocity: Vector3;
  25361. /**
  25362. * The pivot point in the particle local space.
  25363. */
  25364. pivot: Vector3;
  25365. /**
  25366. * Must the particle be translated from its pivot point in its local space ?
  25367. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25368. * Default : false
  25369. */
  25370. translateFromPivot: boolean;
  25371. /**
  25372. * Is the particle active or not ?
  25373. */
  25374. alive: boolean;
  25375. /**
  25376. * Is the particle visible or not ?
  25377. */
  25378. isVisible: boolean;
  25379. /**
  25380. * Index of this particle in the global "positions" array (Internal use)
  25381. */
  25382. _pos: number;
  25383. /**
  25384. * Index of this particle in the global "indices" array (Internal use)
  25385. */
  25386. _ind: number;
  25387. /**
  25388. * ModelShape of this particle (Internal use)
  25389. */
  25390. _model: ModelShape;
  25391. /**
  25392. * ModelShape id of this particle
  25393. */
  25394. shapeId: number;
  25395. /**
  25396. * Index of the particle in its shape id (Internal use)
  25397. */
  25398. idxInShape: number;
  25399. /**
  25400. * Reference to the shape model BoundingInfo object (Internal use)
  25401. */
  25402. _modelBoundingInfo: BoundingInfo;
  25403. /**
  25404. * Particle BoundingInfo object (Internal use)
  25405. */
  25406. _boundingInfo: BoundingInfo;
  25407. /**
  25408. * Reference to the SPS what the particle belongs to (Internal use)
  25409. */
  25410. _sps: SolidParticleSystem;
  25411. /**
  25412. * Still set as invisible in order to skip useless computations (Internal use)
  25413. */
  25414. _stillInvisible: boolean;
  25415. /**
  25416. * Last computed particle rotation matrix
  25417. */
  25418. _rotationMatrix: number[];
  25419. /**
  25420. * Parent particle Id, if any.
  25421. * Default null.
  25422. */
  25423. parentId: Nullable<number>;
  25424. /**
  25425. * Internal global position in the SPS.
  25426. */
  25427. _globalPosition: Vector3;
  25428. /**
  25429. * Creates a Solid Particle object.
  25430. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25431. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25432. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25433. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25434. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25435. * @param shapeId (integer) is the model shape identifier in the SPS.
  25436. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25437. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25438. */
  25439. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25440. /**
  25441. * Legacy support, changed scale to scaling
  25442. */
  25443. /**
  25444. * Legacy support, changed scale to scaling
  25445. */
  25446. scale: Vector3;
  25447. /**
  25448. * Legacy support, changed quaternion to rotationQuaternion
  25449. */
  25450. /**
  25451. * Legacy support, changed quaternion to rotationQuaternion
  25452. */
  25453. quaternion: Nullable<Quaternion>;
  25454. /**
  25455. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25456. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25457. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25458. * @returns true if it intersects
  25459. */
  25460. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25461. }
  25462. /**
  25463. * Represents the shape of the model used by one particle of a solid particle system.
  25464. * SPS internal tool, don't use it manually.
  25465. */
  25466. class ModelShape {
  25467. /**
  25468. * The shape id.
  25469. */
  25470. shapeID: number;
  25471. /**
  25472. * flat array of model positions (internal use)
  25473. */
  25474. _shape: Vector3[];
  25475. /**
  25476. * flat array of model UVs (internal use)
  25477. */
  25478. _shapeUV: number[];
  25479. /**
  25480. * length of the shape in the model indices array (internal use)
  25481. */
  25482. _indicesLength: number;
  25483. /**
  25484. * Custom position function (internal use)
  25485. */
  25486. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25487. /**
  25488. * Custom vertex function (internal use)
  25489. */
  25490. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25491. /**
  25492. * 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.
  25493. * SPS internal tool, don't use it manually.
  25494. * @hidden
  25495. */
  25496. 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>);
  25497. }
  25498. /**
  25499. * Represents a Depth Sorted Particle in the solid particle system.
  25500. */
  25501. class DepthSortedParticle {
  25502. /**
  25503. * Index of the particle in the "indices" array
  25504. */
  25505. ind: number;
  25506. /**
  25507. * Length of the particle shape in the "indices" array
  25508. */
  25509. indicesLength: number;
  25510. /**
  25511. * Squared distance from the particle to the camera
  25512. */
  25513. sqDistance: number;
  25514. }
  25515. }
  25516. declare module BABYLON {
  25517. /**
  25518. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25519. *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.
  25520. * The SPS is also a particle system. It provides some methods to manage the particles.
  25521. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25522. *
  25523. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25524. */
  25525. class SolidParticleSystem implements IDisposable {
  25526. /**
  25527. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25528. * Example : var p = SPS.particles[i];
  25529. */
  25530. particles: SolidParticle[];
  25531. /**
  25532. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25533. */
  25534. nbParticles: number;
  25535. /**
  25536. * If the particles must ever face the camera (default false). Useful for planar particles.
  25537. */
  25538. billboard: boolean;
  25539. /**
  25540. * Recompute normals when adding a shape
  25541. */
  25542. recomputeNormals: boolean;
  25543. /**
  25544. * This a counter ofr your own usage. It's not set by any SPS functions.
  25545. */
  25546. counter: number;
  25547. /**
  25548. * The SPS name. This name is also given to the underlying mesh.
  25549. */
  25550. name: string;
  25551. /**
  25552. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25553. */
  25554. mesh: Mesh;
  25555. /**
  25556. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25557. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25558. */
  25559. vars: any;
  25560. /**
  25561. * This array is populated when the SPS is set as 'pickable'.
  25562. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25563. * Each element of this array is an object `{idx: int, faceId: int}`.
  25564. * `idx` is the picked particle index in the `SPS.particles` array
  25565. * `faceId` is the picked face index counted within this particle.
  25566. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25567. */
  25568. pickedParticles: {
  25569. idx: number;
  25570. faceId: number;
  25571. }[];
  25572. /**
  25573. * This array is populated when `enableDepthSort` is set to true.
  25574. * Each element of this array is an instance of the class DepthSortedParticle.
  25575. */
  25576. depthSortedParticles: DepthSortedParticle[];
  25577. /**
  25578. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25579. */
  25580. _bSphereOnly: boolean;
  25581. /**
  25582. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25583. */
  25584. _bSphereRadiusFactor: number;
  25585. private _scene;
  25586. private _positions;
  25587. private _indices;
  25588. private _normals;
  25589. private _colors;
  25590. private _uvs;
  25591. private _indices32;
  25592. private _positions32;
  25593. private _normals32;
  25594. private _fixedNormal32;
  25595. private _colors32;
  25596. private _uvs32;
  25597. private _index;
  25598. private _updatable;
  25599. private _pickable;
  25600. private _isVisibilityBoxLocked;
  25601. private _alwaysVisible;
  25602. private _depthSort;
  25603. private _shapeCounter;
  25604. private _copy;
  25605. private _shape;
  25606. private _shapeUV;
  25607. private _color;
  25608. private _computeParticleColor;
  25609. private _computeParticleTexture;
  25610. private _computeParticleRotation;
  25611. private _computeParticleVertex;
  25612. private _computeBoundingBox;
  25613. private _depthSortParticles;
  25614. private _cam_axisZ;
  25615. private _cam_axisY;
  25616. private _cam_axisX;
  25617. private _axisZ;
  25618. private _camera;
  25619. private _particle;
  25620. private _camDir;
  25621. private _camInvertedPosition;
  25622. private _rotMatrix;
  25623. private _invertMatrix;
  25624. private _rotated;
  25625. private _quaternion;
  25626. private _vertex;
  25627. private _normal;
  25628. private _yaw;
  25629. private _pitch;
  25630. private _roll;
  25631. private _halfroll;
  25632. private _halfpitch;
  25633. private _halfyaw;
  25634. private _sinRoll;
  25635. private _cosRoll;
  25636. private _sinPitch;
  25637. private _cosPitch;
  25638. private _sinYaw;
  25639. private _cosYaw;
  25640. private _mustUnrotateFixedNormals;
  25641. private _minimum;
  25642. private _maximum;
  25643. private _minBbox;
  25644. private _maxBbox;
  25645. private _particlesIntersect;
  25646. private _depthSortFunction;
  25647. private _needs32Bits;
  25648. private _pivotBackTranslation;
  25649. private _scaledPivot;
  25650. private _particleHasParent;
  25651. private _parent;
  25652. /**
  25653. * Creates a SPS (Solid Particle System) object.
  25654. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25655. * @param scene (Scene) is the scene in which the SPS is added.
  25656. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25657. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25658. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25659. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25660. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25661. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25662. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25663. */
  25664. constructor(name: string, scene: Scene, options?: {
  25665. updatable?: boolean;
  25666. isPickable?: boolean;
  25667. enableDepthSort?: boolean;
  25668. particleIntersection?: boolean;
  25669. boundingSphereOnly?: boolean;
  25670. bSphereRadiusFactor?: number;
  25671. });
  25672. /**
  25673. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25674. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25675. * @returns the created mesh
  25676. */
  25677. buildMesh(): Mesh;
  25678. /**
  25679. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25680. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25681. * Thus the particles generated from `digest()` have their property `position` set yet.
  25682. * @param mesh ( Mesh ) is the mesh to be digested
  25683. * @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
  25684. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25685. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25686. * @returns the current SPS
  25687. */
  25688. digest(mesh: Mesh, options?: {
  25689. facetNb?: number;
  25690. number?: number;
  25691. delta?: number;
  25692. }): SolidParticleSystem;
  25693. private _unrotateFixedNormals();
  25694. private _resetCopy();
  25695. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  25696. private _posToShape(positions);
  25697. private _uvsToShapeUV(uvs);
  25698. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  25699. /**
  25700. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25701. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25702. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25703. * @param nb (positive integer) the number of particles to be created from this model
  25704. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25705. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25706. * @returns the number of shapes in the system
  25707. */
  25708. addShape(mesh: Mesh, nb: number, options?: {
  25709. positionFunction?: any;
  25710. vertexFunction?: any;
  25711. }): number;
  25712. private _rebuildParticle(particle);
  25713. /**
  25714. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25715. * @returns the SPS.
  25716. */
  25717. rebuildMesh(): SolidParticleSystem;
  25718. /**
  25719. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25720. * This method calls `updateParticle()` for each particle of the SPS.
  25721. * For an animated SPS, it is usually called within the render loop.
  25722. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25723. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25724. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25725. * @returns the SPS.
  25726. */
  25727. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25728. private _quaternionRotationYPR();
  25729. private _quaternionToRotationMatrix();
  25730. /**
  25731. * Disposes the SPS.
  25732. */
  25733. dispose(): void;
  25734. /**
  25735. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25736. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25737. * @returns the SPS.
  25738. */
  25739. refreshVisibleSize(): SolidParticleSystem;
  25740. /**
  25741. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25742. * @param size the size (float) of the visibility box
  25743. * note : this doesn't lock the SPS mesh bounding box.
  25744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25745. */
  25746. setVisibilityBox(size: number): void;
  25747. /**
  25748. * Gets whether the SPS as always visible or not
  25749. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25750. */
  25751. /**
  25752. * Sets the SPS as always visible or not
  25753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25754. */
  25755. isAlwaysVisible: boolean;
  25756. /**
  25757. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25759. */
  25760. /**
  25761. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25762. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25763. */
  25764. isVisibilityBoxLocked: boolean;
  25765. /**
  25766. * Gets if `setParticles()` computes the particle rotations or not.
  25767. * Default value : true. The SPS is faster when it's set to false.
  25768. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25769. */
  25770. /**
  25771. * Tells to `setParticles()` to compute the particle rotations or not.
  25772. * Default value : true. The SPS is faster when it's set to false.
  25773. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25774. */
  25775. computeParticleRotation: boolean;
  25776. /**
  25777. * Gets if `setParticles()` computes the particle colors or not.
  25778. * Default value : true. The SPS is faster when it's set to false.
  25779. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25780. */
  25781. /**
  25782. * Tells to `setParticles()` to compute the particle colors or not.
  25783. * Default value : true. The SPS is faster when it's set to false.
  25784. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25785. */
  25786. computeParticleColor: boolean;
  25787. /**
  25788. * Gets if `setParticles()` computes the particle textures or not.
  25789. * Default value : true. The SPS is faster when it's set to false.
  25790. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25791. */
  25792. computeParticleTexture: boolean;
  25793. /**
  25794. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25795. * Default value : false. The SPS is faster when it's set to false.
  25796. * Note : the particle custom vertex positions aren't stored values.
  25797. */
  25798. /**
  25799. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25800. * Default value : false. The SPS is faster when it's set to false.
  25801. * Note : the particle custom vertex positions aren't stored values.
  25802. */
  25803. computeParticleVertex: boolean;
  25804. /**
  25805. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25806. */
  25807. /**
  25808. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25809. */
  25810. computeBoundingBox: boolean;
  25811. /**
  25812. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25813. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25814. * Default : `true`
  25815. */
  25816. /**
  25817. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25818. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25819. * Default : `true`
  25820. */
  25821. depthSortParticles: boolean;
  25822. /**
  25823. * This function does nothing. It may be overwritten to set all the particle first values.
  25824. * The SPS doesn't call this function, you may have to call it by your own.
  25825. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25826. */
  25827. initParticles(): void;
  25828. /**
  25829. * This function does nothing. It may be overwritten to recycle a particle.
  25830. * The SPS doesn't call this function, you may have to call it by your own.
  25831. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25832. * @param particle The particle to recycle
  25833. * @returns the recycled particle
  25834. */
  25835. recycleParticle(particle: SolidParticle): SolidParticle;
  25836. /**
  25837. * Updates a particle : this function should be overwritten by the user.
  25838. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25839. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25840. * @example : just set a particle position or velocity and recycle conditions
  25841. * @param particle The particle to update
  25842. * @returns the updated particle
  25843. */
  25844. updateParticle(particle: SolidParticle): SolidParticle;
  25845. /**
  25846. * Updates a vertex of a particle : it can be overwritten by the user.
  25847. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25848. * @param particle the current particle
  25849. * @param vertex the current index of the current particle
  25850. * @param pt the index of the current vertex in the particle shape
  25851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25852. * @example : just set a vertex particle position
  25853. * @returns the updated vertex
  25854. */
  25855. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25856. /**
  25857. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25858. * This does nothing and may be overwritten by the user.
  25859. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25860. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25861. * @param update the boolean update value actually passed to setParticles()
  25862. */
  25863. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25864. /**
  25865. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25866. * This will be passed three parameters.
  25867. * This does nothing and may be overwritten by the user.
  25868. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25869. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25870. * @param update the boolean update value actually passed to setParticles()
  25871. */
  25872. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25873. }
  25874. }
  25875. declare module BABYLON {
  25876. interface PhysicsImpostorJoint {
  25877. mainImpostor: PhysicsImpostor;
  25878. connectedImpostor: PhysicsImpostor;
  25879. joint: PhysicsJoint;
  25880. }
  25881. class PhysicsEngine {
  25882. private _physicsPlugin;
  25883. gravity: Vector3;
  25884. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  25885. setGravity(gravity: Vector3): void;
  25886. /**
  25887. * Set the time step of the physics engine.
  25888. * default is 1/60.
  25889. * To slow it down, enter 1/600 for example.
  25890. * To speed it up, 1/30
  25891. * @param {number} newTimeStep the new timestep to apply to this world.
  25892. */
  25893. setTimeStep(newTimeStep?: number): void;
  25894. /**
  25895. * Get the time step of the physics engine.
  25896. */
  25897. getTimeStep(): number;
  25898. dispose(): void;
  25899. getPhysicsPluginName(): string;
  25900. static Epsilon: number;
  25901. private _impostors;
  25902. private _joints;
  25903. /**
  25904. * Adding a new impostor for the impostor tracking.
  25905. * This will be done by the impostor itself.
  25906. * @param {PhysicsImpostor} impostor the impostor to add
  25907. */
  25908. addImpostor(impostor: PhysicsImpostor): void;
  25909. /**
  25910. * Remove an impostor from the engine.
  25911. * This impostor and its mesh will not longer be updated by the physics engine.
  25912. * @param {PhysicsImpostor} impostor the impostor to remove
  25913. */
  25914. removeImpostor(impostor: PhysicsImpostor): void;
  25915. /**
  25916. * Add a joint to the physics engine
  25917. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  25918. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  25919. * @param {PhysicsJoint} the joint that will connect both impostors.
  25920. */
  25921. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25922. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  25923. /**
  25924. * Called by the scene. no need to call it.
  25925. */
  25926. _step(delta: number): void;
  25927. getPhysicsPlugin(): IPhysicsEnginePlugin;
  25928. getImpostors(): Array<PhysicsImpostor>;
  25929. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25930. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  25931. }
  25932. interface IPhysicsEnginePlugin {
  25933. world: any;
  25934. name: string;
  25935. setGravity(gravity: Vector3): void;
  25936. setTimeStep(timeStep: number): void;
  25937. getTimeStep(): number;
  25938. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  25939. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25940. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  25941. generatePhysicsBody(impostor: PhysicsImpostor): void;
  25942. removePhysicsBody(impostor: PhysicsImpostor): void;
  25943. generateJoint(joint: PhysicsImpostorJoint): void;
  25944. removeJoint(joint: PhysicsImpostorJoint): void;
  25945. isSupported(): boolean;
  25946. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  25947. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  25948. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25949. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  25950. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25951. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  25952. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  25953. getBodyMass(impostor: PhysicsImpostor): number;
  25954. getBodyFriction(impostor: PhysicsImpostor): number;
  25955. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  25956. getBodyRestitution(impostor: PhysicsImpostor): number;
  25957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  25958. sleepBody(impostor: PhysicsImpostor): void;
  25959. wakeUpBody(impostor: PhysicsImpostor): void;
  25960. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  25961. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  25962. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25963. getRadius(impostor: PhysicsImpostor): number;
  25964. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  25965. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  25966. dispose(): void;
  25967. }
  25968. }
  25969. declare module BABYLON {
  25970. class PhysicsHelper {
  25971. private _scene;
  25972. private _physicsEngine;
  25973. constructor(scene: Scene);
  25974. /**
  25975. * @param {Vector3} origin the origin of the explosion
  25976. * @param {number} radius the explosion radius
  25977. * @param {number} strength the explosion strength
  25978. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25979. */
  25980. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25981. /**
  25982. * @param {Vector3} origin the origin of the explosion
  25983. * @param {number} radius the explosion radius
  25984. * @param {number} strength the explosion strength
  25985. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25986. */
  25987. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  25988. /**
  25989. * @param {Vector3} origin the origin of the explosion
  25990. * @param {number} radius the explosion radius
  25991. * @param {number} strength the explosion strength
  25992. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  25993. */
  25994. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  25995. /**
  25996. * @param {Vector3} origin the origin of the updraft
  25997. * @param {number} radius the radius of the updraft
  25998. * @param {number} strength the strength of the updraft
  25999. * @param {number} height the height of the updraft
  26000. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26001. */
  26002. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26003. /**
  26004. * @param {Vector3} origin the of the vortex
  26005. * @param {number} radius the radius of the vortex
  26006. * @param {number} strength the strength of the vortex
  26007. * @param {number} height the height of the vortex
  26008. */
  26009. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26010. }
  26011. /***** Radial explosion *****/
  26012. class PhysicsRadialExplosionEvent {
  26013. private _scene;
  26014. private _sphere;
  26015. private _sphereOptions;
  26016. private _rays;
  26017. private _dataFetched;
  26018. constructor(scene: Scene);
  26019. /**
  26020. * Returns the data related to the radial explosion event (sphere & rays).
  26021. * @returns {PhysicsRadialExplosionEventData}
  26022. */
  26023. getData(): PhysicsRadialExplosionEventData;
  26024. /**
  26025. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26026. * @param impostor
  26027. * @param {Vector3} origin the origin of the explosion
  26028. * @param {number} radius the explosion radius
  26029. * @param {number} strength the explosion strength
  26030. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26031. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26032. */
  26033. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26034. /**
  26035. * Disposes the sphere.
  26036. * @param {bolean} force
  26037. */
  26038. dispose(force?: boolean): void;
  26039. /*** Helpers ***/
  26040. private _prepareSphere();
  26041. private _intersectsWithSphere(impostor, origin, radius);
  26042. }
  26043. /***** Gravitational Field *****/
  26044. class PhysicsGravitationalFieldEvent {
  26045. private _physicsHelper;
  26046. private _scene;
  26047. private _origin;
  26048. private _radius;
  26049. private _strength;
  26050. private _falloff;
  26051. private _tickCallback;
  26052. private _sphere;
  26053. private _dataFetched;
  26054. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26055. /**
  26056. * Returns the data related to the gravitational field event (sphere).
  26057. * @returns {PhysicsGravitationalFieldEventData}
  26058. */
  26059. getData(): PhysicsGravitationalFieldEventData;
  26060. /**
  26061. * Enables the gravitational field.
  26062. */
  26063. enable(): void;
  26064. /**
  26065. * Disables the gravitational field.
  26066. */
  26067. disable(): void;
  26068. /**
  26069. * Disposes the sphere.
  26070. * @param {bolean} force
  26071. */
  26072. dispose(force?: boolean): void;
  26073. private _tick();
  26074. }
  26075. /***** Updraft *****/
  26076. class PhysicsUpdraftEvent {
  26077. private _scene;
  26078. private _origin;
  26079. private _radius;
  26080. private _strength;
  26081. private _height;
  26082. private _updraftMode;
  26083. private _physicsEngine;
  26084. private _originTop;
  26085. private _originDirection;
  26086. private _tickCallback;
  26087. private _cylinder;
  26088. private _cylinderPosition;
  26089. private _dataFetched;
  26090. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26091. /**
  26092. * Returns the data related to the updraft event (cylinder).
  26093. * @returns {PhysicsUpdraftEventData}
  26094. */
  26095. getData(): PhysicsUpdraftEventData;
  26096. /**
  26097. * Enables the updraft.
  26098. */
  26099. enable(): void;
  26100. /**
  26101. * Disables the cortex.
  26102. */
  26103. disable(): void;
  26104. /**
  26105. * Disposes the sphere.
  26106. * @param {bolean} force
  26107. */
  26108. dispose(force?: boolean): void;
  26109. private getImpostorForceAndContactPoint(impostor);
  26110. private _tick();
  26111. /*** Helpers ***/
  26112. private _prepareCylinder();
  26113. private _intersectsWithCylinder(impostor);
  26114. }
  26115. /***** Vortex *****/
  26116. class PhysicsVortexEvent {
  26117. private _scene;
  26118. private _origin;
  26119. private _radius;
  26120. private _strength;
  26121. private _height;
  26122. private _physicsEngine;
  26123. private _originTop;
  26124. private _centripetalForceThreshold;
  26125. private _updraftMultiplier;
  26126. private _tickCallback;
  26127. private _cylinder;
  26128. private _cylinderPosition;
  26129. private _dataFetched;
  26130. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26131. /**
  26132. * Returns the data related to the vortex event (cylinder).
  26133. * @returns {PhysicsVortexEventData}
  26134. */
  26135. getData(): PhysicsVortexEventData;
  26136. /**
  26137. * Enables the vortex.
  26138. */
  26139. enable(): void;
  26140. /**
  26141. * Disables the cortex.
  26142. */
  26143. disable(): void;
  26144. /**
  26145. * Disposes the sphere.
  26146. * @param {bolean} force
  26147. */
  26148. dispose(force?: boolean): void;
  26149. private getImpostorForceAndContactPoint(impostor);
  26150. private _tick();
  26151. /*** Helpers ***/
  26152. private _prepareCylinder();
  26153. private _intersectsWithCylinder(impostor);
  26154. }
  26155. /***** Enums *****/
  26156. /**
  26157. * The strenght of the force in correspondence to the distance of the affected object
  26158. */
  26159. enum PhysicsRadialImpulseFalloff {
  26160. /** Defines that impulse is constant in strength across it's whole radius */
  26161. Constant = 0,
  26162. /** DEfines that impulse gets weaker if it's further from the origin */
  26163. Linear = 1,
  26164. }
  26165. /**
  26166. * The strenght of the force in correspondence to the distance of the affected object
  26167. */
  26168. enum PhysicsUpdraftMode {
  26169. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26170. Center = 0,
  26171. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26172. Perpendicular = 1,
  26173. }
  26174. /***** Data interfaces *****/
  26175. interface PhysicsForceAndContactPoint {
  26176. force: Vector3;
  26177. contactPoint: Vector3;
  26178. }
  26179. interface PhysicsRadialExplosionEventData {
  26180. sphere: Mesh;
  26181. rays: Array<Ray>;
  26182. }
  26183. interface PhysicsGravitationalFieldEventData {
  26184. sphere: Mesh;
  26185. }
  26186. interface PhysicsUpdraftEventData {
  26187. cylinder: Mesh;
  26188. }
  26189. interface PhysicsVortexEventData {
  26190. cylinder: Mesh;
  26191. }
  26192. }
  26193. declare module BABYLON {
  26194. interface PhysicsImpostorParameters {
  26195. mass: number;
  26196. friction?: number;
  26197. restitution?: number;
  26198. nativeOptions?: any;
  26199. ignoreParent?: boolean;
  26200. disableBidirectionalTransformation?: boolean;
  26201. }
  26202. interface IPhysicsEnabledObject {
  26203. position: Vector3;
  26204. rotationQuaternion: Nullable<Quaternion>;
  26205. scaling: Vector3;
  26206. rotation?: Vector3;
  26207. parent?: any;
  26208. getBoundingInfo(): BoundingInfo;
  26209. computeWorldMatrix(force: boolean): Matrix;
  26210. getWorldMatrix?(): Matrix;
  26211. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26212. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26213. getIndices?(): Nullable<IndicesArray>;
  26214. getScene?(): Scene;
  26215. getAbsolutePosition(): Vector3;
  26216. getAbsolutePivotPoint(): Vector3;
  26217. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26218. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26219. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26220. getClassName(): string;
  26221. }
  26222. class PhysicsImpostor {
  26223. object: IPhysicsEnabledObject;
  26224. type: number;
  26225. private _options;
  26226. private _scene;
  26227. static DEFAULT_OBJECT_SIZE: Vector3;
  26228. static IDENTITY_QUATERNION: Quaternion;
  26229. private _physicsEngine;
  26230. private _physicsBody;
  26231. private _bodyUpdateRequired;
  26232. private _onBeforePhysicsStepCallbacks;
  26233. private _onAfterPhysicsStepCallbacks;
  26234. private _onPhysicsCollideCallbacks;
  26235. private _deltaPosition;
  26236. private _deltaRotation;
  26237. private _deltaRotationConjugated;
  26238. private _parent;
  26239. private _isDisposed;
  26240. private static _tmpVecs;
  26241. private static _tmpQuat;
  26242. readonly isDisposed: boolean;
  26243. mass: number;
  26244. friction: number;
  26245. restitution: number;
  26246. uniqueId: number;
  26247. private _joints;
  26248. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26249. /**
  26250. * This function will completly initialize this impostor.
  26251. * It will create a new body - but only if this mesh has no parent.
  26252. * If it has, this impostor will not be used other than to define the impostor
  26253. * of the child mesh.
  26254. */
  26255. _init(): void;
  26256. private _getPhysicsParent();
  26257. /**
  26258. * Should a new body be generated.
  26259. */
  26260. isBodyInitRequired(): boolean;
  26261. setScalingUpdated(updated: boolean): void;
  26262. /**
  26263. * Force a regeneration of this or the parent's impostor's body.
  26264. * Use under cautious - This will remove all joints already implemented.
  26265. */
  26266. forceUpdate(): void;
  26267. /**
  26268. * Gets the body that holds this impostor. Either its own, or its parent.
  26269. */
  26270. /**
  26271. * Set the physics body. Used mainly by the physics engine/plugin
  26272. */
  26273. physicsBody: any;
  26274. parent: Nullable<PhysicsImpostor>;
  26275. resetUpdateFlags(): void;
  26276. getObjectExtendSize(): Vector3;
  26277. getObjectCenter(): Vector3;
  26278. /**
  26279. * Get a specific parametes from the options parameter.
  26280. */
  26281. getParam(paramName: string): any;
  26282. /**
  26283. * Sets a specific parameter in the options given to the physics plugin
  26284. */
  26285. setParam(paramName: string, value: number): void;
  26286. /**
  26287. * Specifically change the body's mass option. Won't recreate the physics body object
  26288. */
  26289. setMass(mass: number): void;
  26290. getLinearVelocity(): Nullable<Vector3>;
  26291. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26292. getAngularVelocity(): Nullable<Vector3>;
  26293. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26294. /**
  26295. * Execute a function with the physics plugin native code.
  26296. * Provide a function the will have two variables - the world object and the physics body object.
  26297. */
  26298. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26299. /**
  26300. * Register a function that will be executed before the physics world is stepping forward.
  26301. */
  26302. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26303. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26304. /**
  26305. * Register a function that will be executed after the physics step
  26306. */
  26307. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26308. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26309. /**
  26310. * register a function that will be executed when this impostor collides against a different body.
  26311. */
  26312. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26313. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26314. private _tmpQuat;
  26315. private _tmpQuat2;
  26316. getParentsRotation(): Quaternion;
  26317. /**
  26318. * this function is executed by the physics engine.
  26319. */
  26320. beforeStep: () => void;
  26321. /**
  26322. * this function is executed by the physics engine.
  26323. */
  26324. afterStep: () => void;
  26325. /**
  26326. * Legacy collision detection event support
  26327. */
  26328. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26329. onCollide: (e: {
  26330. body: any;
  26331. }) => void;
  26332. /**
  26333. * Apply a force
  26334. */
  26335. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26336. /**
  26337. * Apply an impulse
  26338. */
  26339. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26340. /**
  26341. * A help function to create a joint.
  26342. */
  26343. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26344. /**
  26345. * Add a joint to this impostor with a different impostor.
  26346. */
  26347. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26348. /**
  26349. * Will keep this body still, in a sleep mode.
  26350. */
  26351. sleep(): PhysicsImpostor;
  26352. /**
  26353. * Wake the body up.
  26354. */
  26355. wakeUp(): PhysicsImpostor;
  26356. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26357. dispose(): void;
  26358. setDeltaPosition(position: Vector3): void;
  26359. setDeltaRotation(rotation: Quaternion): void;
  26360. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26361. getRadius(): number;
  26362. /**
  26363. * Sync a bone with this impostor
  26364. * @param bone The bone to sync to the impostor.
  26365. * @param boneMesh The mesh that the bone is influencing.
  26366. * @param jointPivot The pivot of the joint / bone in local space.
  26367. * @param distToJoint Optional distance from the impostor to the joint.
  26368. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26369. */
  26370. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  26371. /**
  26372. * Sync impostor to a bone
  26373. * @param bone The bone that the impostor will be synced to.
  26374. * @param boneMesh The mesh that the bone is influencing.
  26375. * @param jointPivot The pivot of the joint / bone in local space.
  26376. * @param distToJoint Optional distance from the impostor to the joint.
  26377. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26378. * @param boneAxis Optional vector3 axis the bone is aligned with
  26379. */
  26380. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  26381. static NoImpostor: number;
  26382. static SphereImpostor: number;
  26383. static BoxImpostor: number;
  26384. static PlaneImpostor: number;
  26385. static MeshImpostor: number;
  26386. static CylinderImpostor: number;
  26387. static ParticleImpostor: number;
  26388. static HeightmapImpostor: number;
  26389. }
  26390. }
  26391. declare module BABYLON {
  26392. interface PhysicsJointData {
  26393. mainPivot?: Vector3;
  26394. connectedPivot?: Vector3;
  26395. mainAxis?: Vector3;
  26396. connectedAxis?: Vector3;
  26397. collision?: boolean;
  26398. nativeParams?: any;
  26399. }
  26400. /**
  26401. * This is a holder class for the physics joint created by the physics plugin.
  26402. * It holds a set of functions to control the underlying joint.
  26403. */
  26404. class PhysicsJoint {
  26405. type: number;
  26406. jointData: PhysicsJointData;
  26407. private _physicsJoint;
  26408. protected _physicsPlugin: IPhysicsEnginePlugin;
  26409. constructor(type: number, jointData: PhysicsJointData);
  26410. physicsJoint: any;
  26411. physicsPlugin: IPhysicsEnginePlugin;
  26412. /**
  26413. * Execute a function that is physics-plugin specific.
  26414. * @param {Function} func the function that will be executed.
  26415. * It accepts two parameters: the physics world and the physics joint.
  26416. */
  26417. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26418. static DistanceJoint: number;
  26419. static HingeJoint: number;
  26420. static BallAndSocketJoint: number;
  26421. static WheelJoint: number;
  26422. static SliderJoint: number;
  26423. static PrismaticJoint: number;
  26424. static UniversalJoint: number;
  26425. static Hinge2Joint: number;
  26426. static PointToPointJoint: number;
  26427. static SpringJoint: number;
  26428. static LockJoint: number;
  26429. }
  26430. /**
  26431. * A class representing a physics distance joint.
  26432. */
  26433. class DistanceJoint extends PhysicsJoint {
  26434. constructor(jointData: DistanceJointData);
  26435. /**
  26436. * Update the predefined distance.
  26437. */
  26438. updateDistance(maxDistance: number, minDistance?: number): void;
  26439. }
  26440. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26441. constructor(type: number, jointData: PhysicsJointData);
  26442. /**
  26443. * Set the motor values.
  26444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26445. * @param {number} force the force to apply
  26446. * @param {number} maxForce max force for this motor.
  26447. */
  26448. setMotor(force?: number, maxForce?: number): void;
  26449. /**
  26450. * Set the motor's limits.
  26451. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26452. */
  26453. setLimit(upperLimit: number, lowerLimit?: number): void;
  26454. }
  26455. /**
  26456. * This class represents a single hinge physics joint
  26457. */
  26458. class HingeJoint extends MotorEnabledJoint {
  26459. constructor(jointData: PhysicsJointData);
  26460. /**
  26461. * Set the motor values.
  26462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26463. * @param {number} force the force to apply
  26464. * @param {number} maxForce max force for this motor.
  26465. */
  26466. setMotor(force?: number, maxForce?: number): void;
  26467. /**
  26468. * Set the motor's limits.
  26469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26470. */
  26471. setLimit(upperLimit: number, lowerLimit?: number): void;
  26472. }
  26473. /**
  26474. * This class represents a dual hinge physics joint (same as wheel joint)
  26475. */
  26476. class Hinge2Joint extends MotorEnabledJoint {
  26477. constructor(jointData: PhysicsJointData);
  26478. /**
  26479. * Set the motor values.
  26480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26481. * @param {number} force the force to apply
  26482. * @param {number} maxForce max force for this motor.
  26483. * @param {motorIndex} the motor's index, 0 or 1.
  26484. */
  26485. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26486. /**
  26487. * Set the motor limits.
  26488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26489. * @param {number} upperLimit the upper limit
  26490. * @param {number} lowerLimit lower limit
  26491. * @param {motorIndex} the motor's index, 0 or 1.
  26492. */
  26493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26494. }
  26495. interface IMotorEnabledJoint {
  26496. physicsJoint: any;
  26497. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26498. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26499. }
  26500. interface DistanceJointData extends PhysicsJointData {
  26501. maxDistance: number;
  26502. }
  26503. interface SpringJointData extends PhysicsJointData {
  26504. length: number;
  26505. stiffness: number;
  26506. damping: number;
  26507. }
  26508. }
  26509. declare module BABYLON {
  26510. class ReflectionProbe {
  26511. name: string;
  26512. private _scene;
  26513. private _renderTargetTexture;
  26514. private _projectionMatrix;
  26515. private _viewMatrix;
  26516. private _target;
  26517. private _add;
  26518. private _attachedMesh;
  26519. private _invertYAxis;
  26520. position: Vector3;
  26521. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26522. samples: number;
  26523. refreshRate: number;
  26524. getScene(): Scene;
  26525. readonly cubeTexture: RenderTargetTexture;
  26526. readonly renderList: Nullable<AbstractMesh[]>;
  26527. attachToMesh(mesh: AbstractMesh): void;
  26528. /**
  26529. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26530. *
  26531. * @param renderingGroupId The rendering group id corresponding to its index
  26532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26533. */
  26534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26535. dispose(): void;
  26536. }
  26537. }
  26538. declare module BABYLON {
  26539. class BoundingBoxRenderer {
  26540. frontColor: Color3;
  26541. backColor: Color3;
  26542. showBackLines: boolean;
  26543. renderList: SmartArray<BoundingBox>;
  26544. private _scene;
  26545. private _colorShader;
  26546. private _vertexBuffers;
  26547. private _indexBuffer;
  26548. constructor(scene: Scene);
  26549. private _prepareRessources();
  26550. private _createIndexBuffer();
  26551. _rebuild(): void;
  26552. reset(): void;
  26553. render(): void;
  26554. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26555. dispose(): void;
  26556. }
  26557. }
  26558. declare module BABYLON {
  26559. /**
  26560. * This represents a depth renderer in Babylon.
  26561. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26562. */
  26563. class DepthRenderer {
  26564. private _scene;
  26565. private _depthMap;
  26566. private _effect;
  26567. private _cachedDefines;
  26568. private _camera;
  26569. /**
  26570. * Instantiates a depth renderer
  26571. * @param scene The scene the renderer belongs to
  26572. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26573. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26574. */
  26575. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26576. /**
  26577. * Creates the depth rendering effect and checks if the effect is ready.
  26578. * @param subMesh The submesh to be used to render the depth map of
  26579. * @param useInstances If multiple world instances should be used
  26580. * @returns if the depth renderer is ready to render the depth map
  26581. */
  26582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26583. /**
  26584. * Gets the texture which the depth map will be written to.
  26585. * @returns The depth map texture
  26586. */
  26587. getDepthMap(): RenderTargetTexture;
  26588. /**
  26589. * Disposes of the depth renderer.
  26590. */
  26591. dispose(): void;
  26592. }
  26593. }
  26594. declare module BABYLON {
  26595. class EdgesRenderer {
  26596. edgesWidthScalerForOrthographic: number;
  26597. edgesWidthScalerForPerspective: number;
  26598. private _source;
  26599. private _linesPositions;
  26600. private _linesNormals;
  26601. private _linesIndices;
  26602. private _epsilon;
  26603. private _indicesCount;
  26604. private _lineShader;
  26605. private _ib;
  26606. private _buffers;
  26607. private _checkVerticesInsteadOfIndices;
  26608. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26609. isEnabled: boolean;
  26610. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26611. private _prepareRessources();
  26612. _rebuild(): void;
  26613. dispose(): void;
  26614. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26615. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26616. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26617. _generateEdgesLines(): void;
  26618. render(): void;
  26619. }
  26620. }
  26621. declare module BABYLON {
  26622. /**
  26623. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26624. */
  26625. class GeometryBufferRenderer {
  26626. private _scene;
  26627. private _multiRenderTarget;
  26628. private _ratio;
  26629. private _enablePosition;
  26630. protected _effect: Effect;
  26631. protected _cachedDefines: string;
  26632. /**
  26633. * Set the render list (meshes to be rendered) used in the G buffer.
  26634. */
  26635. renderList: Mesh[];
  26636. /**
  26637. * Gets wether or not G buffer are supported by the running hardware.
  26638. * This requires draw buffer supports
  26639. */
  26640. readonly isSupported: boolean;
  26641. /**
  26642. * Gets wether or not position are enabled for the G buffer.
  26643. */
  26644. /**
  26645. * Sets wether or not position are enabled for the G buffer.
  26646. */
  26647. enablePosition: boolean;
  26648. /**
  26649. * Gets the scene associated with the buffer.
  26650. */
  26651. readonly scene: Scene;
  26652. /**
  26653. * Gets the ratio used by the buffer during its creation.
  26654. * How big is the buffer related to the main canvas.
  26655. */
  26656. readonly ratio: number;
  26657. /**
  26658. * Creates a new G Buffer for the scene
  26659. * @param scene The scene the buffer belongs to
  26660. * @param ratio How big is the buffer related to the main canvas.
  26661. */
  26662. constructor(scene: Scene, ratio?: number);
  26663. /**
  26664. * Checks wether everything is ready to render a submesh to the G buffer.
  26665. * @param subMesh the submesh to check readiness for
  26666. * @param useInstances is the mesh drawn using instance or not
  26667. * @returns true if ready otherwise false
  26668. */
  26669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26670. /**
  26671. * Gets the current underlying G Buffer.
  26672. * @returns the buffer
  26673. */
  26674. getGBuffer(): MultiRenderTarget;
  26675. /**
  26676. * Gets the number of samples used to render the buffer (anti aliasing).
  26677. */
  26678. /**
  26679. * Sets the number of samples used to render the buffer (anti aliasing).
  26680. */
  26681. samples: number;
  26682. /**
  26683. * Disposes the renderer and frees up associated resources.
  26684. */
  26685. dispose(): void;
  26686. protected _createRenderTargets(): void;
  26687. }
  26688. }
  26689. declare module BABYLON {
  26690. class OutlineRenderer {
  26691. private _scene;
  26692. private _effect;
  26693. private _cachedDefines;
  26694. zOffset: number;
  26695. constructor(scene: Scene);
  26696. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26698. }
  26699. }
  26700. declare module BABYLON {
  26701. class RenderingGroup {
  26702. index: number;
  26703. private _scene;
  26704. private _opaqueSubMeshes;
  26705. private _transparentSubMeshes;
  26706. private _alphaTestSubMeshes;
  26707. private _depthOnlySubMeshes;
  26708. private _particleSystems;
  26709. private _spriteManagers;
  26710. private _opaqueSortCompareFn;
  26711. private _alphaTestSortCompareFn;
  26712. private _transparentSortCompareFn;
  26713. private _renderOpaque;
  26714. private _renderAlphaTest;
  26715. private _renderTransparent;
  26716. private _edgesRenderers;
  26717. onBeforeTransparentRendering: () => void;
  26718. /**
  26719. * Set the opaque sort comparison function.
  26720. * If null the sub meshes will be render in the order they were created
  26721. */
  26722. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26723. /**
  26724. * Set the alpha test sort comparison function.
  26725. * If null the sub meshes will be render in the order they were created
  26726. */
  26727. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26728. /**
  26729. * Set the transparent sort comparison function.
  26730. * If null the sub meshes will be render in the order they were created
  26731. */
  26732. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26733. /**
  26734. * Creates a new rendering group.
  26735. * @param index The rendering group index
  26736. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26737. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26738. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26739. */
  26740. 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>);
  26741. /**
  26742. * Render all the sub meshes contained in the group.
  26743. * @param customRenderFunction Used to override the default render behaviour of the group.
  26744. * @returns true if rendered some submeshes.
  26745. */
  26746. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26747. /**
  26748. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26749. * @param subMeshes The submeshes to render
  26750. */
  26751. private renderOpaqueSorted(subMeshes);
  26752. /**
  26753. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26754. * @param subMeshes The submeshes to render
  26755. */
  26756. private renderAlphaTestSorted(subMeshes);
  26757. /**
  26758. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26759. * @param subMeshes The submeshes to render
  26760. */
  26761. private renderTransparentSorted(subMeshes);
  26762. /**
  26763. * Renders the submeshes in a specified order.
  26764. * @param subMeshes The submeshes to sort before render
  26765. * @param sortCompareFn The comparison function use to sort
  26766. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26767. * @param transparent Specifies to activate blending if true
  26768. */
  26769. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26770. /**
  26771. * Renders the submeshes in the order they were dispatched (no sort applied).
  26772. * @param subMeshes The submeshes to render
  26773. */
  26774. private static renderUnsorted(subMeshes);
  26775. /**
  26776. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26777. * are rendered back to front if in the same alpha index.
  26778. *
  26779. * @param a The first submesh
  26780. * @param b The second submesh
  26781. * @returns The result of the comparison
  26782. */
  26783. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26784. /**
  26785. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26786. * are rendered back to front.
  26787. *
  26788. * @param a The first submesh
  26789. * @param b The second submesh
  26790. * @returns The result of the comparison
  26791. */
  26792. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26793. /**
  26794. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26795. * are rendered front to back (prevent overdraw).
  26796. *
  26797. * @param a The first submesh
  26798. * @param b The second submesh
  26799. * @returns The result of the comparison
  26800. */
  26801. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26802. /**
  26803. * Resets the different lists of submeshes to prepare a new frame.
  26804. */
  26805. prepare(): void;
  26806. dispose(): void;
  26807. /**
  26808. * Inserts the submesh in its correct queue depending on its material.
  26809. * @param subMesh The submesh to dispatch
  26810. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26811. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26812. */
  26813. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26814. dispatchSprites(spriteManager: SpriteManager): void;
  26815. dispatchParticles(particleSystem: IParticleSystem): void;
  26816. private _renderParticles(activeMeshes);
  26817. private _renderSprites();
  26818. }
  26819. }
  26820. declare module BABYLON {
  26821. class RenderingManager {
  26822. /**
  26823. * The max id used for rendering groups (not included)
  26824. */
  26825. static MAX_RENDERINGGROUPS: number;
  26826. /**
  26827. * The min id used for rendering groups (included)
  26828. */
  26829. static MIN_RENDERINGGROUPS: number;
  26830. /**
  26831. * Used to globally prevent autoclearing scenes.
  26832. */
  26833. static AUTOCLEAR: boolean;
  26834. private _scene;
  26835. private _renderingGroups;
  26836. private _depthStencilBufferAlreadyCleaned;
  26837. private _autoClearDepthStencil;
  26838. private _customOpaqueSortCompareFn;
  26839. private _customAlphaTestSortCompareFn;
  26840. private _customTransparentSortCompareFn;
  26841. private _renderinGroupInfo;
  26842. constructor(scene: Scene);
  26843. private _clearDepthStencilBuffer(depth?, stencil?);
  26844. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26845. reset(): void;
  26846. dispose(): void;
  26847. /**
  26848. * Clear the info related to rendering groups preventing retention points during dispose.
  26849. */
  26850. freeRenderingGroups(): void;
  26851. private _prepareRenderingGroup(renderingGroupId);
  26852. dispatchSprites(spriteManager: SpriteManager): void;
  26853. dispatchParticles(particleSystem: IParticleSystem): void;
  26854. /**
  26855. * @param subMesh The submesh to dispatch
  26856. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26857. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26858. */
  26859. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26860. /**
  26861. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26862. * This allowed control for front to back rendering or reversly depending of the special needs.
  26863. *
  26864. * @param renderingGroupId The rendering group id corresponding to its index
  26865. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26866. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26867. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26868. */
  26869. 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;
  26870. /**
  26871. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26872. *
  26873. * @param renderingGroupId The rendering group id corresponding to its index
  26874. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26875. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26876. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26877. */
  26878. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26879. }
  26880. }
  26881. declare module BABYLON {
  26882. /**
  26883. * Renders a layer on top of an existing scene
  26884. */
  26885. class UtilityLayerRenderer implements IDisposable {
  26886. /** the original scene that will be rendered on top of */ originalScene: Scene;
  26887. private _pointerCaptures;
  26888. private _lastPointerEvents;
  26889. private static _DefaultUtilityLayer;
  26890. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  26891. /**
  26892. * The scene that is rendered on top of the original scene
  26893. */
  26894. utilityLayerScene: Scene;
  26895. /**
  26896. * If the utility layer should automatically be rendered on top of existing scene
  26897. */
  26898. shouldRender: boolean;
  26899. /**
  26900. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  26901. */
  26902. onlyCheckPointerDownEvents: boolean;
  26903. /**
  26904. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  26905. */
  26906. processAllEvents: boolean;
  26907. /**
  26908. * Observable raised when the pointer move from the utility layer scene to the main scene
  26909. */
  26910. onPointerOutObservable: Observable<number>;
  26911. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  26912. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  26913. private _afterRenderObserver;
  26914. private _sceneDisposeObserver;
  26915. private _originalPointerObserver;
  26916. /**
  26917. * Instantiates a UtilityLayerRenderer
  26918. * @param originalScene the original scene that will be rendered on top of
  26919. */
  26920. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  26921. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  26922. /**
  26923. * Renders the utility layers scene on top of the original scene
  26924. */
  26925. render(): void;
  26926. /**
  26927. * Disposes of the renderer
  26928. */
  26929. dispose(): void;
  26930. private _updateCamera();
  26931. }
  26932. }
  26933. declare module BABYLON {
  26934. /**
  26935. * Postprocess used to generate anaglyphic rendering
  26936. */
  26937. class AnaglyphPostProcess extends PostProcess {
  26938. private _passedProcess;
  26939. /**
  26940. * Creates a new AnaglyphPostProcess
  26941. * @param name defines postprocess name
  26942. * @param options defines creation options or target ratio scale
  26943. * @param rigCameras defines cameras using this postprocess
  26944. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26945. * @param engine defines hosting engine
  26946. * @param reusable defines if the postprocess will be reused multiple times per frame
  26947. */
  26948. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  26949. }
  26950. }
  26951. declare module BABYLON {
  26952. class BlackAndWhitePostProcess extends PostProcess {
  26953. degree: number;
  26954. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26955. }
  26956. }
  26957. declare module BABYLON {
  26958. /**
  26959. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  26960. */
  26961. class BloomEffect extends PostProcessRenderEffect {
  26962. private bloomScale;
  26963. /**
  26964. * Internal
  26965. */
  26966. _effects: Array<PostProcess>;
  26967. /**
  26968. * Internal
  26969. */
  26970. _downscale: ExtractHighlightsPostProcess;
  26971. private _blurX;
  26972. private _blurY;
  26973. private _merge;
  26974. /**
  26975. * The luminance threshold to find bright areas of the image to bloom.
  26976. */
  26977. threshold: number;
  26978. /**
  26979. * The strength of the bloom.
  26980. */
  26981. weight: number;
  26982. /**
  26983. * Specifies the size of the bloom blur kernel, relative to the final output size
  26984. */
  26985. kernel: number;
  26986. /**
  26987. * Creates a new instance of @see BloomEffect
  26988. * @param scene The scene the effect belongs to.
  26989. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  26990. * @param bloomKernel The size of the kernel to be used when applying the blur.
  26991. * @param bloomWeight The the strength of bloom.
  26992. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  26993. * @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)
  26994. */
  26995. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  26996. /**
  26997. * Disposes each of the internal effects for a given camera.
  26998. * @param camera The camera to dispose the effect on.
  26999. */
  27000. disposeEffects(camera: Camera): void;
  27001. /**
  27002. * Internal
  27003. */
  27004. _updateEffects(): void;
  27005. /**
  27006. * Internal
  27007. * @returns if all the contained post processes are ready.
  27008. */
  27009. _isReady(): boolean;
  27010. }
  27011. }
  27012. declare module BABYLON {
  27013. /**
  27014. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27015. */
  27016. class BloomMergePostProcess extends PostProcess {
  27017. /** Weight of the bloom to be added to the original input. */ weight: number;
  27018. /**
  27019. * Creates a new instance of @see BloomMergePostProcess
  27020. * @param name The name of the effect.
  27021. * @param originalFromInput Post process which's input will be used for the merge.
  27022. * @param blurred Blurred highlights post process which's output will be used.
  27023. * @param weight Weight of the bloom to be added to the original input.
  27024. * @param options The required width/height ratio to downsize to before computing the render pass.
  27025. * @param camera The camera to apply the render pass to.
  27026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27027. * @param engine The engine which the post process will be applied. (default: current engine)
  27028. * @param reusable If the post process can be reused on the same frame. (default: false)
  27029. * @param textureType Type of textures used when performing the post process. (default: 0)
  27030. * @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)
  27031. */
  27032. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27033. }
  27034. }
  27035. declare module BABYLON {
  27036. /**
  27037. * The Blur Post Process which blurs an image based on a kernel and direction.
  27038. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27039. */
  27040. class BlurPostProcess extends PostProcess {
  27041. /** The direction in which to blur the image. */ direction: Vector2;
  27042. private blockCompilation;
  27043. protected _kernel: number;
  27044. protected _idealKernel: number;
  27045. protected _packedFloat: boolean;
  27046. private _staticDefines;
  27047. /**
  27048. * Gets the length in pixels of the blur sample region
  27049. */
  27050. /**
  27051. * Sets the length in pixels of the blur sample region
  27052. */
  27053. kernel: number;
  27054. /**
  27055. * Gets wether or not the blur is unpacking/repacking floats
  27056. */
  27057. /**
  27058. * Sets wether or not the blur needs to unpack/repack floats
  27059. */
  27060. packedFloat: boolean;
  27061. /**
  27062. * Creates a new instance BlurPostProcess
  27063. * @param name The name of the effect.
  27064. * @param direction The direction in which to blur the image.
  27065. * @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.
  27066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27067. * @param camera The camera to apply the render pass to.
  27068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27069. * @param engine The engine which the post process will be applied. (default: current engine)
  27070. * @param reusable If the post process can be reused on the same frame. (default: false)
  27071. * @param textureType Type of textures used when performing the post process. (default: 0)
  27072. * @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)
  27073. */
  27074. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27075. /**
  27076. * Updates the effect with the current post process compile time values and recompiles the shader.
  27077. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27078. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27079. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27080. * @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
  27081. * @param onCompiled Called when the shader has been compiled.
  27082. * @param onError Called if there is an error when compiling a shader.
  27083. */
  27084. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27085. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27086. /**
  27087. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27088. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27089. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27090. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27091. * The gaps between physical kernels are compensated for in the weighting of the samples
  27092. * @param idealKernel Ideal blur kernel.
  27093. * @return Nearest best kernel.
  27094. */
  27095. protected _nearestBestKernel(idealKernel: number): number;
  27096. /**
  27097. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27098. * @param x The point on the Gaussian distribution to sample.
  27099. * @return the value of the Gaussian function at x.
  27100. */
  27101. protected _gaussianWeight(x: number): number;
  27102. /**
  27103. * Generates a string that can be used as a floating point number in GLSL.
  27104. * @param x Value to print.
  27105. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27106. * @return GLSL float string.
  27107. */
  27108. protected _glslFloat(x: number, decimalFigures?: number): string;
  27109. }
  27110. }
  27111. declare module BABYLON {
  27112. /**
  27113. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27114. */
  27115. class ChromaticAberrationPostProcess extends PostProcess {
  27116. /**
  27117. * The amount of seperation of rgb channels (default: 30)
  27118. */
  27119. aberrationAmount: number;
  27120. /**
  27121. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27122. */
  27123. radialIntensity: number;
  27124. /**
  27125. * 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))
  27126. */
  27127. direction: Vector2;
  27128. /**
  27129. * 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))
  27130. */
  27131. centerPosition: Vector2;
  27132. /**
  27133. * Creates a new instance ChromaticAberrationPostProcess
  27134. * @param name The name of the effect.
  27135. * @param screenWidth The width of the screen to apply the effect on.
  27136. * @param screenHeight The height of the screen to apply the effect on.
  27137. * @param options The required width/height ratio to downsize to before computing the render pass.
  27138. * @param camera The camera to apply the render pass to.
  27139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27140. * @param engine The engine which the post process will be applied. (default: current engine)
  27141. * @param reusable If the post process can be reused on the same frame. (default: false)
  27142. * @param textureType Type of textures used when performing the post process. (default: 0)
  27143. * @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)
  27144. */
  27145. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27146. }
  27147. }
  27148. declare module BABYLON {
  27149. /**
  27150. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27151. */
  27152. class CircleOfConfusionPostProcess extends PostProcess {
  27153. /**
  27154. * 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.
  27155. */
  27156. lensSize: number;
  27157. /**
  27158. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27159. */
  27160. fStop: number;
  27161. /**
  27162. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27163. */
  27164. focusDistance: number;
  27165. /**
  27166. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27167. */
  27168. focalLength: number;
  27169. private _depthTexture;
  27170. /**
  27171. * Creates a new instance CircleOfConfusionPostProcess
  27172. * @param name The name of the effect.
  27173. * @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.
  27174. * @param options The required width/height ratio to downsize to before computing the render pass.
  27175. * @param camera The camera to apply the render pass to.
  27176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27177. * @param engine The engine which the post process will be applied. (default: current engine)
  27178. * @param reusable If the post process can be reused on the same frame. (default: false)
  27179. * @param textureType Type of textures used when performing the post process. (default: 0)
  27180. * @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)
  27181. */
  27182. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27183. /**
  27184. * 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.
  27185. */
  27186. depthTexture: RenderTargetTexture;
  27187. }
  27188. }
  27189. declare module BABYLON {
  27190. class ColorCorrectionPostProcess extends PostProcess {
  27191. private _colorTableTexture;
  27192. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27193. }
  27194. }
  27195. declare module BABYLON {
  27196. /**
  27197. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27198. * input texture to perform effects such as edge detection or sharpening
  27199. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27200. */
  27201. class ConvolutionPostProcess extends PostProcess {
  27202. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  27203. /**
  27204. * Creates a new instance ConvolutionPostProcess
  27205. * @param name The name of the effect.
  27206. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27207. * @param options The required width/height ratio to downsize to before computing the render pass.
  27208. * @param camera The camera to apply the render pass to.
  27209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27210. * @param engine The engine which the post process will be applied. (default: current engine)
  27211. * @param reusable If the post process can be reused on the same frame. (default: false)
  27212. * @param textureType Type of textures used when performing the post process. (default: 0)
  27213. */
  27214. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27215. /**
  27216. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27217. */
  27218. static EdgeDetect0Kernel: number[];
  27219. /**
  27220. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27221. */
  27222. static EdgeDetect1Kernel: number[];
  27223. /**
  27224. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27225. */
  27226. static EdgeDetect2Kernel: number[];
  27227. /**
  27228. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27229. */
  27230. static SharpenKernel: number[];
  27231. /**
  27232. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27233. */
  27234. static EmbossKernel: number[];
  27235. /**
  27236. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27237. */
  27238. static GaussianKernel: number[];
  27239. }
  27240. }
  27241. declare module BABYLON {
  27242. /**
  27243. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27244. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27245. * based on samples that have a large difference in distance than the center pixel.
  27246. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27247. */
  27248. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27249. direction: Vector2;
  27250. /**
  27251. * Creates a new instance CircleOfConfusionPostProcess
  27252. * @param name The name of the effect.
  27253. * @param scene The scene the effect belongs to.
  27254. * @param direction The direction the blur should be applied.
  27255. * @param kernel The size of the kernel used to blur.
  27256. * @param options The required width/height ratio to downsize to before computing the render pass.
  27257. * @param camera The camera to apply the render pass to.
  27258. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27259. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27261. * @param engine The engine which the post process will be applied. (default: current engine)
  27262. * @param reusable If the post process can be reused on the same frame. (default: false)
  27263. * @param textureType Type of textures used when performing the post process. (default: 0)
  27264. * @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)
  27265. */
  27266. 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);
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. /**
  27271. * Specifies the level of max blur that should be applied when using the depth of field effect
  27272. */
  27273. enum DepthOfFieldEffectBlurLevel {
  27274. /**
  27275. * Subtle blur
  27276. */
  27277. Low = 0,
  27278. /**
  27279. * Medium blur
  27280. */
  27281. Medium = 1,
  27282. /**
  27283. * Large blur
  27284. */
  27285. High = 2,
  27286. }
  27287. /**
  27288. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27289. */
  27290. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27291. private _circleOfConfusion;
  27292. /**
  27293. * Internal, blurs from high to low
  27294. */
  27295. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27296. private _depthOfFieldBlurY;
  27297. private _dofMerge;
  27298. /**
  27299. * Internal post processes in depth of field effect
  27300. */
  27301. _effects: Array<PostProcess>;
  27302. /**
  27303. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27304. */
  27305. focalLength: number;
  27306. /**
  27307. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27308. */
  27309. fStop: number;
  27310. /**
  27311. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27312. */
  27313. focusDistance: number;
  27314. /**
  27315. * 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.
  27316. */
  27317. lensSize: number;
  27318. /**
  27319. * Creates a new instance DepthOfFieldEffect
  27320. * @param scene The scene the effect belongs to.
  27321. * @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.
  27322. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27323. * @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)
  27324. */
  27325. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27326. /**
  27327. * 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.
  27328. */
  27329. depthTexture: RenderTargetTexture;
  27330. /**
  27331. * Disposes each of the internal effects for a given camera.
  27332. * @param camera The camera to dispose the effect on.
  27333. */
  27334. disposeEffects(camera: Camera): void;
  27335. /**
  27336. * Internal
  27337. */
  27338. _updateEffects(): void;
  27339. /**
  27340. * Internal
  27341. * @returns if all the contained post processes are ready.
  27342. */
  27343. _isReady(): boolean;
  27344. }
  27345. }
  27346. declare module BABYLON {
  27347. /**
  27348. * Options to be set when merging outputs from the default pipeline.
  27349. */
  27350. class DepthOfFieldMergePostProcessOptions {
  27351. /**
  27352. * The original image to merge on top of
  27353. */
  27354. originalFromInput: PostProcess;
  27355. /**
  27356. * Parameters to perform the merge of the depth of field effect
  27357. */
  27358. depthOfField?: {
  27359. circleOfConfusion: PostProcess;
  27360. blurSteps: Array<PostProcess>;
  27361. };
  27362. /**
  27363. * Parameters to perform the merge of bloom effect
  27364. */
  27365. bloom?: {
  27366. blurred: PostProcess;
  27367. weight: number;
  27368. };
  27369. }
  27370. /**
  27371. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27372. */
  27373. class DepthOfFieldMergePostProcess extends PostProcess {
  27374. private blurSteps;
  27375. /**
  27376. * Creates a new instance of DepthOfFieldMergePostProcess
  27377. * @param name The name of the effect.
  27378. * @param originalFromInput Post process which's input will be used for the merge.
  27379. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27380. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27381. * @param options The required width/height ratio to downsize to before computing the render pass.
  27382. * @param camera The camera to apply the render pass to.
  27383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27384. * @param engine The engine which the post process will be applied. (default: current engine)
  27385. * @param reusable If the post process can be reused on the same frame. (default: false)
  27386. * @param textureType Type of textures used when performing the post process. (default: 0)
  27387. * @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)
  27388. */
  27389. 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);
  27390. /**
  27391. * Updates the effect with the current post process compile time values and recompiles the shader.
  27392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27395. * @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
  27396. * @param onCompiled Called when the shader has been compiled.
  27397. * @param onError Called if there is an error when compiling a shader.
  27398. */
  27399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27400. }
  27401. }
  27402. declare module BABYLON {
  27403. class DisplayPassPostProcess extends PostProcess {
  27404. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27405. }
  27406. }
  27407. declare module BABYLON {
  27408. /**
  27409. * 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.
  27410. */
  27411. class ExtractHighlightsPostProcess extends PostProcess {
  27412. /**
  27413. * The luminance threshold, pixels below this value will be set to black.
  27414. */
  27415. threshold: number;
  27416. /**
  27417. * Internal
  27418. */
  27419. _exposure: number;
  27420. /**
  27421. * Post process which has the input texture to be used when performing highlight extraction
  27422. */
  27423. _inputPostProcess: Nullable<PostProcess>;
  27424. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27425. }
  27426. }
  27427. declare module BABYLON {
  27428. class FilterPostProcess extends PostProcess {
  27429. kernelMatrix: Matrix;
  27430. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27431. }
  27432. }
  27433. declare module BABYLON {
  27434. class FxaaPostProcess extends PostProcess {
  27435. texelWidth: number;
  27436. texelHeight: number;
  27437. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27438. private _getDefines();
  27439. }
  27440. }
  27441. declare module BABYLON {
  27442. /**
  27443. * The GrainPostProcess adds noise to the image at mid luminance levels
  27444. */
  27445. class GrainPostProcess extends PostProcess {
  27446. /**
  27447. * The intensity of the grain added (default: 30)
  27448. */
  27449. intensity: number;
  27450. /**
  27451. * If the grain should be randomized on every frame
  27452. */
  27453. animated: boolean;
  27454. /**
  27455. * Creates a new instance of @see GrainPostProcess
  27456. * @param name The name of the effect.
  27457. * @param options The required width/height ratio to downsize to before computing the render pass.
  27458. * @param camera The camera to apply the render pass to.
  27459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27460. * @param engine The engine which the post process will be applied. (default: current engine)
  27461. * @param reusable If the post process can be reused on the same frame. (default: false)
  27462. * @param textureType Type of textures used when performing the post process. (default: 0)
  27463. * @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)
  27464. */
  27465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27466. }
  27467. }
  27468. declare module BABYLON {
  27469. class HighlightsPostProcess extends PostProcess {
  27470. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27471. }
  27472. }
  27473. declare module BABYLON {
  27474. class ImageProcessingPostProcess extends PostProcess {
  27475. /**
  27476. * Default configuration related to image processing available in the PBR Material.
  27477. */
  27478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27479. /**
  27480. * Gets the image processing configuration used either in this material.
  27481. */
  27482. /**
  27483. * Sets the Default image processing configuration used either in the this material.
  27484. *
  27485. * If sets to null, the scene one is in use.
  27486. */
  27487. imageProcessingConfiguration: ImageProcessingConfiguration;
  27488. /**
  27489. * Keep track of the image processing observer to allow dispose and replace.
  27490. */
  27491. private _imageProcessingObserver;
  27492. /**
  27493. * Attaches a new image processing configuration to the PBR Material.
  27494. * @param configuration
  27495. */
  27496. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27497. /**
  27498. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27499. */
  27500. /**
  27501. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27502. */
  27503. colorCurves: Nullable<ColorCurves>;
  27504. /**
  27505. * Gets wether the color curves effect is enabled.
  27506. */
  27507. /**
  27508. * Sets wether the color curves effect is enabled.
  27509. */
  27510. colorCurvesEnabled: boolean;
  27511. /**
  27512. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27513. */
  27514. /**
  27515. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27516. */
  27517. colorGradingTexture: Nullable<BaseTexture>;
  27518. /**
  27519. * Gets wether the color grading effect is enabled.
  27520. */
  27521. /**
  27522. * Gets wether the color grading effect is enabled.
  27523. */
  27524. colorGradingEnabled: boolean;
  27525. /**
  27526. * Gets exposure used in the effect.
  27527. */
  27528. /**
  27529. * Sets exposure used in the effect.
  27530. */
  27531. exposure: number;
  27532. /**
  27533. * Gets wether tonemapping is enabled or not.
  27534. */
  27535. /**
  27536. * Sets wether tonemapping is enabled or not
  27537. */
  27538. toneMappingEnabled: boolean;
  27539. /**
  27540. * Gets contrast used in the effect.
  27541. */
  27542. /**
  27543. * Sets contrast used in the effect.
  27544. */
  27545. contrast: number;
  27546. /**
  27547. * Gets Vignette stretch size.
  27548. */
  27549. /**
  27550. * Sets Vignette stretch size.
  27551. */
  27552. vignetteStretch: number;
  27553. /**
  27554. * Gets Vignette centre X Offset.
  27555. */
  27556. /**
  27557. * Sets Vignette centre X Offset.
  27558. */
  27559. vignetteCentreX: number;
  27560. /**
  27561. * Gets Vignette centre Y Offset.
  27562. */
  27563. /**
  27564. * Sets Vignette centre Y Offset.
  27565. */
  27566. vignetteCentreY: number;
  27567. /**
  27568. * Gets Vignette weight or intensity of the vignette effect.
  27569. */
  27570. /**
  27571. * Sets Vignette weight or intensity of the vignette effect.
  27572. */
  27573. vignetteWeight: number;
  27574. /**
  27575. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27576. * if vignetteEnabled is set to true.
  27577. */
  27578. /**
  27579. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27580. * if vignetteEnabled is set to true.
  27581. */
  27582. vignetteColor: Color4;
  27583. /**
  27584. * Gets Camera field of view used by the Vignette effect.
  27585. */
  27586. /**
  27587. * Sets Camera field of view used by the Vignette effect.
  27588. */
  27589. vignetteCameraFov: number;
  27590. /**
  27591. * Gets the vignette blend mode allowing different kind of effect.
  27592. */
  27593. /**
  27594. * Sets the vignette blend mode allowing different kind of effect.
  27595. */
  27596. vignetteBlendMode: number;
  27597. /**
  27598. * Gets wether the vignette effect is enabled.
  27599. */
  27600. /**
  27601. * Sets wether the vignette effect is enabled.
  27602. */
  27603. vignetteEnabled: boolean;
  27604. private _fromLinearSpace;
  27605. /**
  27606. * Gets wether the input of the processing is in Gamma or Linear Space.
  27607. */
  27608. /**
  27609. * Sets wether the input of the processing is in Gamma or Linear Space.
  27610. */
  27611. fromLinearSpace: boolean;
  27612. /**
  27613. * Defines cache preventing GC.
  27614. */
  27615. private _defines;
  27616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27617. getClassName(): string;
  27618. protected _updateParameters(): void;
  27619. dispose(camera?: Camera): void;
  27620. }
  27621. }
  27622. declare module BABYLON {
  27623. class PassPostProcess extends PostProcess {
  27624. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27625. }
  27626. }
  27627. declare module BABYLON {
  27628. type PostProcessOptions = {
  27629. width: number;
  27630. height: number;
  27631. };
  27632. /**
  27633. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27634. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27635. */
  27636. class PostProcess {
  27637. /** Name of the PostProcess. */ name: string;
  27638. /**
  27639. * Width of the texture to apply the post process on
  27640. */
  27641. width: number;
  27642. /**
  27643. * Height of the texture to apply the post process on
  27644. */
  27645. height: number;
  27646. /**
  27647. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27648. */
  27649. _outputTexture: Nullable<InternalTexture>;
  27650. /**
  27651. * Sampling mode used by the shader
  27652. * See https://doc.babylonjs.com/classes/3.1/texture
  27653. */
  27654. renderTargetSamplingMode: number;
  27655. /**
  27656. * Clear color to use when screen clearing
  27657. */
  27658. clearColor: Color4;
  27659. /**
  27660. * If the buffer needs to be cleared before applying the post process. (default: true)
  27661. * Should be set to false if shader will overwrite all previous pixels.
  27662. */
  27663. autoClear: boolean;
  27664. /**
  27665. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27666. */
  27667. alphaMode: number;
  27668. /**
  27669. * Sets the setAlphaBlendConstants of the babylon engine
  27670. */
  27671. alphaConstants: Color4;
  27672. /**
  27673. * Animations to be used for the post processing
  27674. */
  27675. animations: Animation[];
  27676. /**
  27677. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27678. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27679. */
  27680. enablePixelPerfectMode: boolean;
  27681. /**
  27682. * Force the postprocess to be applied without taking in account viewport
  27683. */
  27684. forceFullscreenViewport: boolean;
  27685. /**
  27686. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27687. *
  27688. * | Value | Type | Description |
  27689. * | ----- | ----------------------------------- | ----------- |
  27690. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27691. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27692. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27693. *
  27694. */
  27695. scaleMode: number;
  27696. /**
  27697. * Force textures to be a power of two (default: false)
  27698. */
  27699. alwaysForcePOT: boolean;
  27700. /**
  27701. * Number of sample textures (default: 1)
  27702. */
  27703. samples: number;
  27704. /**
  27705. * Modify the scale of the post process to be the same as the viewport (default: false)
  27706. */
  27707. adaptScaleToCurrentViewport: boolean;
  27708. private _camera;
  27709. private _scene;
  27710. private _engine;
  27711. private _options;
  27712. private _reusable;
  27713. private _textureType;
  27714. /**
  27715. * Smart array of input and output textures for the post process.
  27716. */
  27717. _textures: SmartArray<InternalTexture>;
  27718. /**
  27719. * The index in _textures that corresponds to the output texture.
  27720. */
  27721. _currentRenderTextureInd: number;
  27722. private _effect;
  27723. private _samplers;
  27724. private _fragmentUrl;
  27725. private _vertexUrl;
  27726. private _parameters;
  27727. private _scaleRatio;
  27728. protected _indexParameters: any;
  27729. private _shareOutputWithPostProcess;
  27730. private _texelSize;
  27731. private _forcedOutputTexture;
  27732. /**
  27733. * An event triggered when the postprocess is activated.
  27734. */
  27735. onActivateObservable: Observable<Camera>;
  27736. private _onActivateObserver;
  27737. /**
  27738. * A function that is added to the onActivateObservable
  27739. */
  27740. onActivate: Nullable<(camera: Camera) => void>;
  27741. /**
  27742. * An event triggered when the postprocess changes its size.
  27743. */
  27744. onSizeChangedObservable: Observable<PostProcess>;
  27745. private _onSizeChangedObserver;
  27746. /**
  27747. * A function that is added to the onSizeChangedObservable
  27748. */
  27749. onSizeChanged: (postProcess: PostProcess) => void;
  27750. /**
  27751. * An event triggered when the postprocess applies its effect.
  27752. */
  27753. onApplyObservable: Observable<Effect>;
  27754. private _onApplyObserver;
  27755. /**
  27756. * A function that is added to the onApplyObservable
  27757. */
  27758. onApply: (effect: Effect) => void;
  27759. /**
  27760. * An event triggered before rendering the postprocess
  27761. */
  27762. onBeforeRenderObservable: Observable<Effect>;
  27763. private _onBeforeRenderObserver;
  27764. /**
  27765. * A function that is added to the onBeforeRenderObservable
  27766. */
  27767. onBeforeRender: (effect: Effect) => void;
  27768. /**
  27769. * An event triggered after rendering the postprocess
  27770. */
  27771. onAfterRenderObservable: Observable<Effect>;
  27772. private _onAfterRenderObserver;
  27773. /**
  27774. * A function that is added to the onAfterRenderObservable
  27775. */
  27776. onAfterRender: (efect: Effect) => void;
  27777. /**
  27778. * 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
  27779. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27780. */
  27781. inputTexture: InternalTexture;
  27782. /**
  27783. * Gets the camera which post process is applied to.
  27784. * @returns The camera the post process is applied to.
  27785. */
  27786. getCamera(): Camera;
  27787. /**
  27788. * Gets the texel size of the postprocess.
  27789. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27790. */
  27791. readonly texelSize: Vector2;
  27792. /**
  27793. * Creates a new instance PostProcess
  27794. * @param name The name of the PostProcess.
  27795. * @param fragmentUrl The url of the fragment shader to be used.
  27796. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27797. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27798. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27799. * @param camera The camera to apply the render pass to.
  27800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27801. * @param engine The engine which the post process will be applied. (default: current engine)
  27802. * @param reusable If the post process can be reused on the same frame. (default: false)
  27803. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27804. * @param textureType Type of textures used when performing the post process. (default: 0)
  27805. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27806. * @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
  27807. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  27808. */
  27809. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  27810. /**
  27811. * Gets the engine which this post process belongs to.
  27812. * @returns The engine the post process was enabled with.
  27813. */
  27814. getEngine(): Engine;
  27815. /**
  27816. * The effect that is created when initializing the post process.
  27817. * @returns The created effect corrisponding the the postprocess.
  27818. */
  27819. getEffect(): Effect;
  27820. /**
  27821. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27822. * @param postProcess The post process to share the output with.
  27823. * @returns This post process.
  27824. */
  27825. shareOutputWith(postProcess: PostProcess): PostProcess;
  27826. /**
  27827. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27828. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27829. */
  27830. useOwnOutput(): void;
  27831. /**
  27832. * Updates the effect with the current post process compile time values and recompiles the shader.
  27833. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27834. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27835. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27836. * @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
  27837. * @param onCompiled Called when the shader has been compiled.
  27838. * @param onError Called if there is an error when compiling a shader.
  27839. */
  27840. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27841. /**
  27842. * The post process is reusable if it can be used multiple times within one frame.
  27843. * @returns If the post process is reusable
  27844. */
  27845. isReusable(): boolean;
  27846. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27847. markTextureDirty(): void;
  27848. /**
  27849. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27850. * 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.
  27851. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27852. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27853. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27854. * @returns The target texture that was bound to be written to.
  27855. */
  27856. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27857. /**
  27858. * If the post process is supported.
  27859. */
  27860. readonly isSupported: boolean;
  27861. /**
  27862. * The aspect ratio of the output texture.
  27863. */
  27864. readonly aspectRatio: number;
  27865. /**
  27866. * Get a value indicating if the post-process is ready to be used
  27867. * @returns true if the post-process is ready (shader is compiled)
  27868. */
  27869. isReady(): boolean;
  27870. /**
  27871. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27872. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  27873. */
  27874. apply(): Nullable<Effect>;
  27875. private _disposeTextures();
  27876. /**
  27877. * Disposes the post process.
  27878. * @param camera The camera to dispose the post process on.
  27879. */
  27880. dispose(camera?: Camera): void;
  27881. }
  27882. }
  27883. declare module BABYLON {
  27884. /**
  27885. * PostProcessManager is used to manage one or more post processes or post process pipelines
  27886. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27887. */
  27888. class PostProcessManager {
  27889. private _scene;
  27890. private _indexBuffer;
  27891. private _vertexBuffers;
  27892. /**
  27893. * Creates a new instance PostProcess
  27894. * @param scene The scene that the post process is associated with.
  27895. */
  27896. constructor(scene: Scene);
  27897. private _prepareBuffers();
  27898. private _buildIndexBuffer();
  27899. /**
  27900. * Rebuilds the vertex buffers of the manager.
  27901. */
  27902. _rebuild(): void;
  27903. /**
  27904. * Prepares a frame to be run through a post process.
  27905. * @param sourceTexture The input texture to the post procesess. (default: null)
  27906. * @param postProcesses An array of post processes to be run. (default: null)
  27907. * @returns True if the post processes were able to be run.
  27908. */
  27909. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  27910. /**
  27911. * Manually render a set of post processes to a texture.
  27912. * @param postProcesses An array of post processes to be run.
  27913. * @param targetTexture The target texture to render to.
  27914. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  27915. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  27916. * @param lodLevel defines which lod of the texture to render to
  27917. */
  27918. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  27919. /**
  27920. * Finalize the result of the output of the postprocesses.
  27921. * @param doNotPresent If true the result will not be displayed to the screen.
  27922. * @param targetTexture The target texture to render to.
  27923. * @param faceIndex The index of the face to bind the target texture to.
  27924. * @param postProcesses The array of post processes to render.
  27925. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  27926. */
  27927. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  27928. /**
  27929. * Disposes of the post process manager.
  27930. */
  27931. dispose(): void;
  27932. }
  27933. }
  27934. declare module BABYLON {
  27935. class RefractionPostProcess extends PostProcess {
  27936. color: Color3;
  27937. depth: number;
  27938. colorLevel: number;
  27939. private _refTexture;
  27940. private _ownRefractionTexture;
  27941. /**
  27942. * Gets or sets the refraction texture
  27943. * Please note that you are responsible for disposing the texture if you set it manually
  27944. */
  27945. refractionTexture: Texture;
  27946. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27947. dispose(camera: Camera): void;
  27948. }
  27949. }
  27950. declare module BABYLON {
  27951. /**
  27952. * The SharpenPostProcess applies a sharpen kernel to every pixel
  27953. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27954. */
  27955. class SharpenPostProcess extends PostProcess {
  27956. /**
  27957. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  27958. */
  27959. colorAmount: number;
  27960. /**
  27961. * How much sharpness should be applied (default: 0.3)
  27962. */
  27963. edgeAmount: number;
  27964. /**
  27965. * Creates a new instance ConvolutionPostProcess
  27966. * @param name The name of the effect.
  27967. * @param options The required width/height ratio to downsize to before computing the render pass.
  27968. * @param camera The camera to apply the render pass to.
  27969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27970. * @param engine The engine which the post process will be applied. (default: current engine)
  27971. * @param reusable If the post process can be reused on the same frame. (default: false)
  27972. * @param textureType Type of textures used when performing the post process. (default: 0)
  27973. * @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)
  27974. */
  27975. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27976. }
  27977. }
  27978. declare module BABYLON {
  27979. class StereoscopicInterlacePostProcess extends PostProcess {
  27980. private _stepSize;
  27981. private _passedProcess;
  27982. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27983. }
  27984. }
  27985. declare module BABYLON {
  27986. /** Defines operator used for tonemapping */
  27987. enum TonemappingOperator {
  27988. /** Hable */
  27989. Hable = 0,
  27990. /** Reinhard */
  27991. Reinhard = 1,
  27992. /** HejiDawson */
  27993. HejiDawson = 2,
  27994. /** Photographic */
  27995. Photographic = 3,
  27996. }
  27997. /**
  27998. * Defines a post process to apply tone mapping
  27999. */
  28000. class TonemapPostProcess extends PostProcess {
  28001. private _operator;
  28002. /** Defines the required exposure adjustement */
  28003. exposureAdjustment: number;
  28004. /**
  28005. * Creates a new TonemapPostProcess
  28006. * @param name defines the name of the postprocess
  28007. * @param _operator defines the operator to use
  28008. * @param exposureAdjustment defines the required exposure adjustement
  28009. * @param camera defines the camera to use (can be null)
  28010. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28011. * @param engine defines the hosting engine (can be ignore if camera is set)
  28012. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28013. */
  28014. constructor(name: string, _operator: TonemappingOperator,
  28015. /** Defines the required exposure adjustement */
  28016. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28017. }
  28018. }
  28019. declare module BABYLON {
  28020. class VolumetricLightScatteringPostProcess extends PostProcess {
  28021. private _volumetricLightScatteringPass;
  28022. private _volumetricLightScatteringRTT;
  28023. private _viewPort;
  28024. private _screenCoordinates;
  28025. private _cachedDefines;
  28026. /**
  28027. * If not undefined, the mesh position is computed from the attached node position
  28028. */
  28029. attachedNode: {
  28030. position: Vector3;
  28031. };
  28032. /**
  28033. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28034. */
  28035. customMeshPosition: Vector3;
  28036. /**
  28037. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28038. */
  28039. useCustomMeshPosition: boolean;
  28040. /**
  28041. * If the post-process should inverse the light scattering direction
  28042. */
  28043. invert: boolean;
  28044. /**
  28045. * The internal mesh used by the post-process
  28046. */
  28047. mesh: Mesh;
  28048. useDiffuseColor: boolean;
  28049. /**
  28050. * Array containing the excluded meshes not rendered in the internal pass
  28051. */
  28052. excludedMeshes: AbstractMesh[];
  28053. /**
  28054. * Controls the overall intensity of the post-process
  28055. */
  28056. exposure: number;
  28057. /**
  28058. * Dissipates each sample's contribution in range [0, 1]
  28059. */
  28060. decay: number;
  28061. /**
  28062. * Controls the overall intensity of each sample
  28063. */
  28064. weight: number;
  28065. /**
  28066. * Controls the density of each sample
  28067. */
  28068. density: number;
  28069. /**
  28070. * @constructor
  28071. * @param {string} name - The post-process name
  28072. * @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)
  28073. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28074. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28075. * @param {number} samples - The post-process quality, default 100
  28076. * @param {number} samplingMode - The post-process filtering mode
  28077. * @param {BABYLON.Engine} engine - The babylon engine
  28078. * @param {boolean} reusable - If the post-process is reusable
  28079. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  28080. */
  28081. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28082. getClassName(): string;
  28083. private _isReady(subMesh, useInstances);
  28084. /**
  28085. * Sets the new light position for light scattering effect
  28086. * @param {BABYLON.Vector3} The new custom light position
  28087. */
  28088. setCustomMeshPosition(position: Vector3): void;
  28089. /**
  28090. * Returns the light position for light scattering effect
  28091. * @return {BABYLON.Vector3} The custom light position
  28092. */
  28093. getCustomMeshPosition(): Vector3;
  28094. /**
  28095. * Disposes the internal assets and detaches the post-process from the camera
  28096. */
  28097. dispose(camera: Camera): void;
  28098. /**
  28099. * Returns the render target texture used by the post-process
  28100. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28101. */
  28102. getPass(): RenderTargetTexture;
  28103. private _meshExcluded(mesh);
  28104. private _createPass(scene, ratio);
  28105. private _updateMeshScreenCoordinates(scene);
  28106. /**
  28107. * Creates a default mesh for the Volumeric Light Scattering post-process
  28108. * @param {string} The mesh name
  28109. * @param {BABYLON.Scene} The scene where to create the mesh
  28110. * @return {BABYLON.Mesh} the default mesh
  28111. */
  28112. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28113. }
  28114. }
  28115. declare module BABYLON {
  28116. class VRDistortionCorrectionPostProcess extends PostProcess {
  28117. private _isRightEye;
  28118. private _distortionFactors;
  28119. private _postProcessScaleFactor;
  28120. private _lensCenterOffset;
  28121. private _scaleIn;
  28122. private _scaleFactor;
  28123. private _lensCenter;
  28124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28125. }
  28126. }
  28127. declare module BABYLON {
  28128. /**
  28129. * @hidden
  28130. **/
  28131. class _AlphaState {
  28132. private _isAlphaBlendDirty;
  28133. private _isBlendFunctionParametersDirty;
  28134. private _isBlendEquationParametersDirty;
  28135. private _isBlendConstantsDirty;
  28136. private _alphaBlend;
  28137. private _blendFunctionParameters;
  28138. private _blendEquationParameters;
  28139. private _blendConstants;
  28140. /**
  28141. * Initializes the state.
  28142. */
  28143. constructor();
  28144. readonly isDirty: boolean;
  28145. alphaBlend: boolean;
  28146. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28147. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28148. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28149. reset(): void;
  28150. apply(gl: WebGLRenderingContext): void;
  28151. }
  28152. }
  28153. declare module BABYLON {
  28154. /**
  28155. * @hidden
  28156. **/
  28157. class _DepthCullingState {
  28158. private _isDepthTestDirty;
  28159. private _isDepthMaskDirty;
  28160. private _isDepthFuncDirty;
  28161. private _isCullFaceDirty;
  28162. private _isCullDirty;
  28163. private _isZOffsetDirty;
  28164. private _isFrontFaceDirty;
  28165. private _depthTest;
  28166. private _depthMask;
  28167. private _depthFunc;
  28168. private _cull;
  28169. private _cullFace;
  28170. private _zOffset;
  28171. private _frontFace;
  28172. /**
  28173. * Initializes the state.
  28174. */
  28175. constructor();
  28176. readonly isDirty: boolean;
  28177. zOffset: number;
  28178. cullFace: Nullable<number>;
  28179. cull: Nullable<boolean>;
  28180. depthFunc: Nullable<number>;
  28181. depthMask: boolean;
  28182. depthTest: boolean;
  28183. frontFace: Nullable<number>;
  28184. reset(): void;
  28185. apply(gl: WebGLRenderingContext): void;
  28186. }
  28187. }
  28188. declare module BABYLON {
  28189. /**
  28190. * @hidden
  28191. **/
  28192. class _StencilState {
  28193. private _isStencilTestDirty;
  28194. private _isStencilMaskDirty;
  28195. private _isStencilFuncDirty;
  28196. private _isStencilOpDirty;
  28197. private _stencilTest;
  28198. private _stencilMask;
  28199. private _stencilFunc;
  28200. private _stencilFuncRef;
  28201. private _stencilFuncMask;
  28202. private _stencilOpStencilFail;
  28203. private _stencilOpDepthFail;
  28204. private _stencilOpStencilDepthPass;
  28205. readonly isDirty: boolean;
  28206. stencilFunc: number;
  28207. stencilFuncRef: number;
  28208. stencilFuncMask: number;
  28209. stencilOpStencilFail: number;
  28210. stencilOpDepthFail: number;
  28211. stencilOpStencilDepthPass: number;
  28212. stencilMask: number;
  28213. stencilTest: boolean;
  28214. constructor();
  28215. reset(): void;
  28216. apply(gl: WebGLRenderingContext): void;
  28217. }
  28218. }
  28219. declare module BABYLON {
  28220. class Sprite {
  28221. name: string;
  28222. position: Vector3;
  28223. color: Color4;
  28224. width: number;
  28225. height: number;
  28226. angle: number;
  28227. cellIndex: number;
  28228. invertU: number;
  28229. invertV: number;
  28230. disposeWhenFinishedAnimating: boolean;
  28231. animations: Animation[];
  28232. isPickable: boolean;
  28233. actionManager: ActionManager;
  28234. private _animationStarted;
  28235. private _loopAnimation;
  28236. private _fromIndex;
  28237. private _toIndex;
  28238. private _delay;
  28239. private _direction;
  28240. private _manager;
  28241. private _time;
  28242. private _onAnimationEnd;
  28243. /**
  28244. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28245. */
  28246. isVisible: boolean;
  28247. size: number;
  28248. constructor(name: string, manager: SpriteManager);
  28249. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28250. stopAnimation(): void;
  28251. _animate(deltaTime: number): void;
  28252. dispose(): void;
  28253. }
  28254. }
  28255. declare module BABYLON {
  28256. class SpriteManager {
  28257. name: string;
  28258. sprites: Sprite[];
  28259. renderingGroupId: number;
  28260. layerMask: number;
  28261. fogEnabled: boolean;
  28262. isPickable: boolean;
  28263. cellWidth: number;
  28264. cellHeight: number;
  28265. /**
  28266. * An event triggered when the manager is disposed.
  28267. */
  28268. onDisposeObservable: Observable<SpriteManager>;
  28269. private _onDisposeObserver;
  28270. onDispose: () => void;
  28271. private _capacity;
  28272. private _spriteTexture;
  28273. private _epsilon;
  28274. private _scene;
  28275. private _vertexData;
  28276. private _buffer;
  28277. private _vertexBuffers;
  28278. private _indexBuffer;
  28279. private _effectBase;
  28280. private _effectFog;
  28281. texture: Texture;
  28282. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  28283. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  28284. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28285. render(): void;
  28286. dispose(): void;
  28287. }
  28288. }
  28289. declare module BABYLON {
  28290. /**
  28291. * Class used to evalaute queries containing `and` and `or` operators
  28292. */
  28293. class AndOrNotEvaluator {
  28294. /**
  28295. * Evaluate a query
  28296. * @param query defines the query to evaluate
  28297. * @param evaluateCallback defines the callback used to filter result
  28298. * @returns true if the query matches
  28299. */
  28300. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  28301. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  28302. private static _SimplifyNegation(booleanString);
  28303. }
  28304. }
  28305. declare module BABYLON {
  28306. /**
  28307. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  28308. */
  28309. enum AssetTaskState {
  28310. /**
  28311. * Initialization
  28312. */
  28313. INIT = 0,
  28314. /**
  28315. * Running
  28316. */
  28317. RUNNING = 1,
  28318. /**
  28319. * Done
  28320. */
  28321. DONE = 2,
  28322. /**
  28323. * Error
  28324. */
  28325. ERROR = 3,
  28326. }
  28327. /**
  28328. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  28329. */
  28330. abstract class AbstractAssetTask {
  28331. /**
  28332. * Task name
  28333. */ name: string;
  28334. /**
  28335. * Callback called when the task is successful
  28336. */
  28337. onSuccess: (task: any) => void;
  28338. /**
  28339. * Callback called when the task is not successful
  28340. */
  28341. onError: (task: any, message?: string, exception?: any) => void;
  28342. /**
  28343. * Creates a new {BABYLON.AssetsManager}
  28344. * @param name defines the name of the task
  28345. */
  28346. constructor(
  28347. /**
  28348. * Task name
  28349. */ name: string);
  28350. private _isCompleted;
  28351. private _taskState;
  28352. private _errorObject;
  28353. /**
  28354. * Get if the task is completed
  28355. */
  28356. readonly isCompleted: boolean;
  28357. /**
  28358. * Gets the current state of the task
  28359. */
  28360. readonly taskState: AssetTaskState;
  28361. /**
  28362. * Gets the current error object (if task is in error)
  28363. */
  28364. readonly errorObject: {
  28365. message?: string;
  28366. exception?: any;
  28367. };
  28368. /**
  28369. * Internal only
  28370. * @hidden
  28371. */
  28372. _setErrorObject(message?: string, exception?: any): void;
  28373. /**
  28374. * Execute the current task
  28375. * @param scene defines the scene where you want your assets to be loaded
  28376. * @param onSuccess is a callback called when the task is successfully executed
  28377. * @param onError is a callback called if an error occurs
  28378. */
  28379. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28380. /**
  28381. * Execute the current task
  28382. * @param scene defines the scene where you want your assets to be loaded
  28383. * @param onSuccess is a callback called when the task is successfully executed
  28384. * @param onError is a callback called if an error occurs
  28385. */
  28386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28387. /**
  28388. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  28389. * This can be used with failed tasks that have the reason for failure fixed.
  28390. */
  28391. reset(): void;
  28392. private onErrorCallback(onError, message?, exception?);
  28393. private onDoneCallback(onSuccess, onError);
  28394. }
  28395. /**
  28396. * Define the interface used by progress events raised during assets loading
  28397. */
  28398. interface IAssetsProgressEvent {
  28399. /**
  28400. * Defines the number of remaining tasks to process
  28401. */
  28402. remainingCount: number;
  28403. /**
  28404. * Defines the total number of tasks
  28405. */
  28406. totalCount: number;
  28407. /**
  28408. * Defines the task that was just processed
  28409. */
  28410. task: AbstractAssetTask;
  28411. }
  28412. /**
  28413. * Class used to share progress information about assets loading
  28414. */
  28415. class AssetsProgressEvent implements IAssetsProgressEvent {
  28416. /**
  28417. * Defines the number of remaining tasks to process
  28418. */
  28419. remainingCount: number;
  28420. /**
  28421. * Defines the total number of tasks
  28422. */
  28423. totalCount: number;
  28424. /**
  28425. * Defines the task that was just processed
  28426. */
  28427. task: AbstractAssetTask;
  28428. /**
  28429. * Creates a {BABYLON.AssetsProgressEvent}
  28430. * @param remainingCount defines the number of remaining tasks to process
  28431. * @param totalCount defines the total number of tasks
  28432. * @param task defines the task that was just processed
  28433. */
  28434. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28435. }
  28436. /**
  28437. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28438. */
  28439. class MeshAssetTask extends AbstractAssetTask {
  28440. /**
  28441. * Defines the name of the task
  28442. */
  28443. name: string;
  28444. /**
  28445. * Defines the list of mesh's names you want to load
  28446. */
  28447. meshesNames: any;
  28448. /**
  28449. * Defines the root url to use as a base to load your meshes and associated resources
  28450. */
  28451. rootUrl: string;
  28452. /**
  28453. * Defines the filename of the scene to load from
  28454. */
  28455. sceneFilename: string;
  28456. /**
  28457. * Gets the list of loaded meshes
  28458. */
  28459. loadedMeshes: Array<AbstractMesh>;
  28460. /**
  28461. * Gets the list of loaded particle systems
  28462. */
  28463. loadedParticleSystems: Array<ParticleSystem>;
  28464. /**
  28465. * Gets the list of loaded skeletons
  28466. */
  28467. loadedSkeletons: Array<Skeleton>;
  28468. /**
  28469. * Callback called when the task is successful
  28470. */
  28471. onSuccess: (task: MeshAssetTask) => void;
  28472. /**
  28473. * Callback called when the task is successful
  28474. */
  28475. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28476. /**
  28477. * Creates a new {BABYLON.MeshAssetTask}
  28478. * @param name defines the name of the task
  28479. * @param meshesNames defines the list of mesh's names you want to load
  28480. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28481. * @param sceneFilename defines the filename of the scene to load from
  28482. */
  28483. constructor(
  28484. /**
  28485. * Defines the name of the task
  28486. */
  28487. name: string,
  28488. /**
  28489. * Defines the list of mesh's names you want to load
  28490. */
  28491. meshesNames: any,
  28492. /**
  28493. * Defines the root url to use as a base to load your meshes and associated resources
  28494. */
  28495. rootUrl: string,
  28496. /**
  28497. * Defines the filename of the scene to load from
  28498. */
  28499. sceneFilename: string);
  28500. /**
  28501. * Execute the current task
  28502. * @param scene defines the scene where you want your assets to be loaded
  28503. * @param onSuccess is a callback called when the task is successfully executed
  28504. * @param onError is a callback called if an error occurs
  28505. */
  28506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28507. }
  28508. /**
  28509. * Define a task used by {BABYLON.AssetsManager} to load text content
  28510. */
  28511. class TextFileAssetTask extends AbstractAssetTask {
  28512. /**
  28513. * Defines the name of the task
  28514. */
  28515. name: string;
  28516. /**
  28517. * Defines the location of the file to load
  28518. */
  28519. url: string;
  28520. /**
  28521. * Gets the loaded text string
  28522. */
  28523. text: string;
  28524. /**
  28525. * Callback called when the task is successful
  28526. */
  28527. onSuccess: (task: TextFileAssetTask) => void;
  28528. /**
  28529. * Callback called when the task is successful
  28530. */
  28531. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28532. /**
  28533. * Creates a new TextFileAssetTask object
  28534. * @param name defines the name of the task
  28535. * @param url defines the location of the file to load
  28536. */
  28537. constructor(
  28538. /**
  28539. * Defines the name of the task
  28540. */
  28541. name: string,
  28542. /**
  28543. * Defines the location of the file to load
  28544. */
  28545. url: string);
  28546. /**
  28547. * Execute the current task
  28548. * @param scene defines the scene where you want your assets to be loaded
  28549. * @param onSuccess is a callback called when the task is successfully executed
  28550. * @param onError is a callback called if an error occurs
  28551. */
  28552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28553. }
  28554. /**
  28555. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28556. */
  28557. class BinaryFileAssetTask extends AbstractAssetTask {
  28558. /**
  28559. * Defines the name of the task
  28560. */
  28561. name: string;
  28562. /**
  28563. * Defines the location of the file to load
  28564. */
  28565. url: string;
  28566. /**
  28567. * Gets the lodaded data (as an array buffer)
  28568. */
  28569. data: ArrayBuffer;
  28570. /**
  28571. * Callback called when the task is successful
  28572. */
  28573. onSuccess: (task: BinaryFileAssetTask) => void;
  28574. /**
  28575. * Callback called when the task is successful
  28576. */
  28577. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28578. /**
  28579. * Creates a new BinaryFileAssetTask object
  28580. * @param name defines the name of the new task
  28581. * @param url defines the location of the file to load
  28582. */
  28583. constructor(
  28584. /**
  28585. * Defines the name of the task
  28586. */
  28587. name: string,
  28588. /**
  28589. * Defines the location of the file to load
  28590. */
  28591. url: string);
  28592. /**
  28593. * Execute the current task
  28594. * @param scene defines the scene where you want your assets to be loaded
  28595. * @param onSuccess is a callback called when the task is successfully executed
  28596. * @param onError is a callback called if an error occurs
  28597. */
  28598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28599. }
  28600. /**
  28601. * Define a task used by {BABYLON.AssetsManager} to load images
  28602. */
  28603. class ImageAssetTask extends AbstractAssetTask {
  28604. /**
  28605. * Defines the name of the task
  28606. */
  28607. name: string;
  28608. /**
  28609. * Defines the location of the image to load
  28610. */
  28611. url: string;
  28612. /**
  28613. * Gets the loaded images
  28614. */
  28615. image: HTMLImageElement;
  28616. /**
  28617. * Callback called when the task is successful
  28618. */
  28619. onSuccess: (task: ImageAssetTask) => void;
  28620. /**
  28621. * Callback called when the task is successful
  28622. */
  28623. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28624. /**
  28625. * Creates a new ImageAssetTask
  28626. * @param name defines the name of the task
  28627. * @param url defines the location of the image to load
  28628. */
  28629. constructor(
  28630. /**
  28631. * Defines the name of the task
  28632. */
  28633. name: string,
  28634. /**
  28635. * Defines the location of the image to load
  28636. */
  28637. url: string);
  28638. /**
  28639. * Execute the current task
  28640. * @param scene defines the scene where you want your assets to be loaded
  28641. * @param onSuccess is a callback called when the task is successfully executed
  28642. * @param onError is a callback called if an error occurs
  28643. */
  28644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28645. }
  28646. /**
  28647. * Defines the interface used by texture loading tasks
  28648. */
  28649. interface ITextureAssetTask<TEX extends BaseTexture> {
  28650. /**
  28651. * Gets the loaded texture
  28652. */
  28653. texture: TEX;
  28654. }
  28655. /**
  28656. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  28657. */
  28658. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  28659. /**
  28660. * Defines the name of the task
  28661. */
  28662. name: string;
  28663. /**
  28664. * Defines the location of the file to load
  28665. */
  28666. url: string;
  28667. /**
  28668. * Defines if mipmap should not be generated (default is false)
  28669. */
  28670. noMipmap: boolean | undefined;
  28671. /**
  28672. * Defines if texture must be inverted on Y axis (default is false)
  28673. */
  28674. invertY: boolean | undefined;
  28675. /**
  28676. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28677. */
  28678. samplingMode: number;
  28679. /**
  28680. * Gets the loaded texture
  28681. */
  28682. texture: Texture;
  28683. /**
  28684. * Callback called when the task is successful
  28685. */
  28686. onSuccess: (task: TextureAssetTask) => void;
  28687. /**
  28688. * Callback called when the task is successful
  28689. */
  28690. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28691. /**
  28692. * Creates a new TextureAssetTask object
  28693. * @param name defines the name of the task
  28694. * @param url defines the location of the file to load
  28695. * @param noMipmap defines if mipmap should not be generated (default is false)
  28696. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28697. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28698. */
  28699. constructor(
  28700. /**
  28701. * Defines the name of the task
  28702. */
  28703. name: string,
  28704. /**
  28705. * Defines the location of the file to load
  28706. */
  28707. url: string,
  28708. /**
  28709. * Defines if mipmap should not be generated (default is false)
  28710. */
  28711. noMipmap?: boolean | undefined,
  28712. /**
  28713. * Defines if texture must be inverted on Y axis (default is false)
  28714. */
  28715. invertY?: boolean | undefined,
  28716. /**
  28717. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28718. */
  28719. samplingMode?: number);
  28720. /**
  28721. * Execute the current task
  28722. * @param scene defines the scene where you want your assets to be loaded
  28723. * @param onSuccess is a callback called when the task is successfully executed
  28724. * @param onError is a callback called if an error occurs
  28725. */
  28726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28727. }
  28728. /**
  28729. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28730. */
  28731. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28732. /**
  28733. * Defines the name of the task
  28734. */
  28735. name: string;
  28736. /**
  28737. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28738. */
  28739. url: string;
  28740. /**
  28741. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28742. */
  28743. extensions: string[] | undefined;
  28744. /**
  28745. * Defines if mipmaps should not be generated (default is false)
  28746. */
  28747. noMipmap: boolean | undefined;
  28748. /**
  28749. * Defines the explicit list of files (undefined by default)
  28750. */
  28751. files: string[] | undefined;
  28752. /**
  28753. * Gets the loaded texture
  28754. */
  28755. texture: CubeTexture;
  28756. /**
  28757. * Callback called when the task is successful
  28758. */
  28759. onSuccess: (task: CubeTextureAssetTask) => void;
  28760. /**
  28761. * Callback called when the task is successful
  28762. */
  28763. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28764. /**
  28765. * Creates a new CubeTextureAssetTask
  28766. * @param name defines the name of the task
  28767. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28768. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28769. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28770. * @param files defines the explicit list of files (undefined by default)
  28771. */
  28772. constructor(
  28773. /**
  28774. * Defines the name of the task
  28775. */
  28776. name: string,
  28777. /**
  28778. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28779. */
  28780. url: string,
  28781. /**
  28782. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28783. */
  28784. extensions?: string[] | undefined,
  28785. /**
  28786. * Defines if mipmaps should not be generated (default is false)
  28787. */
  28788. noMipmap?: boolean | undefined,
  28789. /**
  28790. * Defines the explicit list of files (undefined by default)
  28791. */
  28792. files?: string[] | undefined);
  28793. /**
  28794. * Execute the current task
  28795. * @param scene defines the scene where you want your assets to be loaded
  28796. * @param onSuccess is a callback called when the task is successfully executed
  28797. * @param onError is a callback called if an error occurs
  28798. */
  28799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28800. }
  28801. /**
  28802. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  28803. */
  28804. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  28805. /**
  28806. * Defines the name of the task
  28807. */
  28808. name: string;
  28809. /**
  28810. * Defines the location of the file to load
  28811. */
  28812. url: string;
  28813. /**
  28814. * Defines the desired size (the more it increases the longer the generation will be)
  28815. */
  28816. size: number;
  28817. /**
  28818. * Defines if mipmaps should not be generated (default is false)
  28819. */
  28820. noMipmap: boolean;
  28821. /**
  28822. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28823. */
  28824. generateHarmonics: boolean;
  28825. /**
  28826. * 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)
  28827. */
  28828. gammaSpace: boolean;
  28829. /**
  28830. * Internal Use Only
  28831. */
  28832. reserved: boolean;
  28833. /**
  28834. * Gets the loaded texture
  28835. */
  28836. texture: HDRCubeTexture;
  28837. /**
  28838. * Callback called when the task is successful
  28839. */
  28840. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  28841. /**
  28842. * Callback called when the task is successful
  28843. */
  28844. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  28845. /**
  28846. * Creates a new HDRCubeTextureAssetTask object
  28847. * @param name defines the name of the task
  28848. * @param url defines the location of the file to load
  28849. * @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.
  28850. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28851. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28852. * @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)
  28853. * @param reserved Internal use only
  28854. */
  28855. constructor(
  28856. /**
  28857. * Defines the name of the task
  28858. */
  28859. name: string,
  28860. /**
  28861. * Defines the location of the file to load
  28862. */
  28863. url: string,
  28864. /**
  28865. * Defines the desired size (the more it increases the longer the generation will be)
  28866. */
  28867. size: number,
  28868. /**
  28869. * Defines if mipmaps should not be generated (default is false)
  28870. */
  28871. noMipmap?: boolean,
  28872. /**
  28873. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  28874. */
  28875. generateHarmonics?: boolean,
  28876. /**
  28877. * 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)
  28878. */
  28879. gammaSpace?: boolean,
  28880. /**
  28881. * Internal Use Only
  28882. */
  28883. reserved?: boolean);
  28884. /**
  28885. * Execute the current task
  28886. * @param scene defines the scene where you want your assets to be loaded
  28887. * @param onSuccess is a callback called when the task is successfully executed
  28888. * @param onError is a callback called if an error occurs
  28889. */
  28890. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28891. }
  28892. /**
  28893. * This class can be used to easily import assets into a scene
  28894. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  28895. */
  28896. class AssetsManager {
  28897. private _scene;
  28898. private _isLoading;
  28899. protected _tasks: AbstractAssetTask[];
  28900. protected _waitingTasksCount: number;
  28901. protected _totalTasksCount: number;
  28902. /**
  28903. * Callback called when all tasks are processed
  28904. */
  28905. onFinish: (tasks: AbstractAssetTask[]) => void;
  28906. /**
  28907. * Callback called when a task is successful
  28908. */
  28909. onTaskSuccess: (task: AbstractAssetTask) => void;
  28910. /**
  28911. * Callback called when a task had an error
  28912. */
  28913. onTaskError: (task: AbstractAssetTask) => void;
  28914. /**
  28915. * Callback called when a task is done (whatever the result is)
  28916. */
  28917. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  28918. /**
  28919. * Observable called when all tasks are processed
  28920. */
  28921. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  28922. /**
  28923. * Observable called when a task had an error
  28924. */
  28925. onTaskErrorObservable: Observable<AbstractAssetTask>;
  28926. /**
  28927. * Observable called when a task is successful
  28928. */
  28929. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  28930. /**
  28931. * Observable called when a task is done (whatever the result is)
  28932. */
  28933. onProgressObservable: Observable<IAssetsProgressEvent>;
  28934. /**
  28935. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  28936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28937. */
  28938. useDefaultLoadingScreen: boolean;
  28939. /**
  28940. * Creates a new AssetsManager
  28941. * @param scene defines the scene to work on
  28942. */
  28943. constructor(scene: Scene);
  28944. /**
  28945. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  28946. * @param taskName defines the name of the new task
  28947. * @param meshesNames defines the name of meshes to load
  28948. * @param rootUrl defines the root url to use to locate files
  28949. * @param sceneFilename defines the filename of the scene file
  28950. * @returns a new {BABYLON.MeshAssetTask} object
  28951. */
  28952. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  28953. /**
  28954. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  28955. * @param taskName defines the name of the new task
  28956. * @param url defines the url of the file to load
  28957. * @returns a new {BABYLON.TextFileAssetTask} object
  28958. */
  28959. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  28960. /**
  28961. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  28962. * @param taskName defines the name of the new task
  28963. * @param url defines the url of the file to load
  28964. * @returns a new {BABYLON.BinaryFileAssetTask} object
  28965. */
  28966. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  28967. /**
  28968. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  28969. * @param taskName defines the name of the new task
  28970. * @param url defines the url of the file to load
  28971. * @returns a new {BABYLON.ImageAssetTask} object
  28972. */
  28973. addImageTask(taskName: string, url: string): ImageAssetTask;
  28974. /**
  28975. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  28976. * @param taskName defines the name of the new task
  28977. * @param url defines the url of the file to load
  28978. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28979. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  28980. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  28981. * @returns a new {BABYLON.TextureAssetTask} object
  28982. */
  28983. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  28984. /**
  28985. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  28986. * @param taskName defines the name of the new task
  28987. * @param url defines the url of the file to load
  28988. * @param extensions defines the extension to use to load the cube map (can be null)
  28989. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  28990. * @param files defines the list of files to load (can be null)
  28991. * @returns a new {BABYLON.CubeTextureAssetTask} object
  28992. */
  28993. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  28994. /**
  28995. *
  28996. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  28997. * @param taskName defines the name of the new task
  28998. * @param url defines the url of the file to load
  28999. * @param size defines the size you want for the cubemap (can be null)
  29000. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29001. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29002. * @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)
  29003. * @param reserved Internal use only
  29004. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29005. */
  29006. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29007. /**
  29008. * Remove a task from the assets manager.
  29009. * @param task the task to remove
  29010. */
  29011. removeTask(task: AbstractAssetTask): void;
  29012. private _decreaseWaitingTasksCount(task);
  29013. private _runTask(task);
  29014. /**
  29015. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29016. * @return the current instance of the {BABYLON.AssetsManager}
  29017. */
  29018. reset(): AssetsManager;
  29019. /**
  29020. * Start the loading process
  29021. * @return the current instance of the {BABYLON.AssetsManager}
  29022. */
  29023. load(): AssetsManager;
  29024. }
  29025. }
  29026. declare module BABYLON {
  29027. /**
  29028. * Class used to enable access to IndexedDB
  29029. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29030. */
  29031. class Database {
  29032. private callbackManifestChecked;
  29033. private currentSceneUrl;
  29034. private db;
  29035. private _enableSceneOffline;
  29036. private _enableTexturesOffline;
  29037. private manifestVersionFound;
  29038. private mustUpdateRessources;
  29039. private hasReachedQuota;
  29040. private isSupported;
  29041. private idbFactory;
  29042. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29043. static IsUASupportingBlobStorage: boolean;
  29044. /** Gets a boolean indicating if Database storate is enabled */
  29045. static IDBStorageEnabled: boolean;
  29046. /**
  29047. * Gets a boolean indicating if scene must be saved in the database
  29048. */
  29049. readonly enableSceneOffline: boolean;
  29050. /**
  29051. * Gets a boolean indicating if textures must be saved in the database
  29052. */
  29053. readonly enableTexturesOffline: boolean;
  29054. /**
  29055. * Creates a new Database
  29056. * @param urlToScene defines the url to load the scene
  29057. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29058. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29059. */
  29060. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29061. private static _ParseURL;
  29062. private static _ReturnFullUrlLocation;
  29063. private _checkManifestFile();
  29064. /**
  29065. * Open the database and make it available
  29066. * @param successCallback defines the callback to call on success
  29067. * @param errorCallback defines the callback to call on error
  29068. */
  29069. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29070. /**
  29071. * Loads an image from the database
  29072. * @param url defines the url to load from
  29073. * @param image defines the target DOM image
  29074. */
  29075. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29076. private _loadImageFromDBAsync(url, image, notInDBCallback);
  29077. private _saveImageIntoDBAsync(url, image);
  29078. private _checkVersionFromDB(url, versionLoaded);
  29079. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  29080. private _saveVersionIntoDBAsync(url, callback);
  29081. /**
  29082. * Loads a file from database
  29083. * @param url defines the URL to load from
  29084. * @param sceneLoaded defines a callback to call on success
  29085. * @param progressCallBack defines a callback to call when progress changed
  29086. * @param errorCallback defines a callback to call on error
  29087. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29088. */
  29089. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29090. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  29091. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  29092. }
  29093. }
  29094. declare module BABYLON {
  29095. interface DDSInfo {
  29096. width: number;
  29097. height: number;
  29098. mipmapCount: number;
  29099. isFourCC: boolean;
  29100. isRGB: boolean;
  29101. isLuminance: boolean;
  29102. isCube: boolean;
  29103. isCompressed: boolean;
  29104. dxgiFormat: number;
  29105. textureType: number;
  29106. /** Sphericle polynomial created for the dds texture */
  29107. sphericalPolynomial?: SphericalPolynomial;
  29108. }
  29109. class DDSTools {
  29110. static StoreLODInAlphaChannel: boolean;
  29111. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  29112. private static _FloatView;
  29113. private static _Int32View;
  29114. private static _ToHalfFloat(value);
  29115. private static _FromHalfFloat(value);
  29116. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29117. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29118. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29119. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29120. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29121. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  29122. private static _ExtractLongWordOrder(value);
  29123. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  29124. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  29125. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  29126. }
  29127. }
  29128. declare module BABYLON {
  29129. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29130. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29131. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29132. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29133. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29134. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29135. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29136. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29137. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29138. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29139. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29140. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29141. /**
  29142. * Decorator used to define property that can be serialized as reference to a camera
  29143. * @param sourceName defines the name of the property to decorate
  29144. */
  29145. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29146. class SerializationHelper {
  29147. static Serialize<T>(entity: T, serializationObject?: any): any;
  29148. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29149. static Clone<T>(creationFunction: () => T, source: T): T;
  29150. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29151. }
  29152. }
  29153. declare module BABYLON {
  29154. /**
  29155. * Wrapper class for promise with external resolve and reject.
  29156. */
  29157. class Deferred<T> {
  29158. /**
  29159. * The promise associated with this deferred object.
  29160. */
  29161. readonly promise: Promise<T>;
  29162. private _resolve;
  29163. private _reject;
  29164. /**
  29165. * The resolve method of the promise associated with this deferred object.
  29166. */
  29167. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  29168. /**
  29169. * The reject method of the promise associated with this deferred object.
  29170. */
  29171. readonly reject: (reason?: any) => void;
  29172. /**
  29173. * Constructor for this deferred object.
  29174. */
  29175. constructor();
  29176. }
  29177. }
  29178. declare module BABYLON {
  29179. /**
  29180. * Raw texture data and descriptor sufficient for WebGL texture upload
  29181. */
  29182. interface EnvironmentTextureInfo {
  29183. /**
  29184. * Version of the environment map
  29185. */
  29186. version: number;
  29187. /**
  29188. * Width of image
  29189. */
  29190. width: number;
  29191. /**
  29192. * Irradiance information stored in the file.
  29193. */
  29194. irradiance: any;
  29195. /**
  29196. * Specular information stored in the file.
  29197. */
  29198. specular: any;
  29199. }
  29200. /**
  29201. * Sets of helpers addressing the serialization and deserialization of environment texture
  29202. * stored in a BabylonJS env file.
  29203. * Those files are usually stored as .env files.
  29204. */
  29205. class EnvironmentTextureTools {
  29206. /**
  29207. * Magic number identifying the env file.
  29208. */
  29209. private static _MagicBytes;
  29210. /**
  29211. * Gets the environment info from an env file.
  29212. * @param data The array buffer containing the .env bytes.
  29213. * @returns the environment file info (the json header) if successfully parsed.
  29214. */
  29215. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  29216. /**
  29217. * Creates an environment texture from a loaded cube texture.
  29218. * @param texture defines the cube texture to convert in env file
  29219. * @return a promise containing the environment data if succesfull.
  29220. */
  29221. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  29222. /**
  29223. * Creates a JSON representation of the spherical data.
  29224. * @param texture defines the texture containing the polynomials
  29225. * @return the JSON representation of the spherical info
  29226. */
  29227. private static _CreateEnvTextureIrradiance(texture);
  29228. /**
  29229. * Uploads the texture info contained in the env file to the GPU.
  29230. * @param texture defines the internal texture to upload to
  29231. * @param arrayBuffer defines the buffer cotaining the data to load
  29232. * @param info defines the texture info retrieved through the GetEnvInfo method
  29233. * @returns a promise
  29234. */
  29235. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  29236. /**
  29237. * Uploads the levels of image data to the GPU.
  29238. * @param texture defines the internal texture to upload to
  29239. * @param imageData defines the array buffer views of image data [mipmap][face]
  29240. * @returns a promise
  29241. */
  29242. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  29243. /**
  29244. * Uploads spherical polynomials information to the texture.
  29245. * @param texture defines the texture we are trying to upload the information to
  29246. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  29247. */
  29248. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  29249. }
  29250. }
  29251. declare module BABYLON {
  29252. class FilesInput {
  29253. static FilesToLoad: {
  29254. [key: string]: File;
  29255. };
  29256. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  29257. private _engine;
  29258. private _currentScene;
  29259. private _sceneLoadedCallback;
  29260. private _progressCallback;
  29261. private _additionalRenderLoopLogicCallback;
  29262. private _textureLoadingCallback;
  29263. private _startingProcessingFilesCallback;
  29264. private _onReloadCallback;
  29265. private _errorCallback;
  29266. private _elementToMonitor;
  29267. private _sceneFileToLoad;
  29268. private _filesToLoad;
  29269. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  29270. private _dragEnterHandler;
  29271. private _dragOverHandler;
  29272. private _dropHandler;
  29273. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  29274. dispose(): void;
  29275. private renderFunction();
  29276. private drag(e);
  29277. private drop(eventDrop);
  29278. private _traverseFolder(folder, files, remaining, callback);
  29279. private _processFiles(files);
  29280. loadFiles(event: any): void;
  29281. private _processReload();
  29282. reload(): void;
  29283. }
  29284. }
  29285. declare module BABYLON {
  29286. /**
  29287. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29288. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29289. */
  29290. class KhronosTextureContainer {
  29291. arrayBuffer: any;
  29292. static HEADER_LEN: number;
  29293. static COMPRESSED_2D: number;
  29294. static COMPRESSED_3D: number;
  29295. static TEX_2D: number;
  29296. static TEX_3D: number;
  29297. glType: number;
  29298. glTypeSize: number;
  29299. glFormat: number;
  29300. glInternalFormat: number;
  29301. glBaseInternalFormat: number;
  29302. pixelWidth: number;
  29303. pixelHeight: number;
  29304. pixelDepth: number;
  29305. numberOfArrayElements: number;
  29306. numberOfFaces: number;
  29307. numberOfMipmapLevels: number;
  29308. bytesOfKeyValueData: number;
  29309. loadType: number;
  29310. /**
  29311. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  29312. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  29313. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  29314. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  29315. */
  29316. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  29317. switchEndainness(val: number): number;
  29318. /**
  29319. * It is assumed that the texture has already been created & is currently bound
  29320. */
  29321. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  29322. private _upload2DCompressedLevels(gl, loadMipmaps);
  29323. }
  29324. }
  29325. declare module BABYLON {
  29326. /**
  29327. * A class serves as a medium between the observable and its observers
  29328. */
  29329. class EventState {
  29330. /**
  29331. * Create a new EventState
  29332. * @param mask defines the mask associated with this state
  29333. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29334. * @param target defines the original target of the state
  29335. * @param currentTarget defines the current target of the state
  29336. */
  29337. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  29338. /**
  29339. * Initialize the current event state
  29340. * @param mask defines the mask associated with this state
  29341. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29342. * @param target defines the original target of the state
  29343. * @param currentTarget defines the current target of the state
  29344. * @returns the current event state
  29345. */
  29346. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  29347. /**
  29348. * An Observer can set this property to true to prevent subsequent observers of being notified
  29349. */
  29350. skipNextObservers: boolean;
  29351. /**
  29352. * Get the mask value that were used to trigger the event corresponding to this EventState object
  29353. */
  29354. mask: number;
  29355. /**
  29356. * The object that originally notified the event
  29357. */
  29358. target?: any;
  29359. /**
  29360. * The current object in the bubbling phase
  29361. */
  29362. currentTarget?: any;
  29363. /**
  29364. * This will be populated with the return value of the last function that was executed.
  29365. * If it is the first function in the callback chain it will be the event data.
  29366. */
  29367. lastReturnValue?: any;
  29368. }
  29369. /**
  29370. * Represent an Observer registered to a given Observable object.
  29371. */
  29372. class Observer<T> {
  29373. /**
  29374. * Defines the callback to call when the observer is notified
  29375. */
  29376. callback: (eventData: T, eventState: EventState) => void;
  29377. /**
  29378. * Defines the mask of the observer (used to filter notifications)
  29379. */
  29380. mask: number;
  29381. /**
  29382. * Defines the current scope used to restore the JS context
  29383. */
  29384. scope: any;
  29385. /** @hidden */
  29386. _willBeUnregistered: boolean;
  29387. /**
  29388. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  29389. */
  29390. unregisterOnNextCall: boolean;
  29391. /**
  29392. * Creates a new observer
  29393. * @param callback defines the callback to call when the observer is notified
  29394. * @param mask defines the mask of the observer (used to filter notifications)
  29395. * @param scope defines the current scope used to restore the JS context
  29396. */
  29397. constructor(
  29398. /**
  29399. * Defines the callback to call when the observer is notified
  29400. */
  29401. callback: (eventData: T, eventState: EventState) => void,
  29402. /**
  29403. * Defines the mask of the observer (used to filter notifications)
  29404. */
  29405. mask: number,
  29406. /**
  29407. * Defines the current scope used to restore the JS context
  29408. */
  29409. scope?: any);
  29410. }
  29411. /**
  29412. * Represent a list of observers registered to multiple Observables object.
  29413. */
  29414. class MultiObserver<T> {
  29415. private _observers;
  29416. private _observables;
  29417. /**
  29418. * Release associated resources
  29419. */
  29420. dispose(): void;
  29421. /**
  29422. * Raise a callback when one of the observable will notify
  29423. * @param observables defines a list of observables to watch
  29424. * @param callback defines the callback to call on notification
  29425. * @param mask defines the mask used to filter notifications
  29426. * @param scope defines the current scope used to restore the JS context
  29427. * @returns the new MultiObserver
  29428. */
  29429. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29430. }
  29431. /**
  29432. * The Observable class is a simple implementation of the Observable pattern.
  29433. *
  29434. * 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.
  29435. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29436. * 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).
  29437. * 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.
  29438. */
  29439. class Observable<T> {
  29440. private _observers;
  29441. private _eventState;
  29442. private _onObserverAdded;
  29443. /**
  29444. * Creates a new observable
  29445. * @param onObserverAdded defines a callback to call when a new observer is added
  29446. */
  29447. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29448. /**
  29449. * Create a new Observer with the specified callback
  29450. * @param callback the callback that will be executed for that Observer
  29451. * @param mask the mask used to filter observers
  29452. * @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.
  29453. * @param scope optional scope for the callback to be called from
  29454. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29455. * @returns the new observer created for the callback
  29456. */
  29457. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29458. /**
  29459. * Create a new Observer with the specified callback and unregisters after the next notification
  29460. * @param callback the callback that will be executed for that Observer
  29461. * @returns the new observer created for the callback
  29462. */
  29463. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29464. /**
  29465. * Remove an Observer from the Observable object
  29466. * @param observer the instance of the Observer to remove
  29467. * @returns false if it doesn't belong to this Observable
  29468. */
  29469. remove(observer: Nullable<Observer<T>>): boolean;
  29470. /**
  29471. * Remove a callback from the Observable object
  29472. * @param callback the callback to remove
  29473. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29474. * @returns false if it doesn't belong to this Observable
  29475. */
  29476. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29477. private _deferUnregister(observer);
  29478. private _remove(observer);
  29479. /**
  29480. * Notify all Observers by calling their respective callback with the given data
  29481. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29482. * @param eventData defines the data to send to all observers
  29483. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29484. * @param target defines the original target of the state
  29485. * @param currentTarget defines the current target of the state
  29486. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29487. */
  29488. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29489. /**
  29490. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29491. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29492. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29493. * and it is crucial that all callbacks will be executed.
  29494. * The order of the callbacks is kept, callbacks are not executed parallel.
  29495. *
  29496. * @param eventData The data to be sent to each callback
  29497. * @param mask is used to filter observers defaults to -1
  29498. * @param target defines the callback target (see EventState)
  29499. * @param currentTarget defines he current object in the bubbling phase
  29500. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29501. */
  29502. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29503. /**
  29504. * Notify a specific observer
  29505. * @param observer defines the observer to notify
  29506. * @param eventData defines the data to be sent to each callback
  29507. * @param mask is used to filter observers defaults to -1
  29508. */
  29509. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29510. /**
  29511. * Gets a boolean indicating if the observable has at least one observer
  29512. * @returns true is the Observable has at least one Observer registered
  29513. */
  29514. hasObservers(): boolean;
  29515. /**
  29516. * Clear the list of observers
  29517. */
  29518. clear(): void;
  29519. /**
  29520. * Clone the current observable
  29521. * @returns a new observable
  29522. */
  29523. clone(): Observable<T>;
  29524. /**
  29525. * Does this observable handles observer registered with a given mask
  29526. * @param mask defines the mask to be tested
  29527. * @return whether or not one observer registered with the given mask is handeled
  29528. **/
  29529. hasSpecificMask(mask?: number): boolean;
  29530. }
  29531. }
  29532. declare module BABYLON {
  29533. /**
  29534. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29535. */
  29536. class PerformanceMonitor {
  29537. private _enabled;
  29538. private _rollingFrameTime;
  29539. private _lastFrameTimeMs;
  29540. /**
  29541. * constructor
  29542. * @param frameSampleSize The number of samples required to saturate the sliding window
  29543. */
  29544. constructor(frameSampleSize?: number);
  29545. /**
  29546. * Samples current frame
  29547. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29548. */
  29549. sampleFrame(timeMs?: number): void;
  29550. /**
  29551. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29552. * @return Average frame time in milliseconds
  29553. */
  29554. readonly averageFrameTime: number;
  29555. /**
  29556. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29557. * @return Frame time variance in milliseconds squared
  29558. */
  29559. readonly averageFrameTimeVariance: number;
  29560. /**
  29561. * Returns the frame time of the most recent frame
  29562. * @return Frame time in milliseconds
  29563. */
  29564. readonly instantaneousFrameTime: number;
  29565. /**
  29566. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29567. * @return Framerate in frames per second
  29568. */
  29569. readonly averageFPS: number;
  29570. /**
  29571. * Returns the average framerate in frames per second using the most recent frame time
  29572. * @return Framerate in frames per second
  29573. */
  29574. readonly instantaneousFPS: number;
  29575. /**
  29576. * Returns true if enough samples have been taken to completely fill the sliding window
  29577. * @return true if saturated
  29578. */
  29579. readonly isSaturated: boolean;
  29580. /**
  29581. * Enables contributions to the sliding window sample set
  29582. */
  29583. enable(): void;
  29584. /**
  29585. * Disables contributions to the sliding window sample set
  29586. * Samples will not be interpolated over the disabled period
  29587. */
  29588. disable(): void;
  29589. /**
  29590. * Returns true if sampling is enabled
  29591. * @return true if enabled
  29592. */
  29593. readonly isEnabled: boolean;
  29594. /**
  29595. * Resets performance monitor
  29596. */
  29597. reset(): void;
  29598. }
  29599. /**
  29600. * RollingAverage
  29601. *
  29602. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29603. */
  29604. class RollingAverage {
  29605. /**
  29606. * Current average
  29607. */
  29608. average: number;
  29609. /**
  29610. * Current variance
  29611. */
  29612. variance: number;
  29613. protected _samples: Array<number>;
  29614. protected _sampleCount: number;
  29615. protected _pos: number;
  29616. protected _m2: number;
  29617. /**
  29618. * constructor
  29619. * @param length The number of samples required to saturate the sliding window
  29620. */
  29621. constructor(length: number);
  29622. /**
  29623. * Adds a sample to the sample set
  29624. * @param v The sample value
  29625. */
  29626. add(v: number): void;
  29627. /**
  29628. * Returns previously added values or null if outside of history or outside the sliding window domain
  29629. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29630. * @return Value previously recorded with add() or null if outside of range
  29631. */
  29632. history(i: number): number;
  29633. /**
  29634. * Returns true if enough samples have been taken to completely fill the sliding window
  29635. * @return true if sample-set saturated
  29636. */
  29637. isSaturated(): boolean;
  29638. /**
  29639. * Resets the rolling average (equivalent to 0 samples taken so far)
  29640. */
  29641. reset(): void;
  29642. /**
  29643. * Wraps a value around the sample range boundaries
  29644. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29645. * @return Wrapped position in sample range
  29646. */
  29647. protected _wrapPosition(i: number): number;
  29648. }
  29649. }
  29650. declare module BABYLON {
  29651. /**
  29652. * Helper class that provides a small promise polyfill
  29653. */
  29654. class PromisePolyfill {
  29655. /**
  29656. * Static function used to check if the polyfill is required
  29657. * If this is the case then the function will inject the polyfill to window.Promise
  29658. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  29659. */
  29660. static Apply(force?: boolean): void;
  29661. }
  29662. }
  29663. declare module BABYLON {
  29664. /**
  29665. * Defines the root class used to create scene optimization to use with SceneOptimizer
  29666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29667. */
  29668. class SceneOptimization {
  29669. /**
  29670. * Defines the priority of this optimization (0 by default which means first in the list)
  29671. */
  29672. priority: number;
  29673. /**
  29674. * Gets a string describing the action executed by the current optimization
  29675. * @returns description string
  29676. */
  29677. getDescription(): string;
  29678. /**
  29679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29680. * @param scene defines the current scene where to apply this optimization
  29681. * @param optimizer defines the current optimizer
  29682. * @returns true if everything that can be done was applied
  29683. */
  29684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29685. /**
  29686. * Creates the SceneOptimization object
  29687. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29688. * @param desc defines the description associated with the optimization
  29689. */
  29690. constructor(
  29691. /**
  29692. * Defines the priority of this optimization (0 by default which means first in the list)
  29693. */
  29694. priority?: number);
  29695. }
  29696. /**
  29697. * Defines an optimization used to reduce the size of render target textures
  29698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29699. */
  29700. class TextureOptimization extends SceneOptimization {
  29701. /**
  29702. * Defines the priority of this optimization (0 by default which means first in the list)
  29703. */
  29704. priority: number;
  29705. /**
  29706. * 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
  29707. */
  29708. maximumSize: number;
  29709. /**
  29710. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29711. */
  29712. step: number;
  29713. /**
  29714. * Gets a string describing the action executed by the current optimization
  29715. * @returns description string
  29716. */
  29717. getDescription(): string;
  29718. /**
  29719. * Creates the TextureOptimization object
  29720. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29721. * @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
  29722. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29723. */
  29724. constructor(
  29725. /**
  29726. * Defines the priority of this optimization (0 by default which means first in the list)
  29727. */
  29728. priority?: number,
  29729. /**
  29730. * 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
  29731. */
  29732. maximumSize?: number,
  29733. /**
  29734. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29735. */
  29736. step?: number);
  29737. /**
  29738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29739. * @param scene defines the current scene where to apply this optimization
  29740. * @param optimizer defines the current optimizer
  29741. * @returns true if everything that can be done was applied
  29742. */
  29743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29744. }
  29745. /**
  29746. * Defines an optimization used to increase or decrease the rendering resolution
  29747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29748. */
  29749. class HardwareScalingOptimization extends SceneOptimization {
  29750. /**
  29751. * Defines the priority of this optimization (0 by default which means first in the list)
  29752. */
  29753. priority: number;
  29754. /**
  29755. * Defines the maximum scale to use (2 by default)
  29756. */
  29757. maximumScale: number;
  29758. /**
  29759. * Defines the step to use between two passes (0.5 by default)
  29760. */
  29761. step: number;
  29762. private _currentScale;
  29763. private _directionOffset;
  29764. /**
  29765. * Gets a string describing the action executed by the current optimization
  29766. * @return description string
  29767. */
  29768. getDescription(): string;
  29769. /**
  29770. * Creates the HardwareScalingOptimization object
  29771. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29772. * @param maximumScale defines the maximum scale to use (2 by default)
  29773. * @param step defines the step to use between two passes (0.5 by default)
  29774. */
  29775. constructor(
  29776. /**
  29777. * Defines the priority of this optimization (0 by default which means first in the list)
  29778. */
  29779. priority?: number,
  29780. /**
  29781. * Defines the maximum scale to use (2 by default)
  29782. */
  29783. maximumScale?: number,
  29784. /**
  29785. * Defines the step to use between two passes (0.5 by default)
  29786. */
  29787. step?: number);
  29788. /**
  29789. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29790. * @param scene defines the current scene where to apply this optimization
  29791. * @param optimizer defines the current optimizer
  29792. * @returns true if everything that can be done was applied
  29793. */
  29794. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29795. }
  29796. /**
  29797. * Defines an optimization used to remove shadows
  29798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29799. */
  29800. class ShadowsOptimization extends SceneOptimization {
  29801. /**
  29802. * Gets a string describing the action executed by the current optimization
  29803. * @return description string
  29804. */
  29805. getDescription(): string;
  29806. /**
  29807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29808. * @param scene defines the current scene where to apply this optimization
  29809. * @param optimizer defines the current optimizer
  29810. * @returns true if everything that can be done was applied
  29811. */
  29812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29813. }
  29814. /**
  29815. * Defines an optimization used to turn post-processes off
  29816. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29817. */
  29818. class PostProcessesOptimization extends SceneOptimization {
  29819. /**
  29820. * Gets a string describing the action executed by the current optimization
  29821. * @return description string
  29822. */
  29823. getDescription(): string;
  29824. /**
  29825. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29826. * @param scene defines the current scene where to apply this optimization
  29827. * @param optimizer defines the current optimizer
  29828. * @returns true if everything that can be done was applied
  29829. */
  29830. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29831. }
  29832. /**
  29833. * Defines an optimization used to turn lens flares off
  29834. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29835. */
  29836. class LensFlaresOptimization extends SceneOptimization {
  29837. /**
  29838. * Gets a string describing the action executed by the current optimization
  29839. * @return description string
  29840. */
  29841. getDescription(): string;
  29842. /**
  29843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29844. * @param scene defines the current scene where to apply this optimization
  29845. * @param optimizer defines the current optimizer
  29846. * @returns true if everything that can be done was applied
  29847. */
  29848. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29849. }
  29850. /**
  29851. * Defines an optimization based on user defined callback.
  29852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29853. */
  29854. class CustomOptimization extends SceneOptimization {
  29855. /**
  29856. * Callback called to apply the custom optimization.
  29857. */
  29858. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  29859. /**
  29860. * Callback called to get custom description
  29861. */
  29862. onGetDescription: () => string;
  29863. /**
  29864. * Gets a string describing the action executed by the current optimization
  29865. * @returns description string
  29866. */
  29867. getDescription(): string;
  29868. /**
  29869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29870. * @param scene defines the current scene where to apply this optimization
  29871. * @param optimizer defines the current optimizer
  29872. * @returns true if everything that can be done was applied
  29873. */
  29874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29875. }
  29876. /**
  29877. * Defines an optimization used to turn particles off
  29878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29879. */
  29880. class ParticlesOptimization extends SceneOptimization {
  29881. /**
  29882. * Gets a string describing the action executed by the current optimization
  29883. * @return description string
  29884. */
  29885. getDescription(): string;
  29886. /**
  29887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29888. * @param scene defines the current scene where to apply this optimization
  29889. * @param optimizer defines the current optimizer
  29890. * @returns true if everything that can be done was applied
  29891. */
  29892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29893. }
  29894. /**
  29895. * Defines an optimization used to turn render targets off
  29896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29897. */
  29898. class RenderTargetsOptimization extends SceneOptimization {
  29899. /**
  29900. * Gets a string describing the action executed by the current optimization
  29901. * @return description string
  29902. */
  29903. getDescription(): string;
  29904. /**
  29905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29906. * @param scene defines the current scene where to apply this optimization
  29907. * @param optimizer defines the current optimizer
  29908. * @returns true if everything that can be done was applied
  29909. */
  29910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29911. }
  29912. /**
  29913. * Defines an optimization used to merge meshes with compatible materials
  29914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29915. */
  29916. class MergeMeshesOptimization extends SceneOptimization {
  29917. private static _UpdateSelectionTree;
  29918. /**
  29919. * Gets or sets a boolean which defines if optimization octree has to be updated
  29920. */
  29921. /**
  29922. * Gets or sets a boolean which defines if optimization octree has to be updated
  29923. */
  29924. static UpdateSelectionTree: boolean;
  29925. /**
  29926. * Gets a string describing the action executed by the current optimization
  29927. * @return description string
  29928. */
  29929. getDescription(): string;
  29930. private _canBeMerged;
  29931. /**
  29932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29933. * @param scene defines the current scene where to apply this optimization
  29934. * @param optimizer defines the current optimizer
  29935. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  29936. * @returns true if everything that can be done was applied
  29937. */
  29938. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  29939. }
  29940. /**
  29941. * Defines a list of options used by SceneOptimizer
  29942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29943. */
  29944. class SceneOptimizerOptions {
  29945. /**
  29946. * Defines the target frame rate to reach (60 by default)
  29947. */
  29948. targetFrameRate: number;
  29949. /**
  29950. * Defines the interval between two checkes (2000ms by default)
  29951. */
  29952. trackerDuration: number;
  29953. /**
  29954. * Gets the list of optimizations to apply
  29955. */
  29956. optimizations: SceneOptimization[];
  29957. /**
  29958. * Creates a new list of options used by SceneOptimizer
  29959. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  29960. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  29961. */
  29962. constructor(
  29963. /**
  29964. * Defines the target frame rate to reach (60 by default)
  29965. */
  29966. targetFrameRate?: number,
  29967. /**
  29968. * Defines the interval between two checkes (2000ms by default)
  29969. */
  29970. trackerDuration?: number);
  29971. /**
  29972. * Add a new optimization
  29973. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  29974. * @returns the current SceneOptimizerOptions
  29975. */
  29976. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  29977. /**
  29978. * Add a new custom optimization
  29979. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  29980. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  29981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29982. * @returns the current SceneOptimizerOptions
  29983. */
  29984. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  29985. /**
  29986. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  29987. * @param targetFrameRate defines the target frame rate (60 by default)
  29988. * @returns a SceneOptimizerOptions object
  29989. */
  29990. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29991. /**
  29992. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  29993. * @param targetFrameRate defines the target frame rate (60 by default)
  29994. * @returns a SceneOptimizerOptions object
  29995. */
  29996. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  29997. /**
  29998. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  29999. * @param targetFrameRate defines the target frame rate (60 by default)
  30000. * @returns a SceneOptimizerOptions object
  30001. */
  30002. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30003. }
  30004. /**
  30005. * Class used to run optimizations in order to reach a target frame rate
  30006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30007. */
  30008. class SceneOptimizer implements IDisposable {
  30009. private _isRunning;
  30010. private _options;
  30011. private _scene;
  30012. private _currentPriorityLevel;
  30013. private _targetFrameRate;
  30014. private _trackerDuration;
  30015. private _currentFrameRate;
  30016. private _sceneDisposeObserver;
  30017. private _improvementMode;
  30018. /**
  30019. * Defines an observable called when the optimizer reaches the target frame rate
  30020. */
  30021. onSuccessObservable: Observable<SceneOptimizer>;
  30022. /**
  30023. * Defines an observable called when the optimizer enables an optimization
  30024. */
  30025. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30026. /**
  30027. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30028. */
  30029. onFailureObservable: Observable<SceneOptimizer>;
  30030. /**
  30031. * Gets a boolean indicating if the optimizer is in improvement mode
  30032. */
  30033. readonly isInImprovementMode: boolean;
  30034. /**
  30035. * Gets the current priority level (0 at start)
  30036. */
  30037. readonly currentPriorityLevel: number;
  30038. /**
  30039. * Gets the current frame rate checked by the SceneOptimizer
  30040. */
  30041. readonly currentFrameRate: number;
  30042. /**
  30043. * Gets or sets the current target frame rate (60 by default)
  30044. */
  30045. /**
  30046. * Gets or sets the current target frame rate (60 by default)
  30047. */
  30048. targetFrameRate: number;
  30049. /**
  30050. * Gets or sets the current interval between two checks (every 2000ms by default)
  30051. */
  30052. /**
  30053. * Gets or sets the current interval between two checks (every 2000ms by default)
  30054. */
  30055. trackerDuration: number;
  30056. /**
  30057. * Gets the list of active optimizations
  30058. */
  30059. readonly optimizations: SceneOptimization[];
  30060. /**
  30061. * Creates a new SceneOptimizer
  30062. * @param scene defines the scene to work on
  30063. * @param options defines the options to use with the SceneOptimizer
  30064. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30065. * @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)
  30066. */
  30067. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30068. /**
  30069. * Stops the current optimizer
  30070. */
  30071. stop(): void;
  30072. /**
  30073. * Reset the optimizer to initial step (current priority level = 0)
  30074. */
  30075. reset(): void;
  30076. /**
  30077. * Start the optimizer. By default it will try to reach a specific framerate
  30078. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  30079. */
  30080. start(): void;
  30081. private _checkCurrentState();
  30082. /**
  30083. * Release all resources
  30084. */
  30085. dispose(): void;
  30086. /**
  30087. * Helper function to create a SceneOptimizer with one single line of code
  30088. * @param scene defines the scene to work on
  30089. * @param options defines the options to use with the SceneOptimizer
  30090. * @param onSuccess defines a callback to call on success
  30091. * @param onFailure defines a callback to call on failure
  30092. * @returns the new SceneOptimizer object
  30093. */
  30094. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  30095. }
  30096. }
  30097. declare module BABYLON {
  30098. class SceneSerializer {
  30099. static ClearCache(): void;
  30100. static Serialize(scene: Scene): any;
  30101. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. class SmartArray<T> {
  30106. data: Array<T>;
  30107. length: number;
  30108. protected _id: number;
  30109. [index: number]: T;
  30110. constructor(capacity: number);
  30111. push(value: T): void;
  30112. forEach(func: (content: T) => void): void;
  30113. sort(compareFn: (a: T, b: T) => number): void;
  30114. reset(): void;
  30115. dispose(): void;
  30116. concat(array: any): void;
  30117. indexOf(value: T): number;
  30118. contains(value: T): boolean;
  30119. private static _GlobalId;
  30120. }
  30121. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  30122. private _duplicateId;
  30123. [index: number]: T;
  30124. push(value: T): void;
  30125. pushNoDuplicate(value: T): boolean;
  30126. reset(): void;
  30127. concatWithNoDuplicate(array: any): void;
  30128. }
  30129. }
  30130. declare module BABYLON {
  30131. /**
  30132. * This class implement a typical dictionary using a string as key and the generic type T as value.
  30133. * The underlying implementation relies on an associative array to ensure the best performances.
  30134. * The value can be anything including 'null' but except 'undefined'
  30135. */
  30136. class StringDictionary<T> {
  30137. /**
  30138. * This will clear this dictionary and copy the content from the 'source' one.
  30139. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  30140. * @param source the dictionary to take the content from and copy to this dictionary
  30141. */
  30142. copyFrom(source: StringDictionary<T>): void;
  30143. /**
  30144. * Get a value based from its key
  30145. * @param key the given key to get the matching value from
  30146. * @return the value if found, otherwise undefined is returned
  30147. */
  30148. get(key: string): T | undefined;
  30149. /**
  30150. * Get a value from its key or add it if it doesn't exist.
  30151. * This method will ensure you that a given key/data will be present in the dictionary.
  30152. * @param key the given key to get the matching value from
  30153. * @param factory the factory that will create the value if the key is not present in the dictionary.
  30154. * The factory will only be invoked if there's no data for the given key.
  30155. * @return the value corresponding to the key.
  30156. */
  30157. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  30158. /**
  30159. * Get a value from its key if present in the dictionary otherwise add it
  30160. * @param key the key to get the value from
  30161. * @param val if there's no such key/value pair in the dictionary add it with this value
  30162. * @return the value corresponding to the key
  30163. */
  30164. getOrAdd(key: string, val: T): T;
  30165. /**
  30166. * Check if there's a given key in the dictionary
  30167. * @param key the key to check for
  30168. * @return true if the key is present, false otherwise
  30169. */
  30170. contains(key: string): boolean;
  30171. /**
  30172. * Add a new key and its corresponding value
  30173. * @param key the key to add
  30174. * @param value the value corresponding to the key
  30175. * @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
  30176. */
  30177. add(key: string, value: T): boolean;
  30178. set(key: string, value: T): boolean;
  30179. /**
  30180. * Get the element of the given key and remove it from the dictionary
  30181. * @param key
  30182. */
  30183. getAndRemove(key: string): Nullable<T>;
  30184. /**
  30185. * Remove a key/value from the dictionary.
  30186. * @param key the key to remove
  30187. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  30188. */
  30189. remove(key: string): boolean;
  30190. /**
  30191. * Clear the whole content of the dictionary
  30192. */
  30193. clear(): void;
  30194. readonly count: number;
  30195. /**
  30196. * Execute a callback on each key/val of the dictionary.
  30197. * Note that you can remove any element in this dictionary in the callback implementation
  30198. * @param callback the callback to execute on a given key/value pair
  30199. */
  30200. forEach(callback: (key: string, val: T) => void): void;
  30201. /**
  30202. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  30203. * If the callback returns null or undefined the method will iterate to the next key/value pair
  30204. * Note that you can remove any element in this dictionary in the callback implementation
  30205. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  30206. */
  30207. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  30208. private _count;
  30209. private _data;
  30210. }
  30211. }
  30212. declare module BABYLON {
  30213. class Tags {
  30214. static EnableFor(obj: any): void;
  30215. static DisableFor(obj: any): void;
  30216. static HasTags(obj: any): boolean;
  30217. static GetTags(obj: any, asString?: boolean): any;
  30218. static AddTagsTo(obj: any, tagsString: string): void;
  30219. static _AddTagTo(obj: any, tag: string): void;
  30220. static RemoveTagsFrom(obj: any, tagsString: string): void;
  30221. static _RemoveTagFrom(obj: any, tag: string): void;
  30222. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  30223. }
  30224. }
  30225. declare module BABYLON {
  30226. class TextureTools {
  30227. /**
  30228. * Uses the GPU to create a copy texture rescaled at a given size
  30229. * @param texture Texture to copy from
  30230. * @param width Desired width
  30231. * @param height Desired height
  30232. * @return Generated texture
  30233. */
  30234. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  30235. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  30236. private static _environmentBRDFBase64Texture;
  30237. }
  30238. }
  30239. declare module BABYLON {
  30240. class TGATools {
  30241. private static _TYPE_INDEXED;
  30242. private static _TYPE_RGB;
  30243. private static _TYPE_GREY;
  30244. private static _TYPE_RLE_INDEXED;
  30245. private static _TYPE_RLE_RGB;
  30246. private static _TYPE_RLE_GREY;
  30247. private static _ORIGIN_MASK;
  30248. private static _ORIGIN_SHIFT;
  30249. private static _ORIGIN_BL;
  30250. private static _ORIGIN_BR;
  30251. private static _ORIGIN_UL;
  30252. private static _ORIGIN_UR;
  30253. static GetTGAHeader(data: Uint8Array): any;
  30254. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  30255. 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;
  30256. 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;
  30257. 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;
  30258. 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;
  30259. 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;
  30260. 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;
  30261. }
  30262. }
  30263. declare module BABYLON {
  30264. interface IAnimatable {
  30265. animations: Array<Animation>;
  30266. }
  30267. /** Interface used by value gradients (color, factor, ...) */
  30268. interface IValueGradient {
  30269. /**
  30270. * Gets or sets the gradient value (between 0 and 1)
  30271. */
  30272. gradient: number;
  30273. }
  30274. /** Class used to store color gradient */
  30275. class ColorGradient implements IValueGradient {
  30276. /**
  30277. * Gets or sets the gradient value (between 0 and 1)
  30278. */
  30279. gradient: number;
  30280. /**
  30281. * Gets or sets first associated color
  30282. */
  30283. color1: Color4;
  30284. /**
  30285. * Gets or sets second associated color
  30286. */
  30287. color2?: Color4;
  30288. /**
  30289. * Will get a color picked randomly between color1 and color2.
  30290. * If color2 is undefined then color1 will be used
  30291. * @param result defines the target Color4 to store the result in
  30292. */
  30293. getColorToRef(result: Color4): void;
  30294. }
  30295. /** Class used to store factor gradient */
  30296. class FactorGradient implements IValueGradient {
  30297. /**
  30298. * Gets or sets the gradient value (between 0 and 1)
  30299. */
  30300. gradient: number;
  30301. /**
  30302. * Gets or sets first associated factor
  30303. */
  30304. factor1: number;
  30305. /**
  30306. * Gets or sets second associated factor
  30307. */
  30308. factor2?: number;
  30309. /**
  30310. * Will get a number picked randomly between factor1 and factor2.
  30311. * If factor2 is undefined then factor1 will be used
  30312. * @returns the picked number
  30313. */
  30314. getFactor(): number;
  30315. }
  30316. class LoadFileError extends Error {
  30317. request: XMLHttpRequest | undefined;
  30318. private static _setPrototypeOf;
  30319. constructor(message: string, request?: XMLHttpRequest | undefined);
  30320. }
  30321. class RetryStrategy {
  30322. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30323. }
  30324. interface IFileRequest {
  30325. /**
  30326. * Raised when the request is complete (success or error).
  30327. */
  30328. onCompleteObservable: Observable<IFileRequest>;
  30329. /**
  30330. * Aborts the request for a file.
  30331. */
  30332. abort: () => void;
  30333. }
  30334. class Tools {
  30335. static BaseUrl: string;
  30336. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30337. /**
  30338. * Default behaviour for cors in the application.
  30339. * It can be a string if the expected behavior is identical in the entire app.
  30340. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30341. */
  30342. static CorsBehavior: string | ((url: string | string[]) => string);
  30343. static UseFallbackTexture: boolean;
  30344. /**
  30345. * Use this object to register external classes like custom textures or material
  30346. * to allow the laoders to instantiate them
  30347. */
  30348. static RegisteredExternalClasses: {
  30349. [key: string]: Object;
  30350. };
  30351. static fallbackTexture: string;
  30352. /**
  30353. * Interpolates between a and b via alpha
  30354. * @param a The lower value (returned when alpha = 0)
  30355. * @param b The upper value (returned when alpha = 1)
  30356. * @param alpha The interpolation-factor
  30357. * @return The mixed value
  30358. */
  30359. static Mix(a: number, b: number, alpha: number): number;
  30360. static Instantiate(className: string): any;
  30361. /**
  30362. * Provides a slice function that will work even on IE
  30363. * @param data defines the array to slice
  30364. * @param start defines the start of the data (optional)
  30365. * @param end defines the end of the data (optional)
  30366. * @returns the new sliced array
  30367. */
  30368. static Slice<T>(data: T, start?: number, end?: number): T;
  30369. static SetImmediate(action: () => void): void;
  30370. static IsExponentOfTwo(value: number): boolean;
  30371. private static _tmpFloatArray;
  30372. /**
  30373. * Returns the nearest 32-bit single precision float representation of a Number
  30374. * @param value A Number. If the parameter is of a different type, it will get converted
  30375. * to a number or to NaN if it cannot be converted
  30376. * @returns number
  30377. */
  30378. static FloatRound(value: number): number;
  30379. /**
  30380. * Find the next highest power of two.
  30381. * @param x Number to start search from.
  30382. * @return Next highest power of two.
  30383. */
  30384. static CeilingPOT(x: number): number;
  30385. /**
  30386. * Find the next lowest power of two.
  30387. * @param x Number to start search from.
  30388. * @return Next lowest power of two.
  30389. */
  30390. static FloorPOT(x: number): number;
  30391. /**
  30392. * Find the nearest power of two.
  30393. * @param x Number to start search from.
  30394. * @return Next nearest power of two.
  30395. */
  30396. static NearestPOT(x: number): number;
  30397. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30398. static GetFilename(path: string): string;
  30399. /**
  30400. * Extracts the "folder" part of a path (everything before the filename).
  30401. * @param uri The URI to extract the info from
  30402. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30403. * @returns The "folder" part of the path
  30404. */
  30405. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30406. static GetDOMTextContent(element: HTMLElement): string;
  30407. static ToDegrees(angle: number): number;
  30408. static ToRadians(angle: number): number;
  30409. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30410. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30411. minimum: Vector3;
  30412. maximum: Vector3;
  30413. };
  30414. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30415. minimum: Vector3;
  30416. maximum: Vector3;
  30417. };
  30418. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30419. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30420. minimum: Vector2;
  30421. maximum: Vector2;
  30422. };
  30423. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30424. static GetPointerPrefix(): string;
  30425. /**
  30426. * @param func - the function to be called
  30427. * @param requester - the object that will request the next frame. Falls back to window.
  30428. */
  30429. static QueueNewFrame(func: () => void, requester?: any): number;
  30430. static RequestFullscreen(element: HTMLElement): void;
  30431. static ExitFullscreen(): void;
  30432. static SetCorsBehavior(url: string | string[], element: {
  30433. crossOrigin: string | null;
  30434. }): void;
  30435. static CleanUrl(url: string): string;
  30436. static PreprocessUrl: (url: string) => string;
  30437. /**
  30438. * Loads an image as an HTMLImageElement.
  30439. * @param input url string, ArrayBuffer, or Blob to load
  30440. * @param onLoad callback called when the image successfully loads
  30441. * @param onError callback called when the image fails to load
  30442. * @param database database for caching
  30443. * @returns the HTMLImageElement of the loaded image
  30444. */
  30445. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30446. 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;
  30447. /**
  30448. * Load a script (identified by an url). When the url returns, the
  30449. * content of this file is added into a new script element, attached to the DOM (body element)
  30450. */
  30451. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30452. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30453. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30454. static FileAsURL(content: string): string;
  30455. static Format(value: number, decimals?: number): string;
  30456. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30457. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30458. static IsEmpty(obj: any): boolean;
  30459. static RegisterTopRootEvents(events: {
  30460. name: string;
  30461. handler: Nullable<(e: FocusEvent) => any>;
  30462. }[]): void;
  30463. static UnregisterTopRootEvents(events: {
  30464. name: string;
  30465. handler: Nullable<(e: FocusEvent) => any>;
  30466. }[]): void;
  30467. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30468. /**
  30469. * Converts the canvas data to blob.
  30470. * This acts as a polyfill for browsers not supporting the to blob function.
  30471. * @param canvas Defines the canvas to extract the data from
  30472. * @param successCallback Defines the callback triggered once the data are available
  30473. * @param mimeType Defines the mime type of the result
  30474. */
  30475. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30476. /**
  30477. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30478. * @param successCallback Defines the callback triggered once the data are available
  30479. * @param mimeType Defines the mime type of the result
  30480. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30481. */
  30482. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30483. /**
  30484. * Downloads a blob in the browser
  30485. * @param blob defines the blob to download
  30486. * @param fileName defines the name of the downloaded file
  30487. */
  30488. static Download(blob: Blob, fileName: string): void;
  30489. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30490. /**
  30491. * Generates an image screenshot from the specified camera.
  30492. *
  30493. * @param engine The engine to use for rendering
  30494. * @param camera The camera to use for rendering
  30495. * @param size This parameter can be set to a single number or to an object with the
  30496. * following (optional) properties: precision, width, height. If a single number is passed,
  30497. * it will be used for both width and height. If an object is passed, the screenshot size
  30498. * will be derived from the parameters. The precision property is a multiplier allowing
  30499. * rendering at a higher or lower resolution.
  30500. * @param successCallback The callback receives a single parameter which contains the
  30501. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30502. * src parameter of an <img> to display it.
  30503. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30504. * Check your browser for supported MIME types.
  30505. * @param samples Texture samples (default: 1)
  30506. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30507. * @param fileName A name for for the downloaded file.
  30508. * @constructor
  30509. */
  30510. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30511. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30512. /**
  30513. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30514. * Be aware Math.random() could cause collisions, but:
  30515. * "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"
  30516. */
  30517. static RandomId(): string;
  30518. /**
  30519. * Test if the given uri is a base64 string.
  30520. * @param uri The uri to test
  30521. * @return True if the uri is a base64 string or false otherwise.
  30522. */
  30523. static IsBase64(uri: string): boolean;
  30524. /**
  30525. * Decode the given base64 uri.
  30526. * @param uri The uri to decode
  30527. * @return The decoded base64 data.
  30528. */
  30529. static DecodeBase64(uri: string): ArrayBuffer;
  30530. private static _NoneLogLevel;
  30531. private static _MessageLogLevel;
  30532. private static _WarningLogLevel;
  30533. private static _ErrorLogLevel;
  30534. private static _LogCache;
  30535. static errorsCount: number;
  30536. static OnNewCacheEntry: (entry: string) => void;
  30537. static readonly NoneLogLevel: number;
  30538. static readonly MessageLogLevel: number;
  30539. static readonly WarningLogLevel: number;
  30540. static readonly ErrorLogLevel: number;
  30541. static readonly AllLogLevel: number;
  30542. private static _AddLogEntry(entry);
  30543. private static _FormatMessage(message);
  30544. private static _LogDisabled(message);
  30545. private static _LogEnabled(message);
  30546. private static _WarnDisabled(message);
  30547. private static _WarnEnabled(message);
  30548. private static _ErrorDisabled(message);
  30549. private static _ErrorEnabled(message);
  30550. static Log: (message: string) => void;
  30551. static Warn: (message: string) => void;
  30552. static Error: (message: string) => void;
  30553. static readonly LogCache: string;
  30554. static ClearLogCache(): void;
  30555. static LogLevels: number;
  30556. static IsWindowObjectExist(): boolean;
  30557. private static _PerformanceNoneLogLevel;
  30558. private static _PerformanceUserMarkLogLevel;
  30559. private static _PerformanceConsoleLogLevel;
  30560. private static _performance;
  30561. static readonly PerformanceNoneLogLevel: number;
  30562. static readonly PerformanceUserMarkLogLevel: number;
  30563. static readonly PerformanceConsoleLogLevel: number;
  30564. static PerformanceLogLevel: number;
  30565. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30566. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30567. static _StartUserMark(counterName: string, condition?: boolean): void;
  30568. static _EndUserMark(counterName: string, condition?: boolean): void;
  30569. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30570. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30571. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30572. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30573. static readonly Now: number;
  30574. /**
  30575. * This method will return the name of the class used to create the instance of the given object.
  30576. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30577. * @param object the object to get the class name from
  30578. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30579. */
  30580. static GetClassName(object: any, isType?: boolean): string;
  30581. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30582. /**
  30583. * This method will return the name of the full name of the class, including its owning module (if any).
  30584. * 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).
  30585. * @param object the object to get the class name from
  30586. * @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.
  30587. */
  30588. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30589. /**
  30590. * 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.
  30591. * @param array
  30592. */
  30593. static arrayOrStringFeeder(array: any): (i: number) => number;
  30594. /**
  30595. * Compute the hashCode of a stream of number
  30596. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30597. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30598. * @return the hash code computed
  30599. */
  30600. static hashCodeFromStream(feeder: (index: number) => number): number;
  30601. /**
  30602. * Returns a promise that resolves after the given amount of time.
  30603. * @param delay Number of milliseconds to delay
  30604. * @returns Promise that resolves after the given amount of time
  30605. */
  30606. static DelayAsync(delay: number): Promise<void>;
  30607. /**
  30608. * Gets the current gradient from an array of IValueGradient
  30609. * @param ratio defines the current ratio to get
  30610. * @param gradients defines the array of IValueGradient
  30611. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30612. */
  30613. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30614. }
  30615. /**
  30616. * This class is used to track a performance counter which is number based.
  30617. * The user has access to many properties which give statistics of different nature
  30618. *
  30619. * The implementer can track two kinds of Performance Counter: time and count
  30620. * 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.
  30621. * 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.
  30622. */
  30623. class PerfCounter {
  30624. static Enabled: boolean;
  30625. /**
  30626. * Returns the smallest value ever
  30627. */
  30628. readonly min: number;
  30629. /**
  30630. * Returns the biggest value ever
  30631. */
  30632. readonly max: number;
  30633. /**
  30634. * Returns the average value since the performance counter is running
  30635. */
  30636. readonly average: number;
  30637. /**
  30638. * Returns the average value of the last second the counter was monitored
  30639. */
  30640. readonly lastSecAverage: number;
  30641. /**
  30642. * Returns the current value
  30643. */
  30644. readonly current: number;
  30645. readonly total: number;
  30646. readonly count: number;
  30647. constructor();
  30648. /**
  30649. * Call this method to start monitoring a new frame.
  30650. * 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.
  30651. */
  30652. fetchNewFrame(): void;
  30653. /**
  30654. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30655. * @param newCount the count value to add to the monitored count
  30656. * @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.
  30657. */
  30658. addCount(newCount: number, fetchResult: boolean): void;
  30659. /**
  30660. * Start monitoring this performance counter
  30661. */
  30662. beginMonitoring(): void;
  30663. /**
  30664. * Compute the time lapsed since the previous beginMonitoring() call.
  30665. * @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
  30666. */
  30667. endMonitoring(newFrame?: boolean): void;
  30668. private _fetchResult();
  30669. private _startMonitoringTime;
  30670. private _min;
  30671. private _max;
  30672. private _average;
  30673. private _current;
  30674. private _totalValueCount;
  30675. private _totalAccumulated;
  30676. private _lastSecAverage;
  30677. private _lastSecAccumulated;
  30678. private _lastSecTime;
  30679. private _lastSecValueCount;
  30680. }
  30681. /**
  30682. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30683. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30684. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30685. * @param name The name of the class, case should be preserved
  30686. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30687. */
  30688. function className(name: string, module?: string): (target: Object) => void;
  30689. /**
  30690. * An implementation of a loop for asynchronous functions.
  30691. */
  30692. class AsyncLoop {
  30693. iterations: number;
  30694. private _fn;
  30695. private _successCallback;
  30696. index: number;
  30697. private _done;
  30698. /**
  30699. * Constroctor.
  30700. * @param iterations the number of iterations.
  30701. * @param _fn the function to run each iteration
  30702. * @param _successCallback the callback that will be called upon succesful execution
  30703. * @param offset starting offset.
  30704. */
  30705. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30706. /**
  30707. * Execute the next iteration. Must be called after the last iteration was finished.
  30708. */
  30709. executeNext(): void;
  30710. /**
  30711. * Break the loop and run the success callback.
  30712. */
  30713. breakLoop(): void;
  30714. /**
  30715. * Helper function
  30716. */
  30717. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30718. /**
  30719. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30720. * @param iterations total number of iterations
  30721. * @param syncedIterations number of synchronous iterations in each async iteration.
  30722. * @param fn the function to call each iteration.
  30723. * @param callback a success call back that will be called when iterating stops.
  30724. * @param breakFunction a break condition (optional)
  30725. * @param timeout timeout settings for the setTimeout function. default - 0.
  30726. * @constructor
  30727. */
  30728. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30729. }
  30730. }
  30731. declare module BABYLON {
  30732. /**
  30733. * Defines the potential axis of a Joystick
  30734. */
  30735. enum JoystickAxis {
  30736. /** X axis */
  30737. X = 0,
  30738. /** Y axis */
  30739. Y = 1,
  30740. /** Z axis */
  30741. Z = 2,
  30742. }
  30743. /**
  30744. * Class used to define virtual joystick (used in touch mode)
  30745. */
  30746. class VirtualJoystick {
  30747. /**
  30748. * Gets or sets a boolean indicating that left and right values must be inverted
  30749. */
  30750. reverseLeftRight: boolean;
  30751. /**
  30752. * Gets or sets a boolean indicating that up and down values must be inverted
  30753. */
  30754. reverseUpDown: boolean;
  30755. /**
  30756. * Gets the offset value for the position (ie. the change of the position value)
  30757. */
  30758. deltaPosition: Vector3;
  30759. /**
  30760. * Gets a boolean indicating if the virtual joystick was pressed
  30761. */
  30762. pressed: boolean;
  30763. private static _globalJoystickIndex;
  30764. private static vjCanvas;
  30765. private static vjCanvasContext;
  30766. private static vjCanvasWidth;
  30767. private static vjCanvasHeight;
  30768. private static halfWidth;
  30769. private _action;
  30770. private _axisTargetedByLeftAndRight;
  30771. private _axisTargetedByUpAndDown;
  30772. private _joystickSensibility;
  30773. private _inversedSensibility;
  30774. private _joystickPointerID;
  30775. private _joystickColor;
  30776. private _joystickPointerPos;
  30777. private _joystickPreviousPointerPos;
  30778. private _joystickPointerStartPos;
  30779. private _deltaJoystickVector;
  30780. private _leftJoystick;
  30781. private _touches;
  30782. private _onPointerDownHandlerRef;
  30783. private _onPointerMoveHandlerRef;
  30784. private _onPointerUpHandlerRef;
  30785. private _onResize;
  30786. /**
  30787. * Creates a new virtual joystick
  30788. * @param leftJoystick defines that the joystick is for left hand (false by default)
  30789. */
  30790. constructor(leftJoystick?: boolean);
  30791. /**
  30792. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  30793. * @param newJoystickSensibility defines the new sensibility
  30794. */
  30795. setJoystickSensibility(newJoystickSensibility: number): void;
  30796. private _onPointerDown(e);
  30797. private _onPointerMove(e);
  30798. private _onPointerUp(e);
  30799. /**
  30800. * Change the color of the virtual joystick
  30801. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  30802. */
  30803. setJoystickColor(newColor: string): void;
  30804. /**
  30805. * Defines a callback to call when the joystick is touched
  30806. * @param action defines the callback
  30807. */
  30808. setActionOnTouch(action: () => any): void;
  30809. /**
  30810. * Defines which axis you'd like to control for left & right
  30811. * @param axis defines the axis to use
  30812. */
  30813. setAxisForLeftRight(axis: JoystickAxis): void;
  30814. /**
  30815. * Defines which axis you'd like to control for up & down
  30816. * @param axis defines the axis to use
  30817. */
  30818. setAxisForUpDown(axis: JoystickAxis): void;
  30819. private _drawVirtualJoystick();
  30820. /**
  30821. * Release internal HTML canvas
  30822. */
  30823. releaseCanvas(): void;
  30824. }
  30825. }
  30826. declare module BABYLON {
  30827. /**
  30828. * Helper class to push actions to a pool of workers.
  30829. */
  30830. class WorkerPool implements IDisposable {
  30831. private _workerInfos;
  30832. private _pendingActions;
  30833. /**
  30834. * Constructor
  30835. * @param workers Array of workers to use for actions
  30836. */
  30837. constructor(workers: Array<Worker>);
  30838. /**
  30839. * Terminates all workers and clears any pending actions.
  30840. */
  30841. dispose(): void;
  30842. /**
  30843. * Pushes an action to the worker pool. If all the workers are active, the action will be
  30844. * pended until a worker has completed its action.
  30845. * @param action The action to perform. Call onComplete when the action is complete.
  30846. */
  30847. push(action: (worker: Worker, onComplete: () => void) => void): void;
  30848. private _execute(workerInfo, action);
  30849. }
  30850. }
  30851. declare module BABYLON {
  30852. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  30853. readonly name: string;
  30854. private _zoomStopsAnimation;
  30855. private _idleRotationSpeed;
  30856. private _idleRotationWaitTime;
  30857. private _idleRotationSpinupTime;
  30858. /**
  30859. * Gets the flag that indicates if user zooming should stop animation.
  30860. */
  30861. /**
  30862. * Sets the flag that indicates if user zooming should stop animation.
  30863. */
  30864. zoomStopsAnimation: boolean;
  30865. /**
  30866. * Gets the default speed at which the camera rotates around the model.
  30867. */
  30868. /**
  30869. * Sets the default speed at which the camera rotates around the model.
  30870. */
  30871. idleRotationSpeed: number;
  30872. /**
  30873. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  30874. */
  30875. /**
  30876. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  30877. */
  30878. idleRotationWaitTime: number;
  30879. /**
  30880. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30881. */
  30882. /**
  30883. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  30884. */
  30885. idleRotationSpinupTime: number;
  30886. /**
  30887. * Gets a value indicating if the camera is currently rotating because of this behavior
  30888. */
  30889. readonly rotationInProgress: boolean;
  30890. private _onPrePointerObservableObserver;
  30891. private _onAfterCheckInputsObserver;
  30892. private _attachedCamera;
  30893. private _isPointerDown;
  30894. private _lastFrameTime;
  30895. private _lastInteractionTime;
  30896. private _cameraRotationSpeed;
  30897. init(): void;
  30898. attach(camera: ArcRotateCamera): void;
  30899. detach(): void;
  30900. /**
  30901. * Returns true if user is scrolling.
  30902. * @return true if user is scrolling.
  30903. */
  30904. private _userIsZooming();
  30905. private _lastFrameRadius;
  30906. private _shouldAnimationStopForInteraction();
  30907. /**
  30908. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  30909. */
  30910. private _applyUserInteraction();
  30911. private _userIsMoving();
  30912. }
  30913. }
  30914. declare module BABYLON {
  30915. /**
  30916. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  30917. */
  30918. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  30919. readonly name: string;
  30920. /**
  30921. * The easing function used by animations
  30922. */
  30923. static EasingFunction: BackEase;
  30924. /**
  30925. * The easing mode used by animations
  30926. */
  30927. static EasingMode: number;
  30928. /**
  30929. * The duration of the animation, in milliseconds
  30930. */
  30931. transitionDuration: number;
  30932. /**
  30933. * Length of the distance animated by the transition when lower radius is reached
  30934. */
  30935. lowerRadiusTransitionRange: number;
  30936. /**
  30937. * Length of the distance animated by the transition when upper radius is reached
  30938. */
  30939. upperRadiusTransitionRange: number;
  30940. private _autoTransitionRange;
  30941. /**
  30942. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30943. */
  30944. /**
  30945. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  30946. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  30947. */
  30948. autoTransitionRange: boolean;
  30949. private _attachedCamera;
  30950. private _onAfterCheckInputsObserver;
  30951. private _onMeshTargetChangedObserver;
  30952. init(): void;
  30953. attach(camera: ArcRotateCamera): void;
  30954. detach(): void;
  30955. private _radiusIsAnimating;
  30956. private _radiusBounceTransition;
  30957. private _animatables;
  30958. private _cachedWheelPrecision;
  30959. /**
  30960. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  30961. * @param radiusLimit The limit to check against.
  30962. * @return Bool to indicate if at limit.
  30963. */
  30964. private _isRadiusAtLimit(radiusLimit);
  30965. /**
  30966. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  30967. * @param radiusDelta The delta by which to animate to. Can be negative.
  30968. */
  30969. private _applyBoundRadiusAnimation(radiusDelta);
  30970. /**
  30971. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  30972. */
  30973. protected _clearAnimationLocks(): void;
  30974. /**
  30975. * Stops and removes all animations that have been applied to the camera
  30976. */
  30977. stopAllAnimations(): void;
  30978. }
  30979. }
  30980. declare module BABYLON {
  30981. class FramingBehavior implements Behavior<ArcRotateCamera> {
  30982. readonly name: string;
  30983. private _mode;
  30984. private _radiusScale;
  30985. private _positionScale;
  30986. private _defaultElevation;
  30987. private _elevationReturnTime;
  30988. private _elevationReturnWaitTime;
  30989. private _zoomStopsAnimation;
  30990. private _framingTime;
  30991. /**
  30992. * The easing function used by animations
  30993. */
  30994. static EasingFunction: ExponentialEase;
  30995. /**
  30996. * The easing mode used by animations
  30997. */
  30998. static EasingMode: number;
  30999. /**
  31000. * Gets current mode used by the behavior.
  31001. */
  31002. /**
  31003. * Sets the current mode used by the behavior
  31004. */
  31005. mode: number;
  31006. /**
  31007. * Gets the scale applied to the radius
  31008. */
  31009. /**
  31010. * Sets the scale applied to the radius (1 by default)
  31011. */
  31012. radiusScale: number;
  31013. /**
  31014. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31015. */
  31016. /**
  31017. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31018. */
  31019. positionScale: number;
  31020. /**
  31021. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31022. * behaviour is triggered, in radians.
  31023. */
  31024. /**
  31025. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31026. * behaviour is triggered, in radians.
  31027. */
  31028. defaultElevation: number;
  31029. /**
  31030. * Gets the time (in milliseconds) taken to return to the default beta position.
  31031. * Negative value indicates camera should not return to default.
  31032. */
  31033. /**
  31034. * Sets the time (in milliseconds) taken to return to the default beta position.
  31035. * Negative value indicates camera should not return to default.
  31036. */
  31037. elevationReturnTime: number;
  31038. /**
  31039. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31040. */
  31041. /**
  31042. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31043. */
  31044. elevationReturnWaitTime: number;
  31045. /**
  31046. * Gets the flag that indicates if user zooming should stop animation.
  31047. */
  31048. /**
  31049. * Sets the flag that indicates if user zooming should stop animation.
  31050. */
  31051. zoomStopsAnimation: boolean;
  31052. /**
  31053. * Gets the transition time when framing the mesh, in milliseconds
  31054. */
  31055. /**
  31056. * Sets the transition time when framing the mesh, in milliseconds
  31057. */
  31058. framingTime: number;
  31059. private _onPrePointerObservableObserver;
  31060. private _onAfterCheckInputsObserver;
  31061. private _onMeshTargetChangedObserver;
  31062. private _attachedCamera;
  31063. private _isPointerDown;
  31064. private _lastInteractionTime;
  31065. init(): void;
  31066. attach(camera: ArcRotateCamera): void;
  31067. detach(): void;
  31068. private _animatables;
  31069. private _betaIsAnimating;
  31070. private _betaTransition;
  31071. private _radiusTransition;
  31072. private _vectorTransition;
  31073. /**
  31074. * Targets the given mesh and updates zoom level accordingly.
  31075. * @param mesh The mesh to target.
  31076. * @param radius Optional. If a cached radius position already exists, overrides default.
  31077. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31078. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31079. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31080. */
  31081. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31082. /**
  31083. * Targets the given mesh with its children and updates zoom level accordingly.
  31084. * @param mesh The mesh to target.
  31085. * @param radius Optional. If a cached radius position already exists, overrides default.
  31086. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31087. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31088. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31089. */
  31090. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31091. /**
  31092. * Targets the given meshes with their children and updates zoom level accordingly.
  31093. * @param meshes The mesh to target.
  31094. * @param radius Optional. If a cached radius position already exists, overrides default.
  31095. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31096. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31097. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31098. */
  31099. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31100. /**
  31101. * Targets the given mesh and updates zoom level accordingly.
  31102. * @param mesh The mesh to target.
  31103. * @param radius Optional. If a cached radius position already exists, overrides default.
  31104. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31105. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31106. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31107. */
  31108. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31109. /**
  31110. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31111. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31112. * frustum width.
  31113. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31114. * to fully enclose the mesh in the viewing frustum.
  31115. */
  31116. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31117. /**
  31118. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31119. * is automatically returned to its default position (expected to be above ground plane).
  31120. */
  31121. private _maintainCameraAboveGround();
  31122. /**
  31123. * Returns the frustum slope based on the canvas ratio and camera FOV
  31124. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31125. */
  31126. private _getFrustumSlope();
  31127. /**
  31128. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31129. */
  31130. private _clearAnimationLocks();
  31131. /**
  31132. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31133. */
  31134. private _applyUserInteraction();
  31135. /**
  31136. * Stops and removes all animations that have been applied to the camera
  31137. */
  31138. stopAllAnimations(): void;
  31139. /**
  31140. * Gets a value indicating if the user is moving the camera
  31141. */
  31142. readonly isUserIsMoving: boolean;
  31143. /**
  31144. * The camera can move all the way towards the mesh.
  31145. */
  31146. static IgnoreBoundsSizeMode: number;
  31147. /**
  31148. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31149. */
  31150. static FitFrustumSidesMode: number;
  31151. }
  31152. }
  31153. declare module BABYLON {
  31154. /**
  31155. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31156. */
  31157. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31158. private _dragBehaviorA;
  31159. private _dragBehaviorB;
  31160. private _startDistance;
  31161. private _initialScale;
  31162. private _targetScale;
  31163. private _ownerNode;
  31164. private _sceneRenderObserver;
  31165. constructor();
  31166. /**
  31167. * The name of the behavior
  31168. */
  31169. readonly name: string;
  31170. /**
  31171. * Initializes the behavior
  31172. */
  31173. init(): void;
  31174. private _getCurrentDistance();
  31175. /**
  31176. * Attaches the scale behavior the passed in mesh
  31177. * @param ownerNode The mesh that will be scaled around once attached
  31178. */
  31179. attach(ownerNode: Mesh): void;
  31180. /**
  31181. * Detaches the behavior from the mesh
  31182. */
  31183. detach(): void;
  31184. }
  31185. }
  31186. declare module BABYLON {
  31187. /**
  31188. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31189. */
  31190. class PointerDragBehavior implements Behavior<Mesh> {
  31191. private options;
  31192. private _attachedNode;
  31193. private _dragPlane;
  31194. private _scene;
  31195. private _pointerObserver;
  31196. private static _planeScene;
  31197. /**
  31198. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31199. */
  31200. currentDraggingPointerID: number;
  31201. /**
  31202. * The last position where the pointer hit the drag plane in world space
  31203. */
  31204. lastDragPosition: Vector3;
  31205. /**
  31206. * If the behavior is currently in a dragging state
  31207. */
  31208. dragging: boolean;
  31209. /**
  31210. * 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)
  31211. */
  31212. dragDeltaRatio: number;
  31213. /**
  31214. * If the drag plane orientation should be updated during the dragging (Default: true)
  31215. */
  31216. updateDragPlane: boolean;
  31217. private _debugMode;
  31218. private _moving;
  31219. /**
  31220. * Fires each time the attached mesh is dragged with the pointer
  31221. * * delta between last drag position and current drag position in world space
  31222. * * dragDistance along the drag axis
  31223. * * dragPlaneNormal normal of the current drag plane used during the drag
  31224. * * dragPlanePoint in world space where the drag intersects the drag plane
  31225. */
  31226. onDragObservable: Observable<{
  31227. delta: Vector3;
  31228. dragPlanePoint: Vector3;
  31229. dragPlaneNormal: Vector3;
  31230. dragDistance: number;
  31231. pointerId: number;
  31232. }>;
  31233. /**
  31234. * Fires each time a drag begins (eg. mouse down on mesh)
  31235. */
  31236. onDragStartObservable: Observable<{
  31237. dragPlanePoint: Vector3;
  31238. pointerId: number;
  31239. }>;
  31240. /**
  31241. * Fires each time a drag ends (eg. mouse release after drag)
  31242. */
  31243. onDragEndObservable: Observable<{
  31244. dragPlanePoint: Vector3;
  31245. pointerId: number;
  31246. }>;
  31247. /**
  31248. * If the attached mesh should be moved when dragged
  31249. */
  31250. moveAttached: boolean;
  31251. /**
  31252. * If the drag behavior will react to drag events (Default: true)
  31253. */
  31254. enabled: boolean;
  31255. /**
  31256. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  31257. */
  31258. useObjectOrienationForDragging: boolean;
  31259. /**
  31260. * Creates a pointer drag behavior that can be attached to a mesh
  31261. * @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)
  31262. */
  31263. constructor(options: {
  31264. dragAxis?: Vector3;
  31265. dragPlaneNormal?: Vector3;
  31266. });
  31267. /**
  31268. * The name of the behavior
  31269. */
  31270. readonly name: string;
  31271. /**
  31272. * Initializes the behavior
  31273. */
  31274. init(): void;
  31275. private _tmpVector;
  31276. private _worldDragAxis;
  31277. /**
  31278. * Attaches the drag behavior the passed in mesh
  31279. * @param ownerNode The mesh that will be dragged around once attached
  31280. */
  31281. attach(ownerNode: Mesh): void;
  31282. releaseDrag(): void;
  31283. private _pickWithRayOnDragPlane(ray);
  31284. private _pointA;
  31285. private _pointB;
  31286. private _pointC;
  31287. private _lineA;
  31288. private _lineB;
  31289. private _localAxis;
  31290. private _lookAt;
  31291. private _updateDragPlanePosition(ray, dragPlanePosition);
  31292. /**
  31293. * Detaches the behavior from the mesh
  31294. */
  31295. detach(): void;
  31296. }
  31297. }
  31298. declare module BABYLON {
  31299. /**
  31300. * 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
  31301. */
  31302. class SixDofDragBehavior implements Behavior<Mesh> {
  31303. private static _virtualScene;
  31304. private _ownerNode;
  31305. private _sceneRenderObserver;
  31306. private _scene;
  31307. private _targetPosition;
  31308. private _virtualOriginMesh;
  31309. private _virtualDragMesh;
  31310. private _pointerObserver;
  31311. private _moving;
  31312. private _startingOrientation;
  31313. /**
  31314. * 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: 5)
  31315. */
  31316. private zDragFactor;
  31317. /**
  31318. * If the behavior is currently in a dragging state
  31319. */
  31320. dragging: boolean;
  31321. /**
  31322. * 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)
  31323. */
  31324. dragDeltaRatio: number;
  31325. /**
  31326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31327. */
  31328. currentDraggingPointerID: number;
  31329. constructor();
  31330. /**
  31331. * The name of the behavior
  31332. */
  31333. readonly name: string;
  31334. /**
  31335. * Initializes the behavior
  31336. */
  31337. init(): void;
  31338. /**
  31339. * Attaches the scale behavior the passed in mesh
  31340. * @param ownerNode The mesh that will be scaled around once attached
  31341. */
  31342. attach(ownerNode: Mesh): void;
  31343. /**
  31344. * Detaches the behavior from the mesh
  31345. */
  31346. detach(): void;
  31347. }
  31348. }
  31349. declare module BABYLON {
  31350. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31351. camera: ArcRotateCamera;
  31352. gamepad: Nullable<Gamepad>;
  31353. private _onGamepadConnectedObserver;
  31354. private _onGamepadDisconnectedObserver;
  31355. gamepadRotationSensibility: number;
  31356. gamepadMoveSensibility: number;
  31357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31358. detachControl(element: Nullable<HTMLElement>): void;
  31359. checkInputs(): void;
  31360. getClassName(): string;
  31361. getSimpleName(): string;
  31362. }
  31363. }
  31364. declare module BABYLON {
  31365. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31366. camera: ArcRotateCamera;
  31367. private _keys;
  31368. keysUp: number[];
  31369. keysDown: number[];
  31370. keysLeft: number[];
  31371. keysRight: number[];
  31372. keysReset: number[];
  31373. panningSensibility: number;
  31374. zoomingSensibility: number;
  31375. useAltToZoom: boolean;
  31376. private _ctrlPressed;
  31377. private _altPressed;
  31378. private _onCanvasBlurObserver;
  31379. private _onKeyboardObserver;
  31380. private _engine;
  31381. private _scene;
  31382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31383. detachControl(element: Nullable<HTMLElement>): void;
  31384. checkInputs(): void;
  31385. getClassName(): string;
  31386. getSimpleName(): string;
  31387. }
  31388. }
  31389. declare module BABYLON {
  31390. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31391. camera: ArcRotateCamera;
  31392. private _wheel;
  31393. private _observer;
  31394. wheelPrecision: number;
  31395. /**
  31396. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31397. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31398. */
  31399. wheelDeltaPercentage: number;
  31400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31401. detachControl(element: Nullable<HTMLElement>): void;
  31402. getClassName(): string;
  31403. getSimpleName(): string;
  31404. }
  31405. }
  31406. declare module BABYLON {
  31407. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31408. camera: ArcRotateCamera;
  31409. buttons: number[];
  31410. angularSensibilityX: number;
  31411. angularSensibilityY: number;
  31412. pinchPrecision: number;
  31413. /**
  31414. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31415. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31416. */
  31417. pinchDeltaPercentage: number;
  31418. panningSensibility: number;
  31419. multiTouchPanning: boolean;
  31420. multiTouchPanAndZoom: boolean;
  31421. private _isPanClick;
  31422. pinchInwards: boolean;
  31423. private _pointerInput;
  31424. private _observer;
  31425. private _onMouseMove;
  31426. private _onGestureStart;
  31427. private _onGesture;
  31428. private _MSGestureHandler;
  31429. private _onLostFocus;
  31430. private _onContextMenu;
  31431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31432. detachControl(element: Nullable<HTMLElement>): void;
  31433. getClassName(): string;
  31434. getSimpleName(): string;
  31435. }
  31436. }
  31437. declare module BABYLON {
  31438. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31439. camera: ArcRotateCamera;
  31440. alphaCorrection: number;
  31441. betaCorrection: number;
  31442. gammaCorrection: number;
  31443. private _alpha;
  31444. private _gamma;
  31445. private _dirty;
  31446. private _deviceOrientationHandler;
  31447. constructor();
  31448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31449. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31450. checkInputs(): void;
  31451. detachControl(element: Nullable<HTMLElement>): void;
  31452. getClassName(): string;
  31453. getSimpleName(): string;
  31454. }
  31455. }
  31456. declare module BABYLON {
  31457. /**
  31458. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31459. * Screen rotation is taken into account.
  31460. */
  31461. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31462. private _camera;
  31463. private _screenOrientationAngle;
  31464. private _constantTranform;
  31465. private _screenQuaternion;
  31466. private _alpha;
  31467. private _beta;
  31468. private _gamma;
  31469. constructor();
  31470. camera: FreeCamera;
  31471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31472. private _orientationChanged;
  31473. private _deviceOrientation;
  31474. detachControl(element: Nullable<HTMLElement>): void;
  31475. checkInputs(): void;
  31476. getClassName(): string;
  31477. getSimpleName(): string;
  31478. }
  31479. }
  31480. declare module BABYLON {
  31481. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31482. camera: FreeCamera;
  31483. gamepad: Nullable<Gamepad>;
  31484. private _onGamepadConnectedObserver;
  31485. private _onGamepadDisconnectedObserver;
  31486. gamepadAngularSensibility: number;
  31487. gamepadMoveSensibility: number;
  31488. private _cameraTransform;
  31489. private _deltaTransform;
  31490. private _vector3;
  31491. private _vector2;
  31492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31493. detachControl(element: Nullable<HTMLElement>): void;
  31494. checkInputs(): void;
  31495. getClassName(): string;
  31496. getSimpleName(): string;
  31497. }
  31498. }
  31499. declare module BABYLON {
  31500. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31501. camera: FreeCamera;
  31502. private _keys;
  31503. private _onCanvasBlurObserver;
  31504. private _onKeyboardObserver;
  31505. private _engine;
  31506. private _scene;
  31507. keysUp: number[];
  31508. keysDown: number[];
  31509. keysLeft: number[];
  31510. keysRight: number[];
  31511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31512. detachControl(element: Nullable<HTMLElement>): void;
  31513. checkInputs(): void;
  31514. getClassName(): string;
  31515. _onLostFocus(e: FocusEvent): void;
  31516. getSimpleName(): string;
  31517. }
  31518. }
  31519. declare module BABYLON {
  31520. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31521. touchEnabled: boolean;
  31522. camera: FreeCamera;
  31523. buttons: number[];
  31524. angularSensibility: number;
  31525. private _pointerInput;
  31526. private _onMouseMove;
  31527. private _observer;
  31528. private previousPosition;
  31529. constructor(touchEnabled?: boolean);
  31530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31531. detachControl(element: Nullable<HTMLElement>): void;
  31532. getClassName(): string;
  31533. getSimpleName(): string;
  31534. }
  31535. }
  31536. declare module BABYLON {
  31537. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31538. camera: FreeCamera;
  31539. private _offsetX;
  31540. private _offsetY;
  31541. private _pointerPressed;
  31542. private _pointerInput;
  31543. private _observer;
  31544. private _onLostFocus;
  31545. touchAngularSensibility: number;
  31546. touchMoveSensibility: number;
  31547. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31548. detachControl(element: Nullable<HTMLElement>): void;
  31549. checkInputs(): void;
  31550. getClassName(): string;
  31551. getSimpleName(): string;
  31552. }
  31553. }
  31554. declare module BABYLON {
  31555. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31556. camera: FreeCamera;
  31557. private _leftjoystick;
  31558. private _rightjoystick;
  31559. getLeftJoystick(): VirtualJoystick;
  31560. getRightJoystick(): VirtualJoystick;
  31561. checkInputs(): void;
  31562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31563. detachControl(element: Nullable<HTMLElement>): void;
  31564. getClassName(): string;
  31565. getSimpleName(): string;
  31566. }
  31567. }
  31568. declare module BABYLON {
  31569. class VRCameraMetrics {
  31570. hResolution: number;
  31571. vResolution: number;
  31572. hScreenSize: number;
  31573. vScreenSize: number;
  31574. vScreenCenter: number;
  31575. eyeToScreenDistance: number;
  31576. lensSeparationDistance: number;
  31577. interpupillaryDistance: number;
  31578. distortionK: number[];
  31579. chromaAbCorrection: number[];
  31580. postProcessScaleFactor: number;
  31581. lensCenterOffset: number;
  31582. compensateDistortion: boolean;
  31583. readonly aspectRatio: number;
  31584. readonly aspectRatioFov: number;
  31585. readonly leftHMatrix: Matrix;
  31586. readonly rightHMatrix: Matrix;
  31587. readonly leftPreViewMatrix: Matrix;
  31588. readonly rightPreViewMatrix: Matrix;
  31589. static GetDefault(): VRCameraMetrics;
  31590. }
  31591. }
  31592. declare module BABYLON {
  31593. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  31594. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31595. getClassName(): string;
  31596. }
  31597. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  31598. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31599. getClassName(): string;
  31600. }
  31601. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  31602. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  31603. getClassName(): string;
  31604. }
  31605. }
  31606. declare module BABYLON {
  31607. /**
  31608. * Options to modify the vr teleportation behavior.
  31609. */
  31610. interface VRTeleportationOptions {
  31611. /**
  31612. * The name of the mesh which should be used as the teleportation floor. (default: null)
  31613. */
  31614. floorMeshName?: string;
  31615. /**
  31616. * A list of meshes to be used as the teleportation floor. (default: empty)
  31617. */
  31618. floorMeshes?: Mesh[];
  31619. }
  31620. /**
  31621. * Options to modify the vr experience helper's behavior.
  31622. */
  31623. interface VRExperienceHelperOptions extends WebVROptions {
  31624. /**
  31625. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  31626. */
  31627. createDeviceOrientationCamera?: boolean;
  31628. /**
  31629. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  31630. */
  31631. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  31632. /**
  31633. * Uses the main button on the controller to toggle the laser casted. (default: true)
  31634. */
  31635. laserToggle?: boolean;
  31636. /**
  31637. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  31638. */
  31639. floorMeshes?: Mesh[];
  31640. }
  31641. /**
  31642. * Helps to quickly add VR support to an existing scene.
  31643. * See http://doc.babylonjs.com/how_to/webvr_helper
  31644. */
  31645. class VRExperienceHelper {
  31646. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  31647. private _scene;
  31648. private _position;
  31649. private _btnVR;
  31650. private _btnVRDisplayed;
  31651. private _webVRsupported;
  31652. private _webVRready;
  31653. private _webVRrequesting;
  31654. private _webVRpresenting;
  31655. private _fullscreenVRpresenting;
  31656. private _canvas;
  31657. private _webVRCamera;
  31658. private _vrDeviceOrientationCamera;
  31659. private _deviceOrientationCamera;
  31660. private _existingCamera;
  31661. private _onKeyDown;
  31662. private _onVrDisplayPresentChange;
  31663. private _onVRDisplayChanged;
  31664. private _onVRRequestPresentStart;
  31665. private _onVRRequestPresentComplete;
  31666. /**
  31667. * Observable raised when entering VR.
  31668. */
  31669. onEnteringVRObservable: Observable<VRExperienceHelper>;
  31670. /**
  31671. * Observable raised when exiting VR.
  31672. */
  31673. onExitingVRObservable: Observable<VRExperienceHelper>;
  31674. /**
  31675. * Observable raised when controller mesh is loaded.
  31676. */
  31677. onControllerMeshLoadedObservable: Observable<WebVRController>;
  31678. /** Return this.onEnteringVRObservable
  31679. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  31680. */
  31681. readonly onEnteringVR: Observable<VRExperienceHelper>;
  31682. /** Return this.onExitingVRObservable
  31683. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  31684. */
  31685. readonly onExitingVR: Observable<VRExperienceHelper>;
  31686. /** Return this.onControllerMeshLoadedObservable
  31687. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  31688. */
  31689. readonly onControllerMeshLoaded: Observable<WebVRController>;
  31690. private _rayLength;
  31691. private _useCustomVRButton;
  31692. private _teleportationRequested;
  31693. private _teleportActive;
  31694. private _floorMeshName;
  31695. private _floorMeshesCollection;
  31696. private _rotationAllowed;
  31697. private _teleportBackwardsVector;
  31698. private _teleportationTarget;
  31699. private _isDefaultTeleportationTarget;
  31700. private _postProcessMove;
  31701. private _teleportationFillColor;
  31702. private _teleportationBorderColor;
  31703. private _rotationAngle;
  31704. private _haloCenter;
  31705. private _cameraGazer;
  31706. private _padSensibilityUp;
  31707. private _padSensibilityDown;
  31708. private leftController;
  31709. private rightController;
  31710. /**
  31711. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  31712. */
  31713. onNewMeshSelected: Observable<AbstractMesh>;
  31714. /**
  31715. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  31716. */
  31717. onNewMeshPicked: Observable<PickingInfo>;
  31718. private _circleEase;
  31719. /**
  31720. * Observable raised before camera teleportation
  31721. */
  31722. onBeforeCameraTeleport: Observable<Vector3>;
  31723. /**
  31724. * Observable raised after camera teleportation
  31725. */
  31726. onAfterCameraTeleport: Observable<Vector3>;
  31727. /**
  31728. * Observable raised when current selected mesh gets unselected
  31729. */
  31730. onSelectedMeshUnselected: Observable<AbstractMesh>;
  31731. private _raySelectionPredicate;
  31732. /**
  31733. * To be optionaly changed by user to define custom ray selection
  31734. */
  31735. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  31736. /**
  31737. * To be optionaly changed by user to define custom selection logic (after ray selection)
  31738. */
  31739. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  31740. /**
  31741. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  31742. */
  31743. teleportationEnabled: boolean;
  31744. private _defaultHeight;
  31745. private _teleportationInitialized;
  31746. private _interactionsEnabled;
  31747. private _interactionsRequested;
  31748. private _displayGaze;
  31749. private _displayLaserPointer;
  31750. /**
  31751. * The mesh used to display where the user is going to teleport.
  31752. */
  31753. /**
  31754. * Sets the mesh to be used to display where the user is going to teleport.
  31755. */
  31756. teleportationTarget: Mesh;
  31757. /**
  31758. * The mesh used to display where the user is selecting,
  31759. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  31760. * See http://doc.babylonjs.com/resources/baking_transformations
  31761. */
  31762. gazeTrackerMesh: Mesh;
  31763. /**
  31764. * If the ray of the gaze should be displayed.
  31765. */
  31766. /**
  31767. * Sets if the ray of the gaze should be displayed.
  31768. */
  31769. displayGaze: boolean;
  31770. /**
  31771. * If the ray of the LaserPointer should be displayed.
  31772. */
  31773. /**
  31774. * Sets if the ray of the LaserPointer should be displayed.
  31775. */
  31776. displayLaserPointer: boolean;
  31777. /**
  31778. * The deviceOrientationCamera used as the camera when not in VR.
  31779. */
  31780. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  31781. /**
  31782. * Based on the current WebVR support, returns the current VR camera used.
  31783. */
  31784. readonly currentVRCamera: Nullable<Camera>;
  31785. /**
  31786. * The webVRCamera which is used when in VR.
  31787. */
  31788. readonly webVRCamera: WebVRFreeCamera;
  31789. /**
  31790. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  31791. */
  31792. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  31793. private readonly _teleportationRequestInitiated;
  31794. /**
  31795. * Instantiates a VRExperienceHelper.
  31796. * Helps to quickly add VR support to an existing scene.
  31797. * @param scene The scene the VRExperienceHelper belongs to.
  31798. * @param webVROptions Options to modify the vr experience helper's behavior.
  31799. */
  31800. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  31801. private _onDefaultMeshLoaded(webVRController);
  31802. private _onResize;
  31803. private _onFullscreenChange;
  31804. /**
  31805. * Gets a value indicating if we are currently in VR mode.
  31806. */
  31807. readonly isInVRMode: boolean;
  31808. private onVrDisplayPresentChange();
  31809. private onVRDisplayChanged(eventArgs);
  31810. private moveButtonToBottomRight();
  31811. private displayVRButton();
  31812. private updateButtonVisibility();
  31813. /**
  31814. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  31815. * Otherwise, will use the fullscreen API.
  31816. */
  31817. enterVR(): void;
  31818. /**
  31819. * Attempt to exit VR, or fullscreen.
  31820. */
  31821. exitVR(): void;
  31822. /**
  31823. * The position of the vr experience helper.
  31824. */
  31825. /**
  31826. * Sets the position of the vr experience helper.
  31827. */
  31828. position: Vector3;
  31829. /**
  31830. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  31831. */
  31832. enableInteractions(): void;
  31833. private readonly _noControllerIsActive;
  31834. private beforeRender;
  31835. private _isTeleportationFloor(mesh);
  31836. /**
  31837. * Adds a floor mesh to be used for teleportation.
  31838. * @param floorMesh the mesh to be used for teleportation.
  31839. */
  31840. addFloorMesh(floorMesh: Mesh): void;
  31841. /**
  31842. * Removes a floor mesh from being used for teleportation.
  31843. * @param floorMesh the mesh to be removed.
  31844. */
  31845. removeFloorMesh(floorMesh: Mesh): void;
  31846. /**
  31847. * Enables interactions and teleportation using the VR controllers and gaze.
  31848. * @param vrTeleportationOptions options to modify teleportation behavior.
  31849. */
  31850. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  31851. private _onNewGamepadConnected;
  31852. private _tryEnableInteractionOnController;
  31853. private _onNewGamepadDisconnected;
  31854. private _enableInteractionOnController(controller);
  31855. private _checkTeleportWithRay(stateObject, gazer);
  31856. private _checkRotate(stateObject, gazer);
  31857. private _checkTeleportBackwards(stateObject, gazer);
  31858. private _enableTeleportationOnController(controller);
  31859. private _createTeleportationCircles();
  31860. private _displayTeleportationTarget();
  31861. private _hideTeleportationTarget();
  31862. private _rotateCamera(right);
  31863. private _moveTeleportationSelectorTo(hit, gazer, ray);
  31864. private _workingVector;
  31865. private _workingQuaternion;
  31866. private _workingMatrix;
  31867. private _teleportCamera(location);
  31868. private _convertNormalToDirectionOfRay(normal, ray);
  31869. private _castRayAndSelectObject(gazer);
  31870. private _notifySelectedMeshUnselected(mesh);
  31871. /**
  31872. * Sets the color of the laser ray from the vr controllers.
  31873. * @param color new color for the ray.
  31874. */
  31875. changeLaserColor(color: Color3): void;
  31876. /**
  31877. * Sets the color of the ray from the vr headsets gaze.
  31878. * @param color new color for the ray.
  31879. */
  31880. changeGazeColor(color: Color3): void;
  31881. /**
  31882. * Exits VR and disposes of the vr experience helper
  31883. */
  31884. dispose(): void;
  31885. /**
  31886. * Gets the name of the VRExperienceHelper class
  31887. * @returns "VRExperienceHelper"
  31888. */
  31889. getClassName(): string;
  31890. }
  31891. }
  31892. declare module BABYLON {
  31893. /**
  31894. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  31895. * IMPORTANT!! The data is right-hand data.
  31896. * @export
  31897. * @interface DevicePose
  31898. */
  31899. interface DevicePose {
  31900. /**
  31901. * The position of the device, values in array are [x,y,z].
  31902. */
  31903. readonly position: Nullable<Float32Array>;
  31904. /**
  31905. * The linearVelocity of the device, values in array are [x,y,z].
  31906. */
  31907. readonly linearVelocity: Nullable<Float32Array>;
  31908. /**
  31909. * The linearAcceleration of the device, values in array are [x,y,z].
  31910. */
  31911. readonly linearAcceleration: Nullable<Float32Array>;
  31912. /**
  31913. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  31914. */
  31915. readonly orientation: Nullable<Float32Array>;
  31916. /**
  31917. * The angularVelocity of the device, values in array are [x,y,z].
  31918. */
  31919. readonly angularVelocity: Nullable<Float32Array>;
  31920. /**
  31921. * The angularAcceleration of the device, values in array are [x,y,z].
  31922. */
  31923. readonly angularAcceleration: Nullable<Float32Array>;
  31924. }
  31925. /**
  31926. * Interface representing a pose controlled object in Babylon.
  31927. * A pose controlled object has both regular pose values as well as pose values
  31928. * from an external device such as a VR head mounted display
  31929. */
  31930. interface PoseControlled {
  31931. /**
  31932. * The position of the object in babylon space.
  31933. */
  31934. position: Vector3;
  31935. /**
  31936. * The rotation quaternion of the object in babylon space.
  31937. */
  31938. rotationQuaternion: Quaternion;
  31939. /**
  31940. * The position of the device in babylon space.
  31941. */
  31942. devicePosition?: Vector3;
  31943. /**
  31944. * The rotation quaternion of the device in babylon space.
  31945. */
  31946. deviceRotationQuaternion: Quaternion;
  31947. /**
  31948. * The raw pose coming from the device.
  31949. */
  31950. rawPose: Nullable<DevicePose>;
  31951. /**
  31952. * The scale of the device to be used when translating from device space to babylon space.
  31953. */
  31954. deviceScaleFactor: number;
  31955. /**
  31956. * Updates the poseControlled values based on the input device pose.
  31957. * @param poseData the pose data to update the object with
  31958. */
  31959. updateFromDevice(poseData: DevicePose): void;
  31960. }
  31961. /**
  31962. * Set of options to customize the webVRCamera
  31963. */
  31964. interface WebVROptions {
  31965. /**
  31966. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  31967. */
  31968. trackPosition?: boolean;
  31969. /**
  31970. * Sets the scale of the vrDevice in babylon space. (default: 1)
  31971. */
  31972. positionScale?: number;
  31973. /**
  31974. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  31975. */
  31976. displayName?: string;
  31977. /**
  31978. * Should the native controller meshes be initialized. (default: true)
  31979. */
  31980. controllerMeshes?: boolean;
  31981. /**
  31982. * Creating a default HemiLight only on controllers. (default: true)
  31983. */
  31984. defaultLightingOnControllers?: boolean;
  31985. /**
  31986. * If you don't want to use the default VR button of the helper. (default: false)
  31987. */
  31988. useCustomVRButton?: boolean;
  31989. /**
  31990. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  31991. */
  31992. customVRButton?: HTMLButtonElement;
  31993. /**
  31994. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  31995. */
  31996. rayLength?: number;
  31997. /**
  31998. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  31999. */
  32000. defaultHeight?: number;
  32001. }
  32002. /**
  32003. * This represents a WebVR camera.
  32004. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32005. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32006. */
  32007. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32008. private webVROptions;
  32009. /**
  32010. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32011. */
  32012. _vrDevice: any;
  32013. /**
  32014. * The rawPose of the vrDevice.
  32015. */
  32016. rawPose: Nullable<DevicePose>;
  32017. private _onVREnabled;
  32018. private _specsVersion;
  32019. private _attached;
  32020. private _frameData;
  32021. protected _descendants: Array<Node>;
  32022. private _deviceRoomPosition;
  32023. private _deviceRoomRotationQuaternion;
  32024. private _standingMatrix;
  32025. /**
  32026. * Represents device position in babylon space.
  32027. */
  32028. devicePosition: Vector3;
  32029. /**
  32030. * Represents device rotation in babylon space.
  32031. */
  32032. deviceRotationQuaternion: Quaternion;
  32033. /**
  32034. * The scale of the device to be used when translating from device space to babylon space.
  32035. */
  32036. deviceScaleFactor: number;
  32037. private _deviceToWorld;
  32038. private _worldToDevice;
  32039. /**
  32040. * References to the webVR controllers for the vrDevice.
  32041. */
  32042. controllers: Array<WebVRController>;
  32043. /**
  32044. * Emits an event when a controller is attached.
  32045. */
  32046. onControllersAttachedObservable: Observable<WebVRController[]>;
  32047. /**
  32048. * Emits an event when a controller's mesh has been loaded;
  32049. */
  32050. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32051. /**
  32052. * If the rig cameras be used as parent instead of this camera.
  32053. */
  32054. rigParenting: boolean;
  32055. private _lightOnControllers;
  32056. private _defaultHeight?;
  32057. /**
  32058. * Instantiates a WebVRFreeCamera.
  32059. * @param name The name of the WebVRFreeCamera
  32060. * @param position The starting anchor position for the camera
  32061. * @param scene The scene the camera belongs to
  32062. * @param webVROptions a set of customizable options for the webVRCamera
  32063. */
  32064. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  32065. /**
  32066. * Gets the device distance from the ground in meters.
  32067. * @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.
  32068. */
  32069. deviceDistanceToRoomGround(): number;
  32070. /**
  32071. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32072. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  32073. */
  32074. useStandingMatrix(callback?: (bool: boolean) => void): void;
  32075. /**
  32076. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32077. * @returns A promise with a boolean set to if the standing matrix is supported.
  32078. */
  32079. useStandingMatrixAsync(): Promise<boolean>;
  32080. /**
  32081. * Disposes the camera
  32082. */
  32083. dispose(): void;
  32084. /**
  32085. * Gets a vrController by name.
  32086. * @param name The name of the controller to retreive
  32087. * @returns the controller matching the name specified or null if not found
  32088. */
  32089. getControllerByName(name: string): Nullable<WebVRController>;
  32090. private _leftController;
  32091. /**
  32092. * The controller corrisponding to the users left hand.
  32093. */
  32094. readonly leftController: Nullable<WebVRController>;
  32095. private _rightController;
  32096. /**
  32097. * The controller corrisponding to the users right hand.
  32098. */
  32099. readonly rightController: Nullable<WebVRController>;
  32100. /**
  32101. * Casts a ray forward from the vrCamera's gaze.
  32102. * @param length Length of the ray (default: 100)
  32103. * @returns the ray corrisponding to the gaze
  32104. */
  32105. getForwardRay(length?: number): Ray;
  32106. /**
  32107. * Updates the camera based on device's frame data
  32108. */
  32109. _checkInputs(): void;
  32110. /**
  32111. * Updates the poseControlled values based on the input device pose.
  32112. * @param poseData Pose coming from the device
  32113. */
  32114. updateFromDevice(poseData: DevicePose): void;
  32115. /**
  32116. * WebVR's attach control will start broadcasting frames to the device.
  32117. * Note that in certain browsers (chrome for example) this function must be called
  32118. * within a user-interaction callback. Example:
  32119. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  32120. *
  32121. * @param element html element to attach the vrDevice to
  32122. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  32123. */
  32124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32125. /**
  32126. * Detaches the camera from the html element and disables VR
  32127. *
  32128. * @param element html element to detach from
  32129. */
  32130. detachControl(element: HTMLElement): void;
  32131. /**
  32132. * @returns the name of this class
  32133. */
  32134. getClassName(): string;
  32135. /**
  32136. * Calls resetPose on the vrDisplay
  32137. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  32138. */
  32139. resetToCurrentRotation(): void;
  32140. /**
  32141. * Updates the rig cameras (left and right eye)
  32142. */
  32143. _updateRigCameras(): void;
  32144. private _workingVector;
  32145. private _oneVector;
  32146. private _workingMatrix;
  32147. private updateCacheCalled;
  32148. /**
  32149. * Updates the cached values of the camera
  32150. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  32151. */
  32152. _updateCache(ignoreParentClass?: boolean): void;
  32153. /**
  32154. * Updates the current device position and rotation in the babylon world
  32155. */
  32156. update(): void;
  32157. /**
  32158. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  32159. * @returns an identity matrix
  32160. */
  32161. _getViewMatrix(): Matrix;
  32162. /**
  32163. * This function is called by the two RIG cameras.
  32164. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  32165. */
  32166. protected _getWebVRViewMatrix(): Matrix;
  32167. protected _getWebVRProjectionMatrix(): Matrix;
  32168. private _onGamepadConnectedObserver;
  32169. private _onGamepadDisconnectedObserver;
  32170. /**
  32171. * Initializes the controllers and their meshes
  32172. */
  32173. initControllers(): void;
  32174. }
  32175. }
  32176. declare module BABYLON {
  32177. interface IOctreeContainer<T> {
  32178. blocks: Array<OctreeBlock<T>>;
  32179. }
  32180. class Octree<T> {
  32181. maxDepth: number;
  32182. blocks: Array<OctreeBlock<T>>;
  32183. dynamicContent: T[];
  32184. private _maxBlockCapacity;
  32185. private _selectionContent;
  32186. private _creationFunc;
  32187. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  32188. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  32189. addMesh(entry: T): void;
  32190. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  32191. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  32192. intersectsRay(ray: Ray): SmartArray<T>;
  32193. 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;
  32194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  32195. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  32196. }
  32197. }
  32198. declare module BABYLON {
  32199. class OctreeBlock<T> {
  32200. entries: T[];
  32201. blocks: Array<OctreeBlock<T>>;
  32202. private _depth;
  32203. private _maxDepth;
  32204. private _capacity;
  32205. private _minPoint;
  32206. private _maxPoint;
  32207. private _boundingVectors;
  32208. private _creationFunc;
  32209. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  32210. readonly capacity: number;
  32211. readonly minPoint: Vector3;
  32212. readonly maxPoint: Vector3;
  32213. addEntry(entry: T): void;
  32214. addEntries(entries: T[]): void;
  32215. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32216. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  32217. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  32218. createInnerBlocks(): void;
  32219. }
  32220. }
  32221. declare module BABYLON {
  32222. /**
  32223. * Google Daydream controller
  32224. */
  32225. class DaydreamController extends WebVRController {
  32226. /**
  32227. * Base Url for the controller model.
  32228. */
  32229. static MODEL_BASE_URL: string;
  32230. /**
  32231. * File name for the controller model.
  32232. */
  32233. static MODEL_FILENAME: string;
  32234. /**
  32235. * Gamepad Id prefix used to identify Daydream Controller.
  32236. */
  32237. static readonly GAMEPAD_ID_PREFIX: string;
  32238. /**
  32239. * Creates a new DaydreamController from a gamepad
  32240. * @param vrGamepad the gamepad that the controller should be created from
  32241. */
  32242. constructor(vrGamepad: any);
  32243. /**
  32244. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32245. * @param scene scene in which to add meshes
  32246. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32247. */
  32248. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32249. /**
  32250. * Called once for each button that changed state since the last frame
  32251. * @param buttonIdx Which button index changed
  32252. * @param state New state of the button
  32253. * @param changes Which properties on the state changed since last frame
  32254. */
  32255. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32256. }
  32257. }
  32258. declare module BABYLON {
  32259. /**
  32260. * Gear VR Controller
  32261. */
  32262. class GearVRController extends WebVRController {
  32263. /**
  32264. * Base Url for the controller model.
  32265. */
  32266. static MODEL_BASE_URL: string;
  32267. /**
  32268. * File name for the controller model.
  32269. */
  32270. static MODEL_FILENAME: string;
  32271. /**
  32272. * Gamepad Id prefix used to identify this controller.
  32273. */
  32274. static readonly GAMEPAD_ID_PREFIX: string;
  32275. private readonly _buttonIndexToObservableNameMap;
  32276. /**
  32277. * Creates a new GearVRController from a gamepad
  32278. * @param vrGamepad the gamepad that the controller should be created from
  32279. */
  32280. constructor(vrGamepad: any);
  32281. /**
  32282. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32283. * @param scene scene in which to add meshes
  32284. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32285. */
  32286. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32287. /**
  32288. * Called once for each button that changed state since the last frame
  32289. * @param buttonIdx Which button index changed
  32290. * @param state New state of the button
  32291. * @param changes Which properties on the state changed since last frame
  32292. */
  32293. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32294. }
  32295. }
  32296. declare module BABYLON {
  32297. /**
  32298. * Generic Controller
  32299. */
  32300. class GenericController extends WebVRController {
  32301. /**
  32302. * Base Url for the controller model.
  32303. */
  32304. static readonly MODEL_BASE_URL: string;
  32305. /**
  32306. * File name for the controller model.
  32307. */
  32308. static readonly MODEL_FILENAME: string;
  32309. /**
  32310. * Creates a new GenericController from a gamepad
  32311. * @param vrGamepad the gamepad that the controller should be created from
  32312. */
  32313. constructor(vrGamepad: any);
  32314. /**
  32315. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32316. * @param scene scene in which to add meshes
  32317. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32318. */
  32319. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32320. /**
  32321. * Called once for each button that changed state since the last frame
  32322. * @param buttonIdx Which button index changed
  32323. * @param state New state of the button
  32324. * @param changes Which properties on the state changed since last frame
  32325. */
  32326. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32327. }
  32328. }
  32329. declare module BABYLON {
  32330. /**
  32331. * Oculus Touch Controller
  32332. */
  32333. class OculusTouchController extends WebVRController {
  32334. /**
  32335. * Base Url for the controller model.
  32336. */
  32337. static MODEL_BASE_URL: string;
  32338. /**
  32339. * File name for the left controller model.
  32340. */
  32341. static MODEL_LEFT_FILENAME: string;
  32342. /**
  32343. * File name for the right controller model.
  32344. */
  32345. static MODEL_RIGHT_FILENAME: string;
  32346. /**
  32347. * Fired when the secondary trigger on this controller is modified
  32348. */
  32349. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32350. /**
  32351. * Fired when the thumb rest on this controller is modified
  32352. */
  32353. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  32354. /**
  32355. * Creates a new OculusTouchController from a gamepad
  32356. * @param vrGamepad the gamepad that the controller should be created from
  32357. */
  32358. constructor(vrGamepad: any);
  32359. /**
  32360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32361. * @param scene scene in which to add meshes
  32362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32363. */
  32364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32365. /**
  32366. * Fired when the A button on this controller is modified
  32367. */
  32368. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32369. /**
  32370. * Fired when the B button on this controller is modified
  32371. */
  32372. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32373. /**
  32374. * Fired when the X button on this controller is modified
  32375. */
  32376. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32377. /**
  32378. * Fired when the Y button on this controller is modified
  32379. */
  32380. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32381. /**
  32382. * Called once for each button that changed state since the last frame
  32383. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  32384. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  32385. * 2) secondary trigger (same)
  32386. * 3) A (right) X (left), touch, pressed = value
  32387. * 4) B / Y
  32388. * 5) thumb rest
  32389. * @param buttonIdx Which button index changed
  32390. * @param state New state of the button
  32391. * @param changes Which properties on the state changed since last frame
  32392. */
  32393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32394. }
  32395. }
  32396. declare module BABYLON {
  32397. /**
  32398. * Defines the types of pose enabled controllers that are supported
  32399. */
  32400. enum PoseEnabledControllerType {
  32401. /**
  32402. * HTC Vive
  32403. */
  32404. VIVE = 0,
  32405. /**
  32406. * Oculus Rift
  32407. */
  32408. OCULUS = 1,
  32409. /**
  32410. * Windows mixed reality
  32411. */
  32412. WINDOWS = 2,
  32413. /**
  32414. * Samsung gear VR
  32415. */
  32416. GEAR_VR = 3,
  32417. /**
  32418. * Google Daydream
  32419. */
  32420. DAYDREAM = 4,
  32421. /**
  32422. * Generic
  32423. */
  32424. GENERIC = 5,
  32425. }
  32426. /**
  32427. * Defines the MutableGamepadButton interface for the state of a gamepad button
  32428. */
  32429. interface MutableGamepadButton {
  32430. /**
  32431. * Value of the button/trigger
  32432. */
  32433. value: number;
  32434. /**
  32435. * If the button/trigger is currently touched
  32436. */
  32437. touched: boolean;
  32438. /**
  32439. * If the button/trigger is currently pressed
  32440. */
  32441. pressed: boolean;
  32442. }
  32443. /**
  32444. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  32445. * @hidden
  32446. */
  32447. interface ExtendedGamepadButton extends GamepadButton {
  32448. /**
  32449. * If the button/trigger is currently pressed
  32450. */
  32451. readonly pressed: boolean;
  32452. /**
  32453. * If the button/trigger is currently touched
  32454. */
  32455. readonly touched: boolean;
  32456. /**
  32457. * Value of the button/trigger
  32458. */
  32459. readonly value: number;
  32460. }
  32461. /**
  32462. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32463. */
  32464. class PoseEnabledControllerHelper {
  32465. /**
  32466. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  32467. * @param vrGamepad the gamepad to initialized
  32468. * @returns a vr controller of the type the gamepad identified as
  32469. */
  32470. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  32471. }
  32472. /**
  32473. * Defines the PoseEnabledController object that contains state of a vr capable controller
  32474. */
  32475. class PoseEnabledController extends Gamepad implements PoseControlled {
  32476. private _deviceRoomPosition;
  32477. private _deviceRoomRotationQuaternion;
  32478. /**
  32479. * The device position in babylon space
  32480. */
  32481. devicePosition: Vector3;
  32482. /**
  32483. * The device rotation in babylon space
  32484. */
  32485. deviceRotationQuaternion: Quaternion;
  32486. /**
  32487. * The scale factor of the device in babylon space
  32488. */
  32489. deviceScaleFactor: number;
  32490. /**
  32491. * (Likely devicePosition should be used instead) The device position in its room space
  32492. */
  32493. position: Vector3;
  32494. /**
  32495. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  32496. */
  32497. rotationQuaternion: Quaternion;
  32498. /**
  32499. * The type of controller (Eg. Windows mixed reality)
  32500. */
  32501. controllerType: PoseEnabledControllerType;
  32502. protected _calculatedPosition: Vector3;
  32503. private _calculatedRotation;
  32504. /**
  32505. * The raw pose from the device
  32506. */
  32507. rawPose: DevicePose;
  32508. /**
  32509. * Internal, the mesh attached to the controller
  32510. */
  32511. _mesh: Nullable<AbstractMesh>;
  32512. private _poseControlledCamera;
  32513. private _leftHandSystemQuaternion;
  32514. /**
  32515. * Internal, matrix used to convert room space to babylon space
  32516. */
  32517. _deviceToWorld: Matrix;
  32518. /**
  32519. * Node to be used when casting a ray from the controller
  32520. */
  32521. _pointingPoseNode: Nullable<AbstractMesh>;
  32522. /**
  32523. * Name of the child mesh that can be used to cast a ray from the controller
  32524. */
  32525. static readonly POINTING_POSE: string;
  32526. /**
  32527. * Creates a new PoseEnabledController from a gamepad
  32528. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  32529. */
  32530. constructor(browserGamepad: any);
  32531. private _workingMatrix;
  32532. /**
  32533. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  32534. */
  32535. update(): void;
  32536. /**
  32537. * Updates only the pose device and mesh without doing any button event checking
  32538. */
  32539. protected _updatePoseAndMesh(): void;
  32540. /**
  32541. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32542. * @param poseData raw pose fromthe device
  32543. */
  32544. updateFromDevice(poseData: DevicePose): void;
  32545. /**
  32546. * @hidden
  32547. */
  32548. _meshAttachedObservable: Observable<AbstractMesh>;
  32549. /**
  32550. * Attaches a mesh to the controller
  32551. * @param mesh the mesh to be attached
  32552. */
  32553. attachToMesh(mesh: AbstractMesh): void;
  32554. /**
  32555. * Attaches the controllers mesh to a camera
  32556. * @param camera the camera the mesh should be attached to
  32557. */
  32558. attachToPoseControlledCamera(camera: TargetCamera): void;
  32559. /**
  32560. * Disposes of the controller
  32561. */
  32562. dispose(): void;
  32563. /**
  32564. * The mesh that is attached to the controller
  32565. */
  32566. readonly mesh: Nullable<AbstractMesh>;
  32567. /**
  32568. * Gets the ray of the controller in the direction the controller is pointing
  32569. * @param length the length the resulting ray should be
  32570. * @returns a ray in the direction the controller is pointing
  32571. */
  32572. getForwardRay(length?: number): Ray;
  32573. }
  32574. }
  32575. declare module BABYLON {
  32576. /**
  32577. * Vive Controller
  32578. */
  32579. class ViveController extends WebVRController {
  32580. /**
  32581. * Base Url for the controller model.
  32582. */
  32583. static MODEL_BASE_URL: string;
  32584. /**
  32585. * File name for the controller model.
  32586. */
  32587. static MODEL_FILENAME: string;
  32588. /**
  32589. * Creates a new ViveController from a gamepad
  32590. * @param vrGamepad the gamepad that the controller should be created from
  32591. */
  32592. constructor(vrGamepad: any);
  32593. /**
  32594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32595. * @param scene scene in which to add meshes
  32596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32597. */
  32598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32599. /**
  32600. * Fired when the left button on this controller is modified
  32601. */
  32602. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32603. /**
  32604. * Fired when the right button on this controller is modified
  32605. */
  32606. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32607. /**
  32608. * Fired when the menu button on this controller is modified
  32609. */
  32610. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32611. /**
  32612. * Called once for each button that changed state since the last frame
  32613. * Vive mapping:
  32614. * 0: touchpad
  32615. * 1: trigger
  32616. * 2: left AND right buttons
  32617. * 3: menu button
  32618. * @param buttonIdx Which button index changed
  32619. * @param state New state of the button
  32620. * @param changes Which properties on the state changed since last frame
  32621. */
  32622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32623. }
  32624. }
  32625. declare module BABYLON {
  32626. /**
  32627. * Defines the WebVRController object that represents controllers tracked in 3D space
  32628. */
  32629. abstract class WebVRController extends PoseEnabledController {
  32630. /**
  32631. * Internal, the default controller model for the controller
  32632. */
  32633. protected _defaultModel: AbstractMesh;
  32634. /**
  32635. * Fired when the trigger state has changed
  32636. */
  32637. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32638. /**
  32639. * Fired when the main button state has changed
  32640. */
  32641. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32642. /**
  32643. * Fired when the secondary button state has changed
  32644. */
  32645. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32646. /**
  32647. * Fired when the pad state has changed
  32648. */
  32649. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  32650. /**
  32651. * Fired when controllers stick values have changed
  32652. */
  32653. onPadValuesChangedObservable: Observable<StickValues>;
  32654. /**
  32655. * Array of button availible on the controller
  32656. */
  32657. protected _buttons: Array<MutableGamepadButton>;
  32658. private _onButtonStateChange;
  32659. /**
  32660. * Fired when a controller button's state has changed
  32661. * @param callback the callback containing the button that was modified
  32662. */
  32663. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  32664. /**
  32665. * X and Y axis corrisponding to the controllers joystick
  32666. */
  32667. pad: StickValues;
  32668. /**
  32669. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  32670. */
  32671. hand: string;
  32672. /**
  32673. * The default controller model for the controller
  32674. */
  32675. readonly defaultModel: AbstractMesh;
  32676. /**
  32677. * Creates a new WebVRController from a gamepad
  32678. * @param vrGamepad the gamepad that the WebVRController should be created from
  32679. */
  32680. constructor(vrGamepad: any);
  32681. /**
  32682. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  32683. */
  32684. update(): void;
  32685. /**
  32686. * Function to be called when a button is modified
  32687. */
  32688. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32689. /**
  32690. * Loads a mesh and attaches it to the controller
  32691. * @param scene the scene the mesh should be added to
  32692. * @param meshLoaded callback for when the mesh has been loaded
  32693. */
  32694. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32695. private _setButtonValue(newState, currentState, buttonIndex);
  32696. private _changes;
  32697. private _checkChanges(newState, currentState);
  32698. /**
  32699. * Disposes of th webVRCOntroller
  32700. */
  32701. dispose(): void;
  32702. }
  32703. }
  32704. declare module BABYLON {
  32705. /**
  32706. * Defines the WindowsMotionController object that the state of the windows motion controller
  32707. */
  32708. class WindowsMotionController extends WebVRController {
  32709. /**
  32710. * The base url used to load the left and right controller models
  32711. */
  32712. static MODEL_BASE_URL: string;
  32713. /**
  32714. * The name of the left controller model file
  32715. */
  32716. static MODEL_LEFT_FILENAME: string;
  32717. /**
  32718. * The name of the right controller model file
  32719. */
  32720. static MODEL_RIGHT_FILENAME: string;
  32721. /**
  32722. * The controller name prefix for this controller type
  32723. */
  32724. static readonly GAMEPAD_ID_PREFIX: string;
  32725. /**
  32726. * The controller id pattern for this controller type
  32727. */
  32728. private static readonly GAMEPAD_ID_PATTERN;
  32729. private _loadedMeshInfo;
  32730. private readonly _mapping;
  32731. /**
  32732. * Fired when the trackpad on this controller is clicked
  32733. */
  32734. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  32735. /**
  32736. * Fired when the trackpad on this controller is modified
  32737. */
  32738. onTrackpadValuesChangedObservable: Observable<StickValues>;
  32739. /**
  32740. * The current x and y values of this controller's trackpad
  32741. */
  32742. trackpad: StickValues;
  32743. /**
  32744. * Creates a new WindowsMotionController from a gamepad
  32745. * @param vrGamepad the gamepad that the controller should be created from
  32746. */
  32747. constructor(vrGamepad: any);
  32748. /**
  32749. * Fired when the trigger on this controller is modified
  32750. */
  32751. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32752. /**
  32753. * Fired when the menu button on this controller is modified
  32754. */
  32755. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32756. /**
  32757. * Fired when the grip button on this controller is modified
  32758. */
  32759. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32760. /**
  32761. * Fired when the thumbstick button on this controller is modified
  32762. */
  32763. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32764. /**
  32765. * Fired when the touchpad button on this controller is modified
  32766. */
  32767. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32768. /**
  32769. * Fired when the touchpad values on this controller are modified
  32770. */
  32771. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  32772. private _updateTrackpad();
  32773. /**
  32774. * Called once per frame by the engine.
  32775. */
  32776. update(): void;
  32777. /**
  32778. * Called once for each button that changed state since the last frame
  32779. * @param buttonIdx Which button index changed
  32780. * @param state New state of the button
  32781. * @param changes Which properties on the state changed since last frame
  32782. */
  32783. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32784. /**
  32785. * Moves the buttons on the controller mesh based on their current state
  32786. * @param buttonName the name of the button to move
  32787. * @param buttonValue the value of the button which determines the buttons new position
  32788. */
  32789. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  32790. /**
  32791. * Moves the axis on the controller mesh based on its current state
  32792. * @param axis the index of the axis
  32793. * @param axisValue the value of the axis which determines the meshes new position
  32794. * @hidden
  32795. */
  32796. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  32797. /**
  32798. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32799. * @param scene scene in which to add meshes
  32800. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32801. */
  32802. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  32803. /**
  32804. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  32805. * can be transformed by button presses and axes values, based on this._mapping.
  32806. *
  32807. * @param scene scene in which the meshes exist
  32808. * @param meshes list of meshes that make up the controller model to process
  32809. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  32810. */
  32811. private processModel(scene, meshes);
  32812. private createMeshInfo(rootNode);
  32813. /**
  32814. * Gets the ray of the controller in the direction the controller is pointing
  32815. * @param length the length the resulting ray should be
  32816. * @returns a ray in the direction the controller is pointing
  32817. */
  32818. getForwardRay(length?: number): Ray;
  32819. /**
  32820. * Disposes of the controller
  32821. */
  32822. dispose(): void;
  32823. }
  32824. }
  32825. declare module BABYLON {
  32826. /**
  32827. * Interface to implement to create a shadow generator compatible with BJS.
  32828. */
  32829. interface IShadowGenerator {
  32830. /**
  32831. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  32832. * @returns The render target texture if present otherwise, null
  32833. */
  32834. getShadowMap(): Nullable<RenderTargetTexture>;
  32835. /**
  32836. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  32837. * @returns The render target texture if the shadow map is present otherwise, null
  32838. */
  32839. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  32840. /**
  32841. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  32842. * @param subMesh The submesh we want to render in the shadow map
  32843. * @param useInstances Defines wether will draw in the map using instances
  32844. * @returns true if ready otherwise, false
  32845. */
  32846. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  32847. /**
  32848. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  32849. * @param defines Defines of the material we want to update
  32850. * @param lightIndex Index of the light in the enabled light list of the material
  32851. */
  32852. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  32853. /**
  32854. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  32855. * defined in the generator but impacting the effect).
  32856. * It implies the unifroms available on the materials are the standard BJS ones.
  32857. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  32858. * @param effect The effect we are binfing the information for
  32859. */
  32860. bindShadowLight(lightIndex: string, effect: Effect): void;
  32861. /**
  32862. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  32863. * (eq to shadow prjection matrix * light transform matrix)
  32864. * @returns The transform matrix used to create the shadow map
  32865. */
  32866. getTransformMatrix(): Matrix;
  32867. /**
  32868. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  32869. * Cube and 2D textures for instance.
  32870. */
  32871. recreateShadowMap(): void;
  32872. /**
  32873. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32874. * @param onCompiled Callback triggered at the and of the effects compilation
  32875. * @param options Sets of optional options forcing the compilation with different modes
  32876. */
  32877. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  32878. useInstances: boolean;
  32879. }>): void;
  32880. /**
  32881. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  32882. * @param options Sets of optional options forcing the compilation with different modes
  32883. * @returns A promise that resolves when the compilation completes
  32884. */
  32885. forceCompilationAsync(options?: Partial<{
  32886. useInstances: boolean;
  32887. }>): Promise<void>;
  32888. /**
  32889. * Serializes the shadow generator setup to a json object.
  32890. * @returns The serialized JSON object
  32891. */
  32892. serialize(): any;
  32893. /**
  32894. * Disposes the Shadow map and related Textures and effects.
  32895. */
  32896. dispose(): void;
  32897. }
  32898. /**
  32899. * Default implementation IShadowGenerator.
  32900. * This is the main object responsible of generating shadows in the framework.
  32901. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  32902. */
  32903. class ShadowGenerator implements IShadowGenerator {
  32904. /**
  32905. * Shadow generator mode None: no filtering applied.
  32906. */
  32907. static readonly FILTER_NONE: number;
  32908. /**
  32909. * Shadow generator mode ESM: Exponential Shadow Mapping.
  32910. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32911. */
  32912. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  32913. /**
  32914. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  32915. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  32916. */
  32917. static readonly FILTER_POISSONSAMPLING: number;
  32918. /**
  32919. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  32920. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32921. */
  32922. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  32923. /**
  32924. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  32925. * edge artifacts on steep falloff.
  32926. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32927. */
  32928. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  32929. /**
  32930. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  32931. * edge artifacts on steep falloff.
  32932. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  32933. */
  32934. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  32935. /**
  32936. * Shadow generator mode PCF: Percentage Closer Filtering
  32937. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32938. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  32939. */
  32940. static readonly FILTER_PCF: number;
  32941. /**
  32942. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  32943. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  32944. * Contact Hardening
  32945. */
  32946. static readonly FILTER_PCSS: number;
  32947. /**
  32948. * Reserved for PCF and PCSS
  32949. * Highest Quality.
  32950. *
  32951. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  32952. *
  32953. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  32954. */
  32955. static readonly QUALITY_HIGH: number;
  32956. /**
  32957. * Reserved for PCF and PCSS
  32958. * Good tradeoff for quality/perf cross devices
  32959. *
  32960. * Execute PCF on a 3*3 kernel.
  32961. *
  32962. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  32963. */
  32964. static readonly QUALITY_MEDIUM: number;
  32965. /**
  32966. * Reserved for PCF and PCSS
  32967. * The lowest quality but the fastest.
  32968. *
  32969. * Execute PCF on a 1*1 kernel.
  32970. *
  32971. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  32972. */
  32973. static readonly QUALITY_LOW: number;
  32974. private _bias;
  32975. /**
  32976. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  32977. */
  32978. /**
  32979. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  32980. */
  32981. bias: number;
  32982. private _normalBias;
  32983. /**
  32984. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32985. */
  32986. /**
  32987. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  32988. */
  32989. normalBias: number;
  32990. private _blurBoxOffset;
  32991. /**
  32992. * Gets the blur box offset: offset applied during the blur pass.
  32993. * Only usefull if useKernelBlur = false
  32994. */
  32995. /**
  32996. * Sets the blur box offset: offset applied during the blur pass.
  32997. * Only usefull if useKernelBlur = false
  32998. */
  32999. blurBoxOffset: number;
  33000. private _blurScale;
  33001. /**
  33002. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  33003. * 2 means half of the size.
  33004. */
  33005. /**
  33006. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  33007. * 2 means half of the size.
  33008. */
  33009. blurScale: number;
  33010. private _blurKernel;
  33011. /**
  33012. * Gets the blur kernel: kernel size of the blur pass.
  33013. * Only usefull if useKernelBlur = true
  33014. */
  33015. /**
  33016. * Sets the blur kernel: kernel size of the blur pass.
  33017. * Only usefull if useKernelBlur = true
  33018. */
  33019. blurKernel: number;
  33020. private _useKernelBlur;
  33021. /**
  33022. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  33023. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33024. */
  33025. /**
  33026. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  33027. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33028. */
  33029. useKernelBlur: boolean;
  33030. private _depthScale;
  33031. /**
  33032. * Gets the depth scale used in ESM mode.
  33033. */
  33034. /**
  33035. * Sets the depth scale used in ESM mode.
  33036. * This can override the scale stored on the light.
  33037. */
  33038. depthScale: number;
  33039. private _filter;
  33040. /**
  33041. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  33042. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33043. */
  33044. /**
  33045. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  33046. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33047. */
  33048. filter: number;
  33049. /**
  33050. * Gets if the current filter is set to Poisson Sampling.
  33051. */
  33052. /**
  33053. * Sets the current filter to Poisson Sampling.
  33054. */
  33055. usePoissonSampling: boolean;
  33056. /**
  33057. * Gets if the current filter is set to VSM.
  33058. * DEPRECATED. Should use useExponentialShadowMap instead.
  33059. */
  33060. /**
  33061. * Sets the current filter is to VSM.
  33062. * DEPRECATED. Should use useExponentialShadowMap instead.
  33063. */
  33064. useVarianceShadowMap: boolean;
  33065. /**
  33066. * Gets if the current filter is set to blurred VSM.
  33067. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33068. */
  33069. /**
  33070. * Sets the current filter is to blurred VSM.
  33071. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33072. */
  33073. useBlurVarianceShadowMap: boolean;
  33074. /**
  33075. * Gets if the current filter is set to ESM.
  33076. */
  33077. /**
  33078. * Sets the current filter is to ESM.
  33079. */
  33080. useExponentialShadowMap: boolean;
  33081. /**
  33082. * Gets if the current filter is set to filtered ESM.
  33083. */
  33084. /**
  33085. * Gets if the current filter is set to filtered ESM.
  33086. */
  33087. useBlurExponentialShadowMap: boolean;
  33088. /**
  33089. * Gets if the current filter is set to "close ESM" (using the inverse of the
  33090. * exponential to prevent steep falloff artifacts).
  33091. */
  33092. /**
  33093. * Sets the current filter to "close ESM" (using the inverse of the
  33094. * exponential to prevent steep falloff artifacts).
  33095. */
  33096. useCloseExponentialShadowMap: boolean;
  33097. /**
  33098. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  33099. * exponential to prevent steep falloff artifacts).
  33100. */
  33101. /**
  33102. * Sets the current filter to filtered "close ESM" (using the inverse of the
  33103. * exponential to prevent steep falloff artifacts).
  33104. */
  33105. useBlurCloseExponentialShadowMap: boolean;
  33106. /**
  33107. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  33108. */
  33109. /**
  33110. * Sets the current filter to "PCF" (percentage closer filtering).
  33111. */
  33112. usePercentageCloserFiltering: boolean;
  33113. private _filteringQuality;
  33114. /**
  33115. * Gets the PCF or PCSS Quality.
  33116. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33117. */
  33118. /**
  33119. * Sets the PCF or PCSS Quality.
  33120. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33121. */
  33122. filteringQuality: number;
  33123. /**
  33124. * Gets if the current filter is set to "PCSS" (contact hardening).
  33125. */
  33126. /**
  33127. * Sets the current filter to "PCSS" (contact hardening).
  33128. */
  33129. useContactHardeningShadow: boolean;
  33130. private _contactHardeningLightSizeUVRatio;
  33131. /**
  33132. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33133. * Using a ratio helps keeping shape stability independently of the map size.
  33134. *
  33135. * It does not account for the light projection as it was having too much
  33136. * instability during the light setup or during light position changes.
  33137. *
  33138. * Only valid if useContactHardeningShadow is true.
  33139. */
  33140. /**
  33141. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33142. * Using a ratio helps keeping shape stability independently of the map size.
  33143. *
  33144. * It does not account for the light projection as it was having too much
  33145. * instability during the light setup or during light position changes.
  33146. *
  33147. * Only valid if useContactHardeningShadow is true.
  33148. */
  33149. contactHardeningLightSizeUVRatio: number;
  33150. private _darkness;
  33151. /**
  33152. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  33153. * 0 means strongest and 1 would means no shadow.
  33154. * @returns the darkness.
  33155. */
  33156. getDarkness(): number;
  33157. /**
  33158. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  33159. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  33160. * @returns the shadow generator allowing fluent coding.
  33161. */
  33162. setDarkness(darkness: number): ShadowGenerator;
  33163. private _transparencyShadow;
  33164. /**
  33165. * Sets the ability to have transparent shadow (boolean).
  33166. * @param transparent True if transparent else False
  33167. * @returns the shadow generator allowing fluent coding
  33168. */
  33169. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  33170. private _shadowMap;
  33171. private _shadowMap2;
  33172. /**
  33173. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33174. * @returns The render target texture if present otherwise, null
  33175. */
  33176. getShadowMap(): Nullable<RenderTargetTexture>;
  33177. /**
  33178. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33179. * @returns The render target texture if the shadow map is present otherwise, null
  33180. */
  33181. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33182. /**
  33183. * Helper function to add a mesh and its descendants to the list of shadow casters.
  33184. * @param mesh Mesh to add
  33185. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  33186. * @returns the Shadow Generator itself
  33187. */
  33188. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33189. /**
  33190. * Helper function to remove a mesh and its descendants from the list of shadow casters
  33191. * @param mesh Mesh to remove
  33192. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  33193. * @returns the Shadow Generator itself
  33194. */
  33195. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33196. /**
  33197. * Controls the extent to which the shadows fade out at the edge of the frustum
  33198. * Used only by directionals and spots
  33199. */
  33200. frustumEdgeFalloff: number;
  33201. private _light;
  33202. /**
  33203. * Returns the associated light object.
  33204. * @returns the light generating the shadow
  33205. */
  33206. getLight(): IShadowLight;
  33207. /**
  33208. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  33209. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  33210. * It might on the other hand introduce peter panning.
  33211. */
  33212. forceBackFacesOnly: boolean;
  33213. private _scene;
  33214. private _lightDirection;
  33215. private _effect;
  33216. private _viewMatrix;
  33217. private _projectionMatrix;
  33218. private _transformMatrix;
  33219. private _cachedPosition;
  33220. private _cachedDirection;
  33221. private _cachedDefines;
  33222. private _currentRenderID;
  33223. private _boxBlurPostprocess;
  33224. private _kernelBlurXPostprocess;
  33225. private _kernelBlurYPostprocess;
  33226. private _blurPostProcesses;
  33227. private _mapSize;
  33228. private _currentFaceIndex;
  33229. private _currentFaceIndexCache;
  33230. private _textureType;
  33231. private _defaultTextureMatrix;
  33232. /**
  33233. * Creates a ShadowGenerator object.
  33234. * A ShadowGenerator is the required tool to use the shadows.
  33235. * Each light casting shadows needs to use its own ShadowGenerator.
  33236. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  33237. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  33238. * @param light The light object generating the shadows.
  33239. * @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.
  33240. */
  33241. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  33242. private _initializeGenerator();
  33243. private _initializeShadowMap();
  33244. private _initializeBlurRTTAndPostProcesses();
  33245. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  33246. private _renderSubMeshForShadowMap(subMesh);
  33247. private _applyFilterValues();
  33248. /**
  33249. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33250. * @param onCompiled Callback triggered at the and of the effects compilation
  33251. * @param options Sets of optional options forcing the compilation with different modes
  33252. */
  33253. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33254. useInstances: boolean;
  33255. }>): void;
  33256. /**
  33257. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33258. * @param options Sets of optional options forcing the compilation with different modes
  33259. * @returns A promise that resolves when the compilation completes
  33260. */
  33261. forceCompilationAsync(options?: Partial<{
  33262. useInstances: boolean;
  33263. }>): Promise<void>;
  33264. /**
  33265. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33266. * @param subMesh The submesh we want to render in the shadow map
  33267. * @param useInstances Defines wether will draw in the map using instances
  33268. * @returns true if ready otherwise, false
  33269. */
  33270. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33271. /**
  33272. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33273. * @param defines Defines of the material we want to update
  33274. * @param lightIndex Index of the light in the enabled light list of the material
  33275. */
  33276. prepareDefines(defines: any, lightIndex: number): void;
  33277. /**
  33278. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33279. * defined in the generator but impacting the effect).
  33280. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33281. * @param effect The effect we are binfing the information for
  33282. */
  33283. bindShadowLight(lightIndex: string, effect: Effect): void;
  33284. /**
  33285. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33286. * (eq to shadow prjection matrix * light transform matrix)
  33287. * @returns The transform matrix used to create the shadow map
  33288. */
  33289. getTransformMatrix(): Matrix;
  33290. /**
  33291. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33292. * Cube and 2D textures for instance.
  33293. */
  33294. recreateShadowMap(): void;
  33295. private _disposeBlurPostProcesses();
  33296. private _disposeRTTandPostProcesses();
  33297. /**
  33298. * Disposes the ShadowGenerator.
  33299. * Returns nothing.
  33300. */
  33301. dispose(): void;
  33302. /**
  33303. * Serializes the shadow generator setup to a json object.
  33304. * @returns The serialized JSON object
  33305. */
  33306. serialize(): any;
  33307. /**
  33308. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  33309. * @param parsedShadowGenerator The JSON object to parse
  33310. * @param scene The scene to create the shadow map for
  33311. * @returns The parsed shadow generator
  33312. */
  33313. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  33314. }
  33315. }
  33316. declare module BABYLON {
  33317. }
  33318. declare module BABYLON {
  33319. /**
  33320. * Background material used to create an efficient environement around your scene.
  33321. */
  33322. class BackgroundMaterial extends PushMaterial {
  33323. /**
  33324. * Standard reflectance value at parallel view angle.
  33325. */
  33326. static StandardReflectance0: number;
  33327. /**
  33328. * Standard reflectance value at grazing angle.
  33329. */
  33330. static StandardReflectance90: number;
  33331. protected _primaryColor: Color3;
  33332. /**
  33333. * Key light Color (multiply against the environement texture)
  33334. */
  33335. primaryColor: Color3;
  33336. protected __perceptualColor: Nullable<Color3>;
  33337. /**
  33338. * Experimental Internal Use Only.
  33339. *
  33340. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  33341. * This acts as a helper to set the primary color to a more "human friendly" value.
  33342. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  33343. * output color as close as possible from the chosen value.
  33344. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  33345. * part of lighting setup.)
  33346. */
  33347. _perceptualColor: Nullable<Color3>;
  33348. protected _primaryColorShadowLevel: float;
  33349. /**
  33350. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  33351. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  33352. */
  33353. primaryColorShadowLevel: float;
  33354. protected _primaryColorHighlightLevel: float;
  33355. /**
  33356. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  33357. * The primary color is used at the level chosen to define what the white area would look.
  33358. */
  33359. primaryColorHighlightLevel: float;
  33360. protected _reflectionTexture: Nullable<BaseTexture>;
  33361. /**
  33362. * Reflection Texture used in the material.
  33363. * Should be author in a specific way for the best result (refer to the documentation).
  33364. */
  33365. reflectionTexture: Nullable<BaseTexture>;
  33366. protected _reflectionBlur: float;
  33367. /**
  33368. * Reflection Texture level of blur.
  33369. *
  33370. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  33371. * texture twice.
  33372. */
  33373. reflectionBlur: float;
  33374. protected _diffuseTexture: Nullable<BaseTexture>;
  33375. /**
  33376. * Diffuse Texture used in the material.
  33377. * Should be author in a specific way for the best result (refer to the documentation).
  33378. */
  33379. diffuseTexture: Nullable<BaseTexture>;
  33380. protected _shadowLights: Nullable<IShadowLight[]>;
  33381. /**
  33382. * Specify the list of lights casting shadow on the material.
  33383. * All scene shadow lights will be included if null.
  33384. */
  33385. shadowLights: Nullable<IShadowLight[]>;
  33386. protected _shadowLevel: float;
  33387. /**
  33388. * Helps adjusting the shadow to a softer level if required.
  33389. * 0 means black shadows and 1 means no shadows.
  33390. */
  33391. shadowLevel: float;
  33392. protected _sceneCenter: Vector3;
  33393. /**
  33394. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  33395. * It is usually zero but might be interesting to modify according to your setup.
  33396. */
  33397. sceneCenter: Vector3;
  33398. protected _opacityFresnel: boolean;
  33399. /**
  33400. * This helps specifying that the material is falling off to the sky box at grazing angle.
  33401. * This helps ensuring a nice transition when the camera goes under the ground.
  33402. */
  33403. opacityFresnel: boolean;
  33404. protected _reflectionFresnel: boolean;
  33405. /**
  33406. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  33407. * This helps adding a mirror texture on the ground.
  33408. */
  33409. reflectionFresnel: boolean;
  33410. protected _reflectionFalloffDistance: number;
  33411. /**
  33412. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  33413. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  33414. */
  33415. reflectionFalloffDistance: number;
  33416. protected _reflectionAmount: number;
  33417. /**
  33418. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  33419. */
  33420. reflectionAmount: number;
  33421. protected _reflectionReflectance0: number;
  33422. /**
  33423. * This specifies the weight of the reflection at grazing angle.
  33424. */
  33425. reflectionReflectance0: number;
  33426. protected _reflectionReflectance90: number;
  33427. /**
  33428. * This specifies the weight of the reflection at a perpendicular point of view.
  33429. */
  33430. reflectionReflectance90: number;
  33431. /**
  33432. * Sets the reflection reflectance fresnel values according to the default standard
  33433. * empirically know to work well :-)
  33434. */
  33435. reflectionStandardFresnelWeight: number;
  33436. protected _useRGBColor: boolean;
  33437. /**
  33438. * Helps to directly use the maps channels instead of their level.
  33439. */
  33440. useRGBColor: boolean;
  33441. protected _enableNoise: boolean;
  33442. /**
  33443. * This helps reducing the banding effect that could occur on the background.
  33444. */
  33445. enableNoise: boolean;
  33446. /**
  33447. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  33448. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  33449. * Recommended to be keep at 1.0 except for special cases.
  33450. */
  33451. fovMultiplier: number;
  33452. private _fovMultiplier;
  33453. /**
  33454. * Enable the FOV adjustment feature controlled by fovMultiplier.
  33455. */
  33456. useEquirectangularFOV: boolean;
  33457. private _maxSimultaneousLights;
  33458. /**
  33459. * Number of Simultaneous lights allowed on the material.
  33460. */
  33461. maxSimultaneousLights: int;
  33462. /**
  33463. * Default configuration related to image processing available in the Background Material.
  33464. */
  33465. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33466. /**
  33467. * Keep track of the image processing observer to allow dispose and replace.
  33468. */
  33469. private _imageProcessingObserver;
  33470. /**
  33471. * Attaches a new image processing configuration to the PBR Material.
  33472. * @param configuration (if null the scene configuration will be use)
  33473. */
  33474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33475. /**
  33476. * Gets the image processing configuration used either in this material.
  33477. */
  33478. /**
  33479. * Sets the Default image processing configuration used either in the this material.
  33480. *
  33481. * If sets to null, the scene one is in use.
  33482. */
  33483. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  33484. /**
  33485. * Gets wether the color curves effect is enabled.
  33486. */
  33487. /**
  33488. * Sets wether the color curves effect is enabled.
  33489. */
  33490. cameraColorCurvesEnabled: boolean;
  33491. /**
  33492. * Gets wether the color grading effect is enabled.
  33493. */
  33494. /**
  33495. * Gets wether the color grading effect is enabled.
  33496. */
  33497. cameraColorGradingEnabled: boolean;
  33498. /**
  33499. * Gets wether tonemapping is enabled or not.
  33500. */
  33501. /**
  33502. * Sets wether tonemapping is enabled or not
  33503. */
  33504. cameraToneMappingEnabled: boolean;
  33505. /**
  33506. * The camera exposure used on this material.
  33507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33508. * This corresponds to a photographic exposure.
  33509. */
  33510. /**
  33511. * The camera exposure used on this material.
  33512. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  33513. * This corresponds to a photographic exposure.
  33514. */
  33515. cameraExposure: float;
  33516. /**
  33517. * Gets The camera contrast used on this material.
  33518. */
  33519. /**
  33520. * Sets The camera contrast used on this material.
  33521. */
  33522. cameraContrast: float;
  33523. /**
  33524. * Gets the Color Grading 2D Lookup Texture.
  33525. */
  33526. /**
  33527. * Sets the Color Grading 2D Lookup Texture.
  33528. */
  33529. cameraColorGradingTexture: Nullable<BaseTexture>;
  33530. /**
  33531. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33532. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33533. * 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;
  33534. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33535. */
  33536. /**
  33537. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  33538. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  33539. * 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;
  33540. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  33541. */
  33542. cameraColorCurves: Nullable<ColorCurves>;
  33543. /**
  33544. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  33545. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  33546. */
  33547. switchToBGR: boolean;
  33548. private _renderTargets;
  33549. private _reflectionControls;
  33550. private _white;
  33551. private _primaryShadowColor;
  33552. private _primaryHighlightColor;
  33553. /**
  33554. * Instantiates a Background Material in the given scene
  33555. * @param name The friendly name of the material
  33556. * @param scene The scene to add the material to
  33557. */
  33558. constructor(name: string, scene: Scene);
  33559. /**
  33560. * The entire material has been created in order to prevent overdraw.
  33561. * @returns false
  33562. */
  33563. needAlphaTesting(): boolean;
  33564. /**
  33565. * The entire material has been created in order to prevent overdraw.
  33566. * @returns true if blending is enable
  33567. */
  33568. needAlphaBlending(): boolean;
  33569. /**
  33570. * Checks wether the material is ready to be rendered for a given mesh.
  33571. * @param mesh The mesh to render
  33572. * @param subMesh The submesh to check against
  33573. * @param useInstances Specify wether or not the material is used with instances
  33574. * @returns true if all the dependencies are ready (Textures, Effects...)
  33575. */
  33576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  33577. /**
  33578. * Compute the primary color according to the chosen perceptual color.
  33579. */
  33580. private _computePrimaryColorFromPerceptualColor();
  33581. /**
  33582. * Compute the highlights and shadow colors according to their chosen levels.
  33583. */
  33584. private _computePrimaryColors();
  33585. /**
  33586. * Build the uniform buffer used in the material.
  33587. */
  33588. buildUniformLayout(): void;
  33589. /**
  33590. * Unbind the material.
  33591. */
  33592. unbind(): void;
  33593. /**
  33594. * Bind only the world matrix to the material.
  33595. * @param world The world matrix to bind.
  33596. */
  33597. bindOnlyWorldMatrix(world: Matrix): void;
  33598. /**
  33599. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  33600. * @param world The world matrix to bind.
  33601. * @param subMesh The submesh to bind for.
  33602. */
  33603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  33604. /**
  33605. * Dispose the material.
  33606. * @param forceDisposeEffect Force disposal of the associated effect.
  33607. * @param forceDisposeTextures Force disposal of the associated textures.
  33608. */
  33609. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  33610. /**
  33611. * Clones the material.
  33612. * @param name The cloned name.
  33613. * @returns The cloned material.
  33614. */
  33615. clone(name: string): BackgroundMaterial;
  33616. /**
  33617. * Serializes the current material to its JSON representation.
  33618. * @returns The JSON representation.
  33619. */
  33620. serialize(): any;
  33621. /**
  33622. * Gets the class name of the material
  33623. * @returns "BackgroundMaterial"
  33624. */
  33625. getClassName(): string;
  33626. /**
  33627. * Parse a JSON input to create back a background material.
  33628. * @param source The JSON data to parse
  33629. * @param scene The scene to create the parsed material in
  33630. * @param rootUrl The root url of the assets the material depends upon
  33631. * @returns the instantiated BackgroundMaterial.
  33632. */
  33633. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  33634. }
  33635. }
  33636. declare module BABYLON {
  33637. /**
  33638. * The Physically based material base class of BJS.
  33639. *
  33640. * This offers the main features of a standard PBR material.
  33641. * For more information, please refer to the documentation :
  33642. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  33643. */
  33644. abstract class PBRBaseMaterial extends PushMaterial {
  33645. /**
  33646. * Intensity of the direct lights e.g. the four lights available in your scene.
  33647. * This impacts both the direct diffuse and specular highlights.
  33648. */
  33649. protected _directIntensity: number;
  33650. /**
  33651. * Intensity of the emissive part of the material.
  33652. * This helps controlling the emissive effect without modifying the emissive color.
  33653. */
  33654. protected _emissiveIntensity: number;
  33655. /**
  33656. * Intensity of the environment e.g. how much the environment will light the object
  33657. * either through harmonics for rough material or through the refelction for shiny ones.
  33658. */
  33659. protected _environmentIntensity: number;
  33660. /**
  33661. * This is a special control allowing the reduction of the specular highlights coming from the
  33662. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  33663. */
  33664. protected _specularIntensity: number;
  33665. /**
  33666. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  33667. */
  33668. private _lightingInfos;
  33669. /**
  33670. * Debug Control allowing disabling the bump map on this material.
  33671. */
  33672. protected _disableBumpMap: boolean;
  33673. /**
  33674. * AKA Diffuse Texture in standard nomenclature.
  33675. */
  33676. protected _albedoTexture: BaseTexture;
  33677. /**
  33678. * AKA Occlusion Texture in other nomenclature.
  33679. */
  33680. protected _ambientTexture: BaseTexture;
  33681. /**
  33682. * AKA Occlusion Texture Intensity in other nomenclature.
  33683. */
  33684. protected _ambientTextureStrength: number;
  33685. /**
  33686. * Stores the alpha values in a texture.
  33687. */
  33688. protected _opacityTexture: BaseTexture;
  33689. /**
  33690. * Stores the reflection values in a texture.
  33691. */
  33692. protected _reflectionTexture: BaseTexture;
  33693. /**
  33694. * Stores the refraction values in a texture.
  33695. */
  33696. protected _refractionTexture: BaseTexture;
  33697. /**
  33698. * Stores the emissive values in a texture.
  33699. */
  33700. protected _emissiveTexture: BaseTexture;
  33701. /**
  33702. * AKA Specular texture in other nomenclature.
  33703. */
  33704. protected _reflectivityTexture: BaseTexture;
  33705. /**
  33706. * Used to switch from specular/glossiness to metallic/roughness workflow.
  33707. */
  33708. protected _metallicTexture: BaseTexture;
  33709. /**
  33710. * Specifies the metallic scalar of the metallic/roughness workflow.
  33711. * Can also be used to scale the metalness values of the metallic texture.
  33712. */
  33713. protected _metallic: number;
  33714. /**
  33715. * Specifies the roughness scalar of the metallic/roughness workflow.
  33716. * Can also be used to scale the roughness values of the metallic texture.
  33717. */
  33718. protected _roughness: number;
  33719. /**
  33720. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  33721. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  33722. */
  33723. protected _microSurfaceTexture: BaseTexture;
  33724. /**
  33725. * Stores surface normal data used to displace a mesh in a texture.
  33726. */
  33727. protected _bumpTexture: BaseTexture;
  33728. /**
  33729. * Stores the pre-calculated light information of a mesh in a texture.
  33730. */
  33731. protected _lightmapTexture: BaseTexture;
  33732. /**
  33733. * The color of a material in ambient lighting.
  33734. */
  33735. protected _ambientColor: Color3;
  33736. /**
  33737. * AKA Diffuse Color in other nomenclature.
  33738. */
  33739. protected _albedoColor: Color3;
  33740. /**
  33741. * AKA Specular Color in other nomenclature.
  33742. */
  33743. protected _reflectivityColor: Color3;
  33744. /**
  33745. * The color applied when light is reflected from a material.
  33746. */
  33747. protected _reflectionColor: Color3;
  33748. /**
  33749. * The color applied when light is emitted from a material.
  33750. */
  33751. protected _emissiveColor: Color3;
  33752. /**
  33753. * AKA Glossiness in other nomenclature.
  33754. */
  33755. protected _microSurface: number;
  33756. /**
  33757. * source material index of refraction (IOR)' / 'destination material IOR.
  33758. */
  33759. protected _indexOfRefraction: number;
  33760. /**
  33761. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  33762. */
  33763. protected _invertRefractionY: boolean;
  33764. /**
  33765. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  33766. * Materials half opaque for instance using refraction could benefit from this control.
  33767. */
  33768. protected _linkRefractionWithTransparency: boolean;
  33769. /**
  33770. * Specifies that the material will use the light map as a show map.
  33771. */
  33772. protected _useLightmapAsShadowmap: boolean;
  33773. /**
  33774. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  33775. * makes the reflect vector face the model (under horizon).
  33776. */
  33777. protected _useHorizonOcclusion: boolean;
  33778. /**
  33779. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  33780. * too much the area relying on ambient texture to define their ambient occlusion.
  33781. */
  33782. protected _useRadianceOcclusion: boolean;
  33783. /**
  33784. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  33785. */
  33786. protected _useAlphaFromAlbedoTexture: boolean;
  33787. /**
  33788. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  33789. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  33790. */
  33791. protected _useSpecularOverAlpha: boolean;
  33792. /**
  33793. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  33794. */
  33795. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  33796. /**
  33797. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  33798. */
  33799. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  33800. /**
  33801. * Specifies if the metallic texture contains the roughness information in its green channel.
  33802. */
  33803. protected _useRoughnessFromMetallicTextureGreen: boolean;
  33804. /**
  33805. * Specifies if the metallic texture contains the metallness information in its blue channel.
  33806. */
  33807. protected _useMetallnessFromMetallicTextureBlue: boolean;
  33808. /**
  33809. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  33810. */
  33811. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  33812. /**
  33813. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  33814. */
  33815. protected _useAmbientInGrayScale: boolean;
  33816. /**
  33817. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  33818. * The material will try to infer what glossiness each pixel should be.
  33819. */
  33820. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  33821. /**
  33822. * BJS is using an harcoded light falloff based on a manually sets up range.
  33823. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  33824. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  33825. */
  33826. protected _usePhysicalLightFalloff: boolean;
  33827. /**
  33828. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  33829. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  33830. */
  33831. protected _useRadianceOverAlpha: boolean;
  33832. /**
  33833. * Allows using an object space normal map (instead of tangent space).
  33834. */
  33835. protected _useObjectSpaceNormalMap: boolean;
  33836. /**
  33837. * Allows using the bump map in parallax mode.
  33838. */
  33839. protected _useParallax: boolean;
  33840. /**
  33841. * Allows using the bump map in parallax occlusion mode.
  33842. */
  33843. protected _useParallaxOcclusion: boolean;
  33844. /**
  33845. * Controls the scale bias of the parallax mode.
  33846. */
  33847. protected _parallaxScaleBias: number;
  33848. /**
  33849. * If sets to true, disables all the lights affecting the material.
  33850. */
  33851. protected _disableLighting: boolean;
  33852. /**
  33853. * Number of Simultaneous lights allowed on the material.
  33854. */
  33855. protected _maxSimultaneousLights: number;
  33856. /**
  33857. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  33858. */
  33859. protected _invertNormalMapX: boolean;
  33860. /**
  33861. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  33862. */
  33863. protected _invertNormalMapY: boolean;
  33864. /**
  33865. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  33866. */
  33867. protected _twoSidedLighting: boolean;
  33868. /**
  33869. * Defines the alpha limits in alpha test mode.
  33870. */
  33871. protected _alphaCutOff: number;
  33872. /**
  33873. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  33874. */
  33875. protected _forceAlphaTest: boolean;
  33876. /**
  33877. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33878. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  33879. */
  33880. protected _useAlphaFresnel: boolean;
  33881. /**
  33882. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  33883. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  33884. */
  33885. protected _useLinearAlphaFresnel: boolean;
  33886. /**
  33887. * The transparency mode of the material.
  33888. */
  33889. protected _transparencyMode: Nullable<number>;
  33890. /**
  33891. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  33892. * from cos thetav and roughness:
  33893. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  33894. */
  33895. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  33896. /**
  33897. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  33898. */
  33899. protected _forceIrradianceInFragment: boolean;
  33900. /**
  33901. * Force normal to face away from face.
  33902. */
  33903. protected _forceNormalForward: boolean;
  33904. /**
  33905. * Enables specular anti aliasing in the PBR shader.
  33906. * It will both interacts on the Geometry for analytical and IBL lighting.
  33907. * It also prefilter the roughness map based on the bump values.
  33908. */
  33909. protected _enableSpecularAntiAliasing: boolean;
  33910. /**
  33911. * Default configuration related to image processing available in the PBR Material.
  33912. */
  33913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33914. /**
  33915. * Keep track of the image processing observer to allow dispose and replace.
  33916. */
  33917. private _imageProcessingObserver;
  33918. /**
  33919. * Attaches a new image processing configuration to the PBR Material.
  33920. * @param configuration
  33921. */
  33922. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  33923. /**
  33924. * Stores the available render targets.
  33925. */
  33926. private _renderTargets;
  33927. /**
  33928. * Sets the global ambient color for the material used in lighting calculations.
  33929. */
  33930. private _globalAmbientColor;
  33931. /**
  33932. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  33933. */
  33934. private _useLogarithmicDepth;
  33935. /**
  33936. * If set to true, no lighting calculations will be applied.
  33937. */
  33938. private _unlit;
  33939. /**
  33940. * Instantiates a new PBRMaterial instance.
  33941. *
  33942. * @param name The material name
  33943. * @param scene The scene the material will be use in.
  33944. */
  33945. constructor(name: string, scene: Scene);
  33946. /**
  33947. * Gets the name of the material class.
  33948. */
  33949. getClassName(): string;
  33950. /**
  33951. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33952. */
  33953. /**
  33954. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  33955. */
  33956. useLogarithmicDepth: boolean;
  33957. /**
  33958. * Gets the current transparency mode.
  33959. */
  33960. /**
  33961. * Sets the transparency mode of the material.
  33962. *
  33963. * | Value | Type | Description |
  33964. * | ----- | ----------------------------------- | ----------- |
  33965. * | 0 | OPAQUE | |
  33966. * | 1 | ALPHATEST | |
  33967. * | 2 | ALPHABLEND | |
  33968. * | 3 | ALPHATESTANDBLEND | |
  33969. *
  33970. */
  33971. transparencyMode: Nullable<number>;
  33972. /**
  33973. * Returns true if alpha blending should be disabled.
  33974. */
  33975. private readonly _disableAlphaBlending;
  33976. /**
  33977. * Specifies whether or not this material should be rendered in alpha blend mode.
  33978. */
  33979. needAlphaBlending(): boolean;
  33980. /**
  33981. * Specifies if the mesh will require alpha blending.
  33982. * @param mesh - BJS mesh.
  33983. */
  33984. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  33985. /**
  33986. * Specifies whether or not this material should be rendered in alpha test mode.
  33987. */
  33988. needAlphaTesting(): boolean;
  33989. /**
  33990. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  33991. */
  33992. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  33993. /**
  33994. * Gets the texture used for the alpha test.
  33995. */
  33996. getAlphaTestTexture(): BaseTexture;
  33997. /**
  33998. * Stores the reflectivity values based on metallic roughness workflow.
  33999. */
  34000. private static _scaledReflectivity;
  34001. /**
  34002. * Specifies that the submesh is ready to be used.
  34003. * @param mesh - BJS mesh.
  34004. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  34005. * @param useInstances - Specifies that instances should be used.
  34006. * @returns - boolean indicating that the submesh is ready or not.
  34007. */
  34008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34009. /**
  34010. * Specifies if the material uses metallic roughness workflow.
  34011. * @returns boolean specifiying if the material uses metallic roughness workflow.
  34012. */
  34013. isMetallicWorkflow(): boolean;
  34014. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  34015. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  34016. /**
  34017. * Force shader compilation
  34018. */
  34019. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  34020. clipPlane: boolean;
  34021. }>): void;
  34022. /**
  34023. * Initializes the uniform buffer layout for the shader.
  34024. */
  34025. buildUniformLayout(): void;
  34026. /**
  34027. * Unbinds the textures.
  34028. */
  34029. unbind(): void;
  34030. /**
  34031. * Binds the submesh data.
  34032. * @param world - The world matrix.
  34033. * @param mesh - The BJS mesh.
  34034. * @param subMesh - A submesh of the BJS mesh.
  34035. */
  34036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34037. /**
  34038. * Returns the animatable textures.
  34039. * @returns - Array of animatable textures.
  34040. */
  34041. getAnimatables(): IAnimatable[];
  34042. /**
  34043. * Returns the texture used for reflections.
  34044. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  34045. */
  34046. private _getReflectionTexture();
  34047. /**
  34048. * Returns the texture used for refraction or null if none is used.
  34049. * @returns - Refection texture if present. If no refraction texture and refraction
  34050. * is linked with transparency, returns environment texture. Otherwise, returns null.
  34051. */
  34052. private _getRefractionTexture();
  34053. /**
  34054. * Disposes the resources of the material.
  34055. * @param forceDisposeEffect - Forces the disposal of effects.
  34056. * @param forceDisposeTextures - Forces the disposal of all textures.
  34057. */
  34058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34059. }
  34060. }
  34061. declare module BABYLON {
  34062. /**
  34063. * The Physically based simple base material of BJS.
  34064. *
  34065. * This enables better naming and convention enforcements on top of the pbrMaterial.
  34066. * It is used as the base class for both the specGloss and metalRough conventions.
  34067. */
  34068. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  34069. /**
  34070. * Number of Simultaneous lights allowed on the material.
  34071. */
  34072. maxSimultaneousLights: number;
  34073. /**
  34074. * If sets to true, disables all the lights affecting the material.
  34075. */
  34076. disableLighting: boolean;
  34077. /**
  34078. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  34079. */
  34080. environmentTexture: BaseTexture;
  34081. /**
  34082. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34083. */
  34084. invertNormalMapX: boolean;
  34085. /**
  34086. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34087. */
  34088. invertNormalMapY: boolean;
  34089. /**
  34090. * Normal map used in the model.
  34091. */
  34092. normalTexture: BaseTexture;
  34093. /**
  34094. * Emissivie color used to self-illuminate the model.
  34095. */
  34096. emissiveColor: Color3;
  34097. /**
  34098. * Emissivie texture used to self-illuminate the model.
  34099. */
  34100. emissiveTexture: BaseTexture;
  34101. /**
  34102. * Occlusion Channel Strenght.
  34103. */
  34104. occlusionStrength: number;
  34105. /**
  34106. * Occlusion Texture of the material (adding extra occlusion effects).
  34107. */
  34108. occlusionTexture: BaseTexture;
  34109. /**
  34110. * Defines the alpha limits in alpha test mode.
  34111. */
  34112. alphaCutOff: number;
  34113. /**
  34114. * Gets the current double sided mode.
  34115. */
  34116. /**
  34117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34118. */
  34119. doubleSided: boolean;
  34120. lightmapTexture: BaseTexture;
  34121. useLightmapAsShadowmap: boolean;
  34122. /**
  34123. * Return the active textures of the material.
  34124. */
  34125. getActiveTextures(): BaseTexture[];
  34126. hasTexture(texture: BaseTexture): boolean;
  34127. /**
  34128. * Instantiates a new PBRMaterial instance.
  34129. *
  34130. * @param name The material name
  34131. * @param scene The scene the material will be use in.
  34132. */
  34133. constructor(name: string, scene: Scene);
  34134. getClassName(): string;
  34135. }
  34136. }
  34137. declare module BABYLON {
  34138. /**
  34139. * The Physically based material of BJS.
  34140. *
  34141. * This offers the main features of a standard PBR material.
  34142. * For more information, please refer to the documentation :
  34143. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34144. */
  34145. class PBRMaterial extends PBRBaseMaterial {
  34146. private static _PBRMATERIAL_OPAQUE;
  34147. /**
  34148. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  34149. */
  34150. static readonly PBRMATERIAL_OPAQUE: number;
  34151. /**
  34152. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34153. */
  34154. private static _PBRMATERIAL_ALPHATEST;
  34155. /**
  34156. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34157. */
  34158. static readonly PBRMATERIAL_ALPHATEST: number;
  34159. /**
  34160. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34161. */
  34162. private static _PBRMATERIAL_ALPHABLEND;
  34163. /**
  34164. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34165. */
  34166. static readonly PBRMATERIAL_ALPHABLEND: number;
  34167. /**
  34168. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34169. * They are also discarded below the alpha cutoff threshold to improve performances.
  34170. */
  34171. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  34172. /**
  34173. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34174. * They are also discarded below the alpha cutoff threshold to improve performances.
  34175. */
  34176. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  34177. /**
  34178. * Intensity of the direct lights e.g. the four lights available in your scene.
  34179. * This impacts both the direct diffuse and specular highlights.
  34180. */
  34181. directIntensity: number;
  34182. /**
  34183. * Intensity of the emissive part of the material.
  34184. * This helps controlling the emissive effect without modifying the emissive color.
  34185. */
  34186. emissiveIntensity: number;
  34187. /**
  34188. * Intensity of the environment e.g. how much the environment will light the object
  34189. * either through harmonics for rough material or through the refelction for shiny ones.
  34190. */
  34191. environmentIntensity: number;
  34192. /**
  34193. * This is a special control allowing the reduction of the specular highlights coming from the
  34194. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34195. */
  34196. specularIntensity: number;
  34197. /**
  34198. * Debug Control allowing disabling the bump map on this material.
  34199. */
  34200. disableBumpMap: boolean;
  34201. /**
  34202. * AKA Diffuse Texture in standard nomenclature.
  34203. */
  34204. albedoTexture: BaseTexture;
  34205. /**
  34206. * AKA Occlusion Texture in other nomenclature.
  34207. */
  34208. ambientTexture: BaseTexture;
  34209. /**
  34210. * AKA Occlusion Texture Intensity in other nomenclature.
  34211. */
  34212. ambientTextureStrength: number;
  34213. /**
  34214. * Stores the alpha values in a texture.
  34215. */
  34216. opacityTexture: BaseTexture;
  34217. /**
  34218. * Stores the reflection values in a texture.
  34219. */
  34220. reflectionTexture: Nullable<BaseTexture>;
  34221. /**
  34222. * Stores the emissive values in a texture.
  34223. */
  34224. emissiveTexture: BaseTexture;
  34225. /**
  34226. * AKA Specular texture in other nomenclature.
  34227. */
  34228. reflectivityTexture: BaseTexture;
  34229. /**
  34230. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34231. */
  34232. metallicTexture: BaseTexture;
  34233. /**
  34234. * Specifies the metallic scalar of the metallic/roughness workflow.
  34235. * Can also be used to scale the metalness values of the metallic texture.
  34236. */
  34237. metallic: number;
  34238. /**
  34239. * Specifies the roughness scalar of the metallic/roughness workflow.
  34240. * Can also be used to scale the roughness values of the metallic texture.
  34241. */
  34242. roughness: number;
  34243. /**
  34244. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34245. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34246. */
  34247. microSurfaceTexture: BaseTexture;
  34248. /**
  34249. * Stores surface normal data used to displace a mesh in a texture.
  34250. */
  34251. bumpTexture: BaseTexture;
  34252. /**
  34253. * Stores the pre-calculated light information of a mesh in a texture.
  34254. */
  34255. lightmapTexture: BaseTexture;
  34256. /**
  34257. * Stores the refracted light information in a texture.
  34258. */
  34259. refractionTexture: BaseTexture;
  34260. /**
  34261. * The color of a material in ambient lighting.
  34262. */
  34263. ambientColor: Color3;
  34264. /**
  34265. * AKA Diffuse Color in other nomenclature.
  34266. */
  34267. albedoColor: Color3;
  34268. /**
  34269. * AKA Specular Color in other nomenclature.
  34270. */
  34271. reflectivityColor: Color3;
  34272. /**
  34273. * The color reflected from the material.
  34274. */
  34275. reflectionColor: Color3;
  34276. /**
  34277. * The color emitted from the material.
  34278. */
  34279. emissiveColor: Color3;
  34280. /**
  34281. * AKA Glossiness in other nomenclature.
  34282. */
  34283. microSurface: number;
  34284. /**
  34285. * source material index of refraction (IOR)' / 'destination material IOR.
  34286. */
  34287. indexOfRefraction: number;
  34288. /**
  34289. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34290. */
  34291. invertRefractionY: boolean;
  34292. /**
  34293. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34294. * Materials half opaque for instance using refraction could benefit from this control.
  34295. */
  34296. linkRefractionWithTransparency: boolean;
  34297. useLightmapAsShadowmap: boolean;
  34298. /**
  34299. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34300. */
  34301. useAlphaFromAlbedoTexture: boolean;
  34302. /**
  34303. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34304. */
  34305. forceAlphaTest: boolean;
  34306. /**
  34307. * Defines the alpha limits in alpha test mode.
  34308. */
  34309. alphaCutOff: number;
  34310. /**
  34311. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34312. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34313. */
  34314. useSpecularOverAlpha: boolean;
  34315. /**
  34316. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34317. */
  34318. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34319. /**
  34320. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34321. */
  34322. useRoughnessFromMetallicTextureAlpha: boolean;
  34323. /**
  34324. * Specifies if the metallic texture contains the roughness information in its green channel.
  34325. */
  34326. useRoughnessFromMetallicTextureGreen: boolean;
  34327. /**
  34328. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34329. */
  34330. useMetallnessFromMetallicTextureBlue: boolean;
  34331. /**
  34332. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34333. */
  34334. useAmbientOcclusionFromMetallicTextureRed: boolean;
  34335. /**
  34336. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34337. */
  34338. useAmbientInGrayScale: boolean;
  34339. /**
  34340. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34341. * The material will try to infer what glossiness each pixel should be.
  34342. */
  34343. useAutoMicroSurfaceFromReflectivityMap: boolean;
  34344. /**
  34345. * BJS is using an harcoded light falloff based on a manually sets up range.
  34346. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34347. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34348. */
  34349. usePhysicalLightFalloff: boolean;
  34350. /**
  34351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34353. */
  34354. useRadianceOverAlpha: boolean;
  34355. /**
  34356. * Allows using an object space normal map (instead of tangent space).
  34357. */
  34358. useObjectSpaceNormalMap: boolean;
  34359. /**
  34360. * Allows using the bump map in parallax mode.
  34361. */
  34362. useParallax: boolean;
  34363. /**
  34364. * Allows using the bump map in parallax occlusion mode.
  34365. */
  34366. useParallaxOcclusion: boolean;
  34367. /**
  34368. * Controls the scale bias of the parallax mode.
  34369. */
  34370. parallaxScaleBias: number;
  34371. /**
  34372. * If sets to true, disables all the lights affecting the material.
  34373. */
  34374. disableLighting: boolean;
  34375. /**
  34376. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34377. */
  34378. forceIrradianceInFragment: boolean;
  34379. /**
  34380. * Number of Simultaneous lights allowed on the material.
  34381. */
  34382. maxSimultaneousLights: number;
  34383. /**
  34384. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34385. */
  34386. invertNormalMapX: boolean;
  34387. /**
  34388. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34389. */
  34390. invertNormalMapY: boolean;
  34391. /**
  34392. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34393. */
  34394. twoSidedLighting: boolean;
  34395. /**
  34396. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34397. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34398. */
  34399. useAlphaFresnel: boolean;
  34400. /**
  34401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34402. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34403. */
  34404. useLinearAlphaFresnel: boolean;
  34405. /**
  34406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34407. * And/Or occlude the blended part.
  34408. */
  34409. environmentBRDFTexture: Nullable<BaseTexture>;
  34410. /**
  34411. * Force normal to face away from face.
  34412. */
  34413. forceNormalForward: boolean;
  34414. /**
  34415. * Enables specular anti aliasing in the PBR shader.
  34416. * It will both interacts on the Geometry for analytical and IBL lighting.
  34417. * It also prefilter the roughness map based on the bump values.
  34418. */
  34419. enableSpecularAntiAliasing: boolean;
  34420. /**
  34421. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34422. * makes the reflect vector face the model (under horizon).
  34423. */
  34424. useHorizonOcclusion: boolean;
  34425. /**
  34426. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34427. * too much the area relying on ambient texture to define their ambient occlusion.
  34428. */
  34429. useRadianceOcclusion: boolean;
  34430. /**
  34431. * If set to true, no lighting calculations will be applied.
  34432. */
  34433. unlit: boolean;
  34434. /**
  34435. * Gets the image processing configuration used either in this material.
  34436. */
  34437. /**
  34438. * Sets the Default image processing configuration used either in the this material.
  34439. *
  34440. * If sets to null, the scene one is in use.
  34441. */
  34442. imageProcessingConfiguration: ImageProcessingConfiguration;
  34443. /**
  34444. * Gets wether the color curves effect is enabled.
  34445. */
  34446. /**
  34447. * Sets wether the color curves effect is enabled.
  34448. */
  34449. cameraColorCurvesEnabled: boolean;
  34450. /**
  34451. * Gets wether the color grading effect is enabled.
  34452. */
  34453. /**
  34454. * Gets wether the color grading effect is enabled.
  34455. */
  34456. cameraColorGradingEnabled: boolean;
  34457. /**
  34458. * Gets wether tonemapping is enabled or not.
  34459. */
  34460. /**
  34461. * Sets wether tonemapping is enabled or not
  34462. */
  34463. cameraToneMappingEnabled: boolean;
  34464. /**
  34465. * The camera exposure used on this material.
  34466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34467. * This corresponds to a photographic exposure.
  34468. */
  34469. /**
  34470. * The camera exposure used on this material.
  34471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34472. * This corresponds to a photographic exposure.
  34473. */
  34474. cameraExposure: number;
  34475. /**
  34476. * Gets The camera contrast used on this material.
  34477. */
  34478. /**
  34479. * Sets The camera contrast used on this material.
  34480. */
  34481. cameraContrast: number;
  34482. /**
  34483. * Gets the Color Grading 2D Lookup Texture.
  34484. */
  34485. /**
  34486. * Sets the Color Grading 2D Lookup Texture.
  34487. */
  34488. cameraColorGradingTexture: Nullable<BaseTexture>;
  34489. /**
  34490. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34491. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34492. * 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;
  34493. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34494. */
  34495. /**
  34496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34498. * 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;
  34499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34500. */
  34501. cameraColorCurves: Nullable<ColorCurves>;
  34502. /**
  34503. * Instantiates a new PBRMaterial instance.
  34504. *
  34505. * @param name The material name
  34506. * @param scene The scene the material will be use in.
  34507. */
  34508. constructor(name: string, scene: Scene);
  34509. /**
  34510. * Returns the name of this material class.
  34511. */
  34512. getClassName(): string;
  34513. /**
  34514. * Returns an array of the actively used textures.
  34515. * @returns - Array of BaseTextures
  34516. */
  34517. getActiveTextures(): BaseTexture[];
  34518. /**
  34519. * Checks to see if a texture is used in the material.
  34520. * @param texture - Base texture to use.
  34521. * @returns - Boolean specifying if a texture is used in the material.
  34522. */
  34523. hasTexture(texture: BaseTexture): boolean;
  34524. /**
  34525. * Makes a duplicate of the current material.
  34526. * @param name - name to use for the new material.
  34527. */
  34528. clone(name: string): PBRMaterial;
  34529. /**
  34530. * Serializes this PBR Material.
  34531. * @returns - An object with the serialized material.
  34532. */
  34533. serialize(): any;
  34534. /**
  34535. * Parses a PBR Material from a serialized object.
  34536. * @param source - Serialized object.
  34537. * @param scene - BJS scene instance.
  34538. * @param rootUrl - url for the scene object
  34539. * @returns - PBRMaterial
  34540. */
  34541. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  34542. }
  34543. }
  34544. declare module BABYLON {
  34545. /**
  34546. * The PBR material of BJS following the metal roughness convention.
  34547. *
  34548. * This fits to the PBR convention in the GLTF definition:
  34549. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  34550. */
  34551. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  34552. /**
  34553. * The base color has two different interpretations depending on the value of metalness.
  34554. * When the material is a metal, the base color is the specific measured reflectance value
  34555. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  34556. * of the material.
  34557. */
  34558. baseColor: Color3;
  34559. /**
  34560. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  34561. * well as opacity information in the alpha channel.
  34562. */
  34563. baseTexture: BaseTexture;
  34564. /**
  34565. * Specifies the metallic scalar value of the material.
  34566. * Can also be used to scale the metalness values of the metallic texture.
  34567. */
  34568. metallic: number;
  34569. /**
  34570. * Specifies the roughness scalar value of the material.
  34571. * Can also be used to scale the roughness values of the metallic texture.
  34572. */
  34573. roughness: number;
  34574. /**
  34575. * Texture containing both the metallic value in the B channel and the
  34576. * roughness value in the G channel to keep better precision.
  34577. */
  34578. metallicRoughnessTexture: BaseTexture;
  34579. /**
  34580. * Instantiates a new PBRMetalRoughnessMaterial instance.
  34581. *
  34582. * @param name The material name
  34583. * @param scene The scene the material will be use in.
  34584. */
  34585. constructor(name: string, scene: Scene);
  34586. /**
  34587. * Return the currrent class name of the material.
  34588. */
  34589. getClassName(): string;
  34590. /**
  34591. * Return the active textures of the material.
  34592. */
  34593. getActiveTextures(): BaseTexture[];
  34594. /**
  34595. * Checks to see if a texture is used in the material.
  34596. * @param texture - Base texture to use.
  34597. * @returns - Boolean specifying if a texture is used in the material.
  34598. */
  34599. hasTexture(texture: BaseTexture): boolean;
  34600. /**
  34601. * Makes a duplicate of the current material.
  34602. * @param name - name to use for the new material.
  34603. */
  34604. clone(name: string): PBRMetallicRoughnessMaterial;
  34605. /**
  34606. * Serialize the material to a parsable JSON object.
  34607. */
  34608. serialize(): any;
  34609. /**
  34610. * Parses a JSON object correponding to the serialize function.
  34611. */
  34612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  34613. }
  34614. }
  34615. declare module BABYLON {
  34616. /**
  34617. * The PBR material of BJS following the specular glossiness convention.
  34618. *
  34619. * This fits to the PBR convention in the GLTF definition:
  34620. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  34621. */
  34622. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  34623. /**
  34624. * Specifies the diffuse color of the material.
  34625. */
  34626. diffuseColor: Color3;
  34627. /**
  34628. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  34629. * channel.
  34630. */
  34631. diffuseTexture: BaseTexture;
  34632. /**
  34633. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  34634. */
  34635. specularColor: Color3;
  34636. /**
  34637. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  34638. */
  34639. glossiness: number;
  34640. /**
  34641. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  34642. */
  34643. specularGlossinessTexture: BaseTexture;
  34644. /**
  34645. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  34646. *
  34647. * @param name The material name
  34648. * @param scene The scene the material will be use in.
  34649. */
  34650. constructor(name: string, scene: Scene);
  34651. /**
  34652. * Return the currrent class name of the material.
  34653. */
  34654. getClassName(): string;
  34655. /**
  34656. * Return the active textures of the material.
  34657. */
  34658. getActiveTextures(): BaseTexture[];
  34659. /**
  34660. * Checks to see if a texture is used in the material.
  34661. * @param texture - Base texture to use.
  34662. * @returns - Boolean specifying if a texture is used in the material.
  34663. */
  34664. hasTexture(texture: BaseTexture): boolean;
  34665. /**
  34666. * Makes a duplicate of the current material.
  34667. * @param name - name to use for the new material.
  34668. */
  34669. clone(name: string): PBRSpecularGlossinessMaterial;
  34670. /**
  34671. * Serialize the material to a parsable JSON object.
  34672. */
  34673. serialize(): any;
  34674. /**
  34675. * Parses a JSON object correponding to the serialize function.
  34676. */
  34677. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  34678. }
  34679. }
  34680. declare module BABYLON {
  34681. class BaseTexture {
  34682. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34683. name: string;
  34684. private _hasAlpha;
  34685. hasAlpha: boolean;
  34686. getAlphaFromRGB: boolean;
  34687. level: number;
  34688. coordinatesIndex: number;
  34689. private _coordinatesMode;
  34690. /**
  34691. * How a texture is mapped.
  34692. *
  34693. * | Value | Type | Description |
  34694. * | ----- | ----------------------------------- | ----------- |
  34695. * | 0 | EXPLICIT_MODE | |
  34696. * | 1 | SPHERICAL_MODE | |
  34697. * | 2 | PLANAR_MODE | |
  34698. * | 3 | CUBIC_MODE | |
  34699. * | 4 | PROJECTION_MODE | |
  34700. * | 5 | SKYBOX_MODE | |
  34701. * | 6 | INVCUBIC_MODE | |
  34702. * | 7 | EQUIRECTANGULAR_MODE | |
  34703. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34704. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34705. */
  34706. coordinatesMode: number;
  34707. /**
  34708. * | Value | Type | Description |
  34709. * | ----- | ------------------ | ----------- |
  34710. * | 0 | CLAMP_ADDRESSMODE | |
  34711. * | 1 | WRAP_ADDRESSMODE | |
  34712. * | 2 | MIRROR_ADDRESSMODE | |
  34713. */
  34714. wrapU: number;
  34715. /**
  34716. * | Value | Type | Description |
  34717. * | ----- | ------------------ | ----------- |
  34718. * | 0 | CLAMP_ADDRESSMODE | |
  34719. * | 1 | WRAP_ADDRESSMODE | |
  34720. * | 2 | MIRROR_ADDRESSMODE | |
  34721. */
  34722. wrapV: number;
  34723. /**
  34724. * | Value | Type | Description |
  34725. * | ----- | ------------------ | ----------- |
  34726. * | 0 | CLAMP_ADDRESSMODE | |
  34727. * | 1 | WRAP_ADDRESSMODE | |
  34728. * | 2 | MIRROR_ADDRESSMODE | |
  34729. */
  34730. wrapR: number;
  34731. anisotropicFilteringLevel: number;
  34732. isCube: boolean;
  34733. is3D: boolean;
  34734. gammaSpace: boolean;
  34735. /**
  34736. * Gets whether or not the texture contains RGBD data.
  34737. */
  34738. readonly isRGBD: boolean;
  34739. invertZ: boolean;
  34740. lodLevelInAlpha: boolean;
  34741. lodGenerationOffset: number;
  34742. lodGenerationScale: number;
  34743. isRenderTarget: boolean;
  34744. readonly uid: string;
  34745. toString(): string;
  34746. getClassName(): string;
  34747. animations: Animation[];
  34748. /**
  34749. * An event triggered when the texture is disposed.
  34750. */
  34751. onDisposeObservable: Observable<BaseTexture>;
  34752. private _onDisposeObserver;
  34753. onDispose: () => void;
  34754. delayLoadState: number;
  34755. private _scene;
  34756. _texture: Nullable<InternalTexture>;
  34757. private _uid;
  34758. readonly isBlocking: boolean;
  34759. constructor(scene: Nullable<Scene>);
  34760. getScene(): Nullable<Scene>;
  34761. getTextureMatrix(): Matrix;
  34762. getReflectionTextureMatrix(): Matrix;
  34763. getInternalTexture(): Nullable<InternalTexture>;
  34764. isReadyOrNotBlocking(): boolean;
  34765. isReady(): boolean;
  34766. private _cachedSize;
  34767. getSize(): ISize;
  34768. getBaseSize(): ISize;
  34769. scale(ratio: number): void;
  34770. readonly canRescale: boolean;
  34771. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  34772. _rebuild(): void;
  34773. delayLoad(): void;
  34774. clone(): Nullable<BaseTexture>;
  34775. readonly textureType: number;
  34776. readonly textureFormat: number;
  34777. /**
  34778. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34779. * This will returns an RGBA array buffer containing either in values (0-255) or
  34780. * float values (0-1) depending of the underlying buffer type.
  34781. * @param faceIndex The face of the texture to read (in case of cube texture)
  34782. * @param level The LOD level of the texture to read (in case of Mip Maps)
  34783. * @returns The Array buffer containing the pixels data.
  34784. */
  34785. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  34786. releaseInternalTexture(): void;
  34787. sphericalPolynomial: Nullable<SphericalPolynomial>;
  34788. readonly _lodTextureHigh: Nullable<BaseTexture>;
  34789. readonly _lodTextureMid: Nullable<BaseTexture>;
  34790. readonly _lodTextureLow: Nullable<BaseTexture>;
  34791. dispose(): void;
  34792. serialize(): any;
  34793. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. /**
  34798. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  34799. * It can help converting any input color in a desired output one. This can then be used to create effects
  34800. * from sepia, black and white to sixties or futuristic rendering...
  34801. *
  34802. * The only supported format is currently 3dl.
  34803. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  34804. */
  34805. class ColorGradingTexture extends BaseTexture {
  34806. /**
  34807. * The current texture matrix. (will always be identity in color grading texture)
  34808. */
  34809. private _textureMatrix;
  34810. /**
  34811. * The texture URL.
  34812. */
  34813. url: string;
  34814. /**
  34815. * Empty line regex stored for GC.
  34816. */
  34817. private static _noneEmptyLineRegex;
  34818. private _engine;
  34819. /**
  34820. * Instantiates a ColorGradingTexture from the following parameters.
  34821. *
  34822. * @param url The location of the color gradind data (currently only supporting 3dl)
  34823. * @param scene The scene the texture will be used in
  34824. */
  34825. constructor(url: string, scene: Scene);
  34826. /**
  34827. * Returns the texture matrix used in most of the material.
  34828. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  34829. */
  34830. getTextureMatrix(): Matrix;
  34831. /**
  34832. * Occurs when the file being loaded is a .3dl LUT file.
  34833. */
  34834. private load3dlTexture();
  34835. /**
  34836. * Starts the loading process of the texture.
  34837. */
  34838. private loadTexture();
  34839. /**
  34840. * Clones the color gradind texture.
  34841. */
  34842. clone(): ColorGradingTexture;
  34843. /**
  34844. * Called during delayed load for textures.
  34845. */
  34846. delayLoad(): void;
  34847. /**
  34848. * Parses a color grading texture serialized by Babylon.
  34849. * @param parsedTexture The texture information being parsedTexture
  34850. * @param scene The scene to load the texture in
  34851. * @param rootUrl The root url of the data assets to load
  34852. * @return A color gradind texture
  34853. */
  34854. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  34855. /**
  34856. * Serializes the LUT texture to json format.
  34857. */
  34858. serialize(): any;
  34859. }
  34860. }
  34861. declare module BABYLON {
  34862. class CubeTexture extends BaseTexture {
  34863. url: string;
  34864. /**
  34865. * Gets or sets the center of the bounding box associated with the cube texture
  34866. * It must define where the camera used to render the texture was set
  34867. */
  34868. boundingBoxPosition: Vector3;
  34869. private _boundingBoxSize;
  34870. /**
  34871. * Gets or sets the size of the bounding box associated with the cube texture
  34872. * When defined, the cubemap will switch to local mode
  34873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  34874. * @example https://www.babylonjs-playground.com/#RNASML
  34875. */
  34876. boundingBoxSize: Vector3;
  34877. protected _rotationY: number;
  34878. /**
  34879. * Gets texture matrix rotation angle around Y axis radians.
  34880. */
  34881. /**
  34882. * Sets texture matrix rotation angle around Y axis in radians.
  34883. */
  34884. rotationY: number;
  34885. private _noMipmap;
  34886. private _files;
  34887. private _extensions;
  34888. private _textureMatrix;
  34889. private _format;
  34890. private _createPolynomials;
  34891. /** @hidden */
  34892. readonly _prefiltered: boolean;
  34893. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  34894. /**
  34895. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  34896. * @param url defines the url of the prefiltered texture
  34897. * @param scene defines the scene the texture is attached to
  34898. * @param forcedExtension defines the extension of the file if different from the url
  34899. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34900. * @return the prefiltered texture
  34901. */
  34902. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  34903. /**
  34904. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  34905. * as prefiltered data.
  34906. * @param rootUrl defines the url of the texture or the root name of the six images
  34907. * @param scene defines the scene the texture is attached to
  34908. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  34909. * @param noMipmap defines if mipmaps should be created or not
  34910. * @param files defines the six files to load for the different faces
  34911. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  34912. * @param onError defines a callback triggered in case of error during load
  34913. * @param format defines the internal format to use for the texture once loaded
  34914. * @param prefiltered defines whether or not the texture is created from prefiltered data
  34915. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  34916. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  34917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  34918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  34919. * @return the cube texture
  34920. */
  34921. 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);
  34922. delayLoad(): void;
  34923. getReflectionTextureMatrix(): Matrix;
  34924. setReflectionTextureMatrix(value: Matrix): void;
  34925. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  34926. clone(): CubeTexture;
  34927. }
  34928. }
  34929. declare module BABYLON {
  34930. /**
  34931. * A class extending {BABYLON.Texture} allowing drawing on a texture
  34932. * @see http://doc.babylonjs.com/how_to/dynamictexture
  34933. */
  34934. class DynamicTexture extends Texture {
  34935. private _generateMipMaps;
  34936. private _canvas;
  34937. private _context;
  34938. private _engine;
  34939. /**
  34940. * Creates a {BABYLON.DynamicTexture}
  34941. * @param name defines the name of the texture
  34942. * @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
  34943. * @param scene defines the scene where you want the texture
  34944. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  34945. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  34946. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  34947. */
  34948. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  34949. /**
  34950. * Gets the current state of canRescale
  34951. */
  34952. readonly canRescale: boolean;
  34953. private _recreate(textureSize);
  34954. /**
  34955. * Scales the texture
  34956. * @param ratio the scale factor to apply to both width and height
  34957. */
  34958. scale(ratio: number): void;
  34959. /**
  34960. * Resizes the texture
  34961. * @param width the new width
  34962. * @param height the new height
  34963. */
  34964. scaleTo(width: number, height: number): void;
  34965. /**
  34966. * Gets the context of the canvas used by the texture
  34967. * @returns the canvas context of the dynamic texture
  34968. */
  34969. getContext(): CanvasRenderingContext2D;
  34970. /**
  34971. * Clears the texture
  34972. */
  34973. clear(): void;
  34974. /**
  34975. * Updates the texture
  34976. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34977. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  34978. */
  34979. update(invertY?: boolean, premulAlpha?: boolean): void;
  34980. /**
  34981. * Draws text onto the texture
  34982. * @param text defines the text to be drawn
  34983. * @param x defines the placement of the text from the left
  34984. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  34985. * @param font defines the font to be used with font-style, font-size, font-name
  34986. * @param color defines the color used for the text
  34987. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  34988. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  34989. * @param update defines whether texture is immediately update (default is true)
  34990. */
  34991. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  34992. /**
  34993. * Clones the texture
  34994. * @returns the clone of the texture.
  34995. */
  34996. clone(): DynamicTexture;
  34997. /** @hidden */
  34998. _rebuild(): void;
  34999. }
  35000. }
  35001. declare module BABYLON {
  35002. /**
  35003. * This represents a texture coming from an HDR input.
  35004. *
  35005. * The only supported format is currently panorama picture stored in RGBE format.
  35006. * Example of such files can be found on HDRLib: http://hdrlib.com/
  35007. */
  35008. class HDRCubeTexture extends BaseTexture {
  35009. private static _facesMapping;
  35010. private _generateHarmonics;
  35011. private _noMipmap;
  35012. private _textureMatrix;
  35013. private _size;
  35014. private _onLoad;
  35015. private _onError;
  35016. /**
  35017. * The texture URL.
  35018. */
  35019. url: string;
  35020. /**
  35021. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  35022. */
  35023. coordinatesMode: number;
  35024. protected _isBlocking: boolean;
  35025. /**
  35026. * Gets wether or not the texture is blocking during loading.
  35027. */
  35028. /**
  35029. * Sets wether or not the texture is blocking during loading.
  35030. */
  35031. isBlocking: boolean;
  35032. protected _rotationY: number;
  35033. /**
  35034. * Gets texture matrix rotation angle around Y axis radians.
  35035. */
  35036. /**
  35037. * Sets texture matrix rotation angle around Y axis in radians.
  35038. */
  35039. rotationY: number;
  35040. /**
  35041. * Gets or sets the center of the bounding box associated with the cube texture
  35042. * It must define where the camera used to render the texture was set
  35043. */
  35044. boundingBoxPosition: Vector3;
  35045. private _boundingBoxSize;
  35046. /**
  35047. * Gets or sets the size of the bounding box associated with the cube texture
  35048. * When defined, the cubemap will switch to local mode
  35049. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35050. * @example https://www.babylonjs-playground.com/#RNASML
  35051. */
  35052. boundingBoxSize: Vector3;
  35053. /**
  35054. * Instantiates an HDRTexture from the following parameters.
  35055. *
  35056. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  35057. * @param scene The scene the texture will be used in
  35058. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  35059. * @param noMipmap Forces to not generate the mipmap if true
  35060. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  35061. * @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)
  35062. * @param reserved Reserved flag for internal use.
  35063. */
  35064. 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>);
  35065. /**
  35066. * Occurs when the file is raw .hdr file.
  35067. */
  35068. private loadTexture();
  35069. clone(): HDRCubeTexture;
  35070. delayLoad(): void;
  35071. getReflectionTextureMatrix(): Matrix;
  35072. setReflectionTextureMatrix(value: Matrix): void;
  35073. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  35074. serialize(): any;
  35075. }
  35076. }
  35077. declare module BABYLON {
  35078. /**
  35079. * Class used to store data associated with WebGL texture data for the engine
  35080. * This class should not be used directly
  35081. */
  35082. class InternalTexture implements IInternalTextureTracker {
  35083. /**
  35084. * The source of the texture data is unknown
  35085. */
  35086. static DATASOURCE_UNKNOWN: number;
  35087. /**
  35088. * Texture data comes from an URL
  35089. */
  35090. static DATASOURCE_URL: number;
  35091. /**
  35092. * Texture data is only used for temporary storage
  35093. */
  35094. static DATASOURCE_TEMP: number;
  35095. /**
  35096. * Texture data comes from raw data (ArrayBuffer)
  35097. */
  35098. static DATASOURCE_RAW: number;
  35099. /**
  35100. * Texture content is dynamic (video or dynamic texture)
  35101. */
  35102. static DATASOURCE_DYNAMIC: number;
  35103. /**
  35104. * Texture content is generated by rendering to it
  35105. */
  35106. static DATASOURCE_RENDERTARGET: number;
  35107. /**
  35108. * Texture content is part of a multi render target process
  35109. */
  35110. static DATASOURCE_MULTIRENDERTARGET: number;
  35111. /**
  35112. * Texture data comes from a cube data file
  35113. */
  35114. static DATASOURCE_CUBE: number;
  35115. /**
  35116. * Texture data comes from a raw cube data
  35117. */
  35118. static DATASOURCE_CUBERAW: number;
  35119. /**
  35120. * Texture data come from a prefiltered cube data file
  35121. */
  35122. static DATASOURCE_CUBEPREFILTERED: number;
  35123. /**
  35124. * Texture content is raw 3D data
  35125. */
  35126. static DATASOURCE_RAW3D: number;
  35127. /**
  35128. * Texture content is a depth texture
  35129. */
  35130. static DATASOURCE_DEPTHTEXTURE: number;
  35131. /**
  35132. * Texture data comes from a raw cube data encoded with RGBD
  35133. */
  35134. static DATASOURCE_CUBERAW_RGBD: number;
  35135. /**
  35136. * Defines if the texture is ready
  35137. */
  35138. isReady: boolean;
  35139. /**
  35140. * Defines if the texture is a cube texture
  35141. */
  35142. isCube: boolean;
  35143. /**
  35144. * Defines if the texture contains 3D data
  35145. */
  35146. is3D: boolean;
  35147. /**
  35148. * Gets the URL used to load this texture
  35149. */
  35150. url: string;
  35151. /**
  35152. * Gets the sampling mode of the texture
  35153. */
  35154. samplingMode: number;
  35155. /**
  35156. * Gets a boolean indicating if the texture needs mipmaps generation
  35157. */
  35158. generateMipMaps: boolean;
  35159. /**
  35160. * Gets the number of samples used by the texture (WebGL2+ only)
  35161. */
  35162. samples: number;
  35163. /**
  35164. * Gets the type of the texture
  35165. */
  35166. type: number;
  35167. /**
  35168. * Gets the format of the texture
  35169. */
  35170. format: number;
  35171. /**
  35172. * Observable called when the texture is loaded
  35173. */
  35174. onLoadedObservable: Observable<InternalTexture>;
  35175. /**
  35176. * Gets the width of the texture
  35177. */
  35178. width: number;
  35179. /**
  35180. * Gets the height of the texture
  35181. */
  35182. height: number;
  35183. /**
  35184. * Gets the depth of the texture
  35185. */
  35186. depth: number;
  35187. /**
  35188. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35189. */
  35190. baseWidth: number;
  35191. /**
  35192. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35193. */
  35194. baseHeight: number;
  35195. /**
  35196. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35197. */
  35198. baseDepth: number;
  35199. /**
  35200. * Gets a boolean indicating if the texture is inverted on Y axis
  35201. */
  35202. invertY: boolean;
  35203. /**
  35204. * Gets or set the previous tracker in the list
  35205. */
  35206. previous: Nullable<IInternalTextureTracker>;
  35207. /**
  35208. * Gets or set the next tracker in the list
  35209. */
  35210. next: Nullable<IInternalTextureTracker>;
  35211. /** @hidden */
  35212. _initialSlot: number;
  35213. /** @hidden */
  35214. _designatedSlot: number;
  35215. /** @hidden */
  35216. _dataSource: number;
  35217. /** @hidden */
  35218. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35219. /** @hidden */
  35220. _bufferView: Nullable<ArrayBufferView>;
  35221. /** @hidden */
  35222. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35223. /** @hidden */
  35224. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35225. /** @hidden */
  35226. _size: number;
  35227. /** @hidden */
  35228. _extension: string;
  35229. /** @hidden */
  35230. _files: Nullable<string[]>;
  35231. /** @hidden */
  35232. _workingCanvas: HTMLCanvasElement;
  35233. /** @hidden */
  35234. _workingContext: CanvasRenderingContext2D;
  35235. /** @hidden */
  35236. _framebuffer: Nullable<WebGLFramebuffer>;
  35237. /** @hidden */
  35238. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35239. /** @hidden */
  35240. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35241. /** @hidden */
  35242. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35243. /** @hidden */
  35244. _attachments: Nullable<number[]>;
  35245. /** @hidden */
  35246. _cachedCoordinatesMode: Nullable<number>;
  35247. /** @hidden */
  35248. _cachedWrapU: Nullable<number>;
  35249. /** @hidden */
  35250. _cachedWrapV: Nullable<number>;
  35251. /** @hidden */
  35252. _cachedWrapR: Nullable<number>;
  35253. /** @hidden */
  35254. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35255. /** @hidden */
  35256. _isDisabled: boolean;
  35257. /** @hidden */
  35258. _compression: Nullable<string>;
  35259. /** @hidden */
  35260. _generateStencilBuffer: boolean;
  35261. /** @hidden */
  35262. _generateDepthBuffer: boolean;
  35263. /** @hidden */
  35264. _comparisonFunction: number;
  35265. /** @hidden */
  35266. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35267. /** @hidden */
  35268. _lodGenerationScale: number;
  35269. /** @hidden */
  35270. _lodGenerationOffset: number;
  35271. /** @hidden */
  35272. _lodTextureHigh: BaseTexture;
  35273. /** @hidden */
  35274. _lodTextureMid: BaseTexture;
  35275. /** @hidden */
  35276. _lodTextureLow: BaseTexture;
  35277. /** @hidden */
  35278. _isRGBD: boolean;
  35279. /** @hidden */
  35280. _webGLTexture: Nullable<WebGLTexture>;
  35281. /** @hidden */
  35282. _references: number;
  35283. private _engine;
  35284. /**
  35285. * Gets the Engine the texture belongs to.
  35286. * @returns The babylon engine
  35287. */
  35288. getEngine(): Engine;
  35289. /**
  35290. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  35291. */
  35292. readonly dataSource: number;
  35293. /**
  35294. * Creates a new InternalTexture
  35295. * @param engine defines the engine to use
  35296. * @param dataSource defines the type of data that will be used
  35297. */
  35298. constructor(engine: Engine, dataSource: number);
  35299. /**
  35300. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  35301. */
  35302. incrementReferences(): void;
  35303. /**
  35304. * Change the size of the texture (not the size of the content)
  35305. * @param width defines the new width
  35306. * @param height defines the new height
  35307. * @param depth defines the new depth (1 by default)
  35308. */
  35309. updateSize(width: int, height: int, depth?: int): void;
  35310. /** @hidden */
  35311. _rebuild(): void;
  35312. _swapAndDie(target: InternalTexture): void;
  35313. /**
  35314. * Dispose the current allocated resources
  35315. */
  35316. dispose(): void;
  35317. }
  35318. }
  35319. declare module BABYLON {
  35320. /**
  35321. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  35322. */
  35323. interface IInternalTextureTracker {
  35324. /**
  35325. * Gets or set the previous tracker in the list
  35326. */
  35327. previous: Nullable<IInternalTextureTracker>;
  35328. /**
  35329. * Gets or set the next tracker in the list
  35330. */
  35331. next: Nullable<IInternalTextureTracker>;
  35332. }
  35333. /**
  35334. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  35335. */
  35336. class DummyInternalTextureTracker {
  35337. /**
  35338. * Gets or set the previous tracker in the list
  35339. */
  35340. previous: Nullable<IInternalTextureTracker>;
  35341. /**
  35342. * Gets or set the next tracker in the list
  35343. */
  35344. next: Nullable<IInternalTextureTracker>;
  35345. }
  35346. }
  35347. declare module BABYLON {
  35348. class MirrorTexture extends RenderTargetTexture {
  35349. private scene;
  35350. mirrorPlane: Plane;
  35351. private _transformMatrix;
  35352. private _mirrorMatrix;
  35353. private _savedViewMatrix;
  35354. private _blurX;
  35355. private _blurY;
  35356. private _adaptiveBlurKernel;
  35357. private _blurKernelX;
  35358. private _blurKernelY;
  35359. private _blurRatio;
  35360. blurRatio: number;
  35361. adaptiveBlurKernel: number;
  35362. blurKernel: number;
  35363. blurKernelX: number;
  35364. blurKernelY: number;
  35365. private _autoComputeBlurKernel();
  35366. protected _onRatioRescale(): void;
  35367. private _updateGammaSpace();
  35368. private _imageProcessingConfigChangeObserver;
  35369. constructor(name: string, size: number | {
  35370. width: number;
  35371. height: number;
  35372. } | {
  35373. ratio: number;
  35374. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  35375. private _preparePostProcesses();
  35376. clone(): MirrorTexture;
  35377. serialize(): any;
  35378. dispose(): void;
  35379. }
  35380. }
  35381. declare module BABYLON {
  35382. interface IMultiRenderTargetOptions {
  35383. generateMipMaps?: boolean;
  35384. types?: number[];
  35385. samplingModes?: number[];
  35386. generateDepthBuffer?: boolean;
  35387. generateStencilBuffer?: boolean;
  35388. generateDepthTexture?: boolean;
  35389. textureCount?: number;
  35390. doNotChangeAspectRatio?: boolean;
  35391. defaultType?: number;
  35392. }
  35393. class MultiRenderTarget extends RenderTargetTexture {
  35394. private _internalTextures;
  35395. private _textures;
  35396. readonly isSupported: boolean;
  35397. private _multiRenderTargetOptions;
  35398. readonly textures: Texture[];
  35399. readonly depthTexture: Texture;
  35400. wrapU: number;
  35401. wrapV: number;
  35402. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  35403. _rebuild(): void;
  35404. private _createInternalTextures();
  35405. private _createTextures();
  35406. samples: number;
  35407. resize(size: any): void;
  35408. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35409. dispose(): void;
  35410. releaseInternalTextures(): void;
  35411. }
  35412. }
  35413. declare module BABYLON {
  35414. /**
  35415. * Raw cube texture where the raw buffers are passed in
  35416. */
  35417. class RawCubeTexture extends CubeTexture {
  35418. /**
  35419. * Creates a cube texture where the raw buffers are passed in.
  35420. * @param scene defines the scene the texture is attached to
  35421. * @param data defines the array of data to use to create each face
  35422. * @param size defines the size of the textures
  35423. * @param format defines the format of the data
  35424. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  35425. * @param generateMipMaps defines if the engine should generate the mip levels
  35426. * @param invertY defines if data must be stored with Y axis inverted
  35427. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  35428. * @param compression defines the compression used (null by default)
  35429. */
  35430. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  35431. /**
  35432. * Updates the raw cube texture.
  35433. * @param data defines the data to store
  35434. * @param format defines the data format
  35435. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35436. * @param invertY defines if data must be stored with Y axis inverted
  35437. * @param compression defines the compression used (null by default)
  35438. * @param level defines which level of the texture to update
  35439. */
  35440. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  35441. /**
  35442. * Updates a raw cube texture with RGBD encoded data.
  35443. * @param data defines the array of data [mipmap][face] to use to create each face
  35444. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  35445. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35446. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35447. * @returns a promsie that resolves when the operation is complete
  35448. */
  35449. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  35450. /**
  35451. * Clones the raw cube texture.
  35452. * @return a new cube texture
  35453. */
  35454. clone(): CubeTexture;
  35455. /** @hidden */
  35456. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  35457. }
  35458. }
  35459. declare module BABYLON {
  35460. class RawTexture extends Texture {
  35461. format: number;
  35462. private _engine;
  35463. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  35464. update(data: ArrayBufferView): void;
  35465. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35466. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35467. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  35468. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35469. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35470. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  35471. }
  35472. }
  35473. declare module BABYLON {
  35474. /**
  35475. * Class used to store 3D textures containing user data
  35476. */
  35477. class RawTexture3D extends Texture {
  35478. /** Gets or sets the texture format to use */
  35479. format: number;
  35480. private _engine;
  35481. /**
  35482. * Create a new RawTexture3D
  35483. * @param data defines the data of the texture
  35484. * @param width defines the width of the texture
  35485. * @param height defines the height of the texture
  35486. * @param depth defines the depth of the texture
  35487. * @param format defines the texture format to use
  35488. * @param scene defines the hosting scene
  35489. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  35490. * @param invertY defines if texture must be stored with Y axis inverted
  35491. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  35492. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  35493. */
  35494. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  35495. /** Gets or sets the texture format to use */
  35496. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  35497. /**
  35498. * Update the texture with new data
  35499. * @param data defines the data to store in the texture
  35500. */
  35501. update(data: ArrayBufferView): void;
  35502. }
  35503. }
  35504. declare module BABYLON {
  35505. /**
  35506. * Creates a refraction texture used by refraction channel of the standard material.
  35507. * @param name the texture name
  35508. * @param size size of the underlying texture
  35509. * @param scene root scene
  35510. */
  35511. class RefractionTexture extends RenderTargetTexture {
  35512. refractionPlane: Plane;
  35513. depth: number;
  35514. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  35515. clone(): RefractionTexture;
  35516. serialize(): any;
  35517. }
  35518. }
  35519. declare module BABYLON {
  35520. class RenderTargetTexture extends Texture {
  35521. isCube: boolean;
  35522. static _REFRESHRATE_RENDER_ONCE: number;
  35523. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35524. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35525. static readonly REFRESHRATE_RENDER_ONCE: number;
  35526. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  35527. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  35528. /**
  35529. * Use this predicate to dynamically define the list of mesh you want to render.
  35530. * If set, the renderList property will be overwritten.
  35531. */
  35532. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  35533. /**
  35534. * Use this list to define the list of mesh you want to render.
  35535. */
  35536. renderList: Nullable<Array<AbstractMesh>>;
  35537. renderParticles: boolean;
  35538. renderSprites: boolean;
  35539. coordinatesMode: number;
  35540. activeCamera: Nullable<Camera>;
  35541. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  35542. useCameraPostProcesses: boolean;
  35543. ignoreCameraViewport: boolean;
  35544. private _postProcessManager;
  35545. private _postProcesses;
  35546. private _resizeObserver;
  35547. /**
  35548. * An event triggered when the texture is unbind.
  35549. */
  35550. onBeforeBindObservable: Observable<RenderTargetTexture>;
  35551. /**
  35552. * An event triggered when the texture is unbind.
  35553. */
  35554. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  35555. private _onAfterUnbindObserver;
  35556. onAfterUnbind: () => void;
  35557. /**
  35558. * An event triggered before rendering the texture
  35559. */
  35560. onBeforeRenderObservable: Observable<number>;
  35561. private _onBeforeRenderObserver;
  35562. onBeforeRender: (faceIndex: number) => void;
  35563. /**
  35564. * An event triggered after rendering the texture
  35565. */
  35566. onAfterRenderObservable: Observable<number>;
  35567. private _onAfterRenderObserver;
  35568. onAfterRender: (faceIndex: number) => void;
  35569. /**
  35570. * An event triggered after the texture clear
  35571. */
  35572. onClearObservable: Observable<Engine>;
  35573. private _onClearObserver;
  35574. onClear: (Engine: Engine) => void;
  35575. clearColor: Color4;
  35576. protected _size: number | {
  35577. width: number;
  35578. height: number;
  35579. };
  35580. protected _initialSizeParameter: number | {
  35581. width: number;
  35582. height: number;
  35583. } | {
  35584. ratio: number;
  35585. };
  35586. protected _sizeRatio: Nullable<number>;
  35587. _generateMipMaps: boolean;
  35588. protected _renderingManager: RenderingManager;
  35589. _waitingRenderList: string[];
  35590. protected _doNotChangeAspectRatio: boolean;
  35591. protected _currentRefreshId: number;
  35592. protected _refreshRate: number;
  35593. protected _textureMatrix: Matrix;
  35594. protected _samples: number;
  35595. protected _renderTargetOptions: RenderTargetCreationOptions;
  35596. readonly renderTargetOptions: RenderTargetCreationOptions;
  35597. protected _engine: Engine;
  35598. protected _onRatioRescale(): void;
  35599. /**
  35600. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  35601. * It must define where the camera used to render the texture is set
  35602. */
  35603. boundingBoxPosition: Vector3;
  35604. private _boundingBoxSize;
  35605. /**
  35606. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  35607. * When defined, the cubemap will switch to local mode
  35608. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35609. * @example https://www.babylonjs-playground.com/#RNASML
  35610. */
  35611. boundingBoxSize: Vector3;
  35612. /**
  35613. * In case the RTT has been created with a depth texture, get the associated
  35614. * depth texture.
  35615. * Otherwise, return null.
  35616. */
  35617. depthStencilTexture: Nullable<InternalTexture>;
  35618. /**
  35619. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  35620. * or used a shadow, depth texture...
  35621. * @param name The friendly name of the texture
  35622. * @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)
  35623. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  35624. * @param generateMipMaps True if mip maps need to be generated after render.
  35625. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  35626. * @param type The type of the buffer in the RTT (int, half float, float...)
  35627. * @param isCube True if a cube texture needs to be created
  35628. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  35629. * @param generateDepthBuffer True to generate a depth buffer
  35630. * @param generateStencilBuffer True to generate a stencil buffer
  35631. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  35632. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  35633. */
  35634. constructor(name: string, size: number | {
  35635. width: number;
  35636. height: number;
  35637. } | {
  35638. ratio: number;
  35639. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  35640. /**
  35641. * Creates a depth stencil texture.
  35642. * This is only available in WebGL 2 or with the depth texture extension available.
  35643. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  35644. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  35645. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  35646. */
  35647. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  35648. private _processSizeParameter(size);
  35649. samples: number;
  35650. resetRefreshCounter(): void;
  35651. refreshRate: number;
  35652. addPostProcess(postProcess: PostProcess): void;
  35653. clearPostProcesses(dispose?: boolean): void;
  35654. removePostProcess(postProcess: PostProcess): void;
  35655. _shouldRender(): boolean;
  35656. getRenderSize(): number;
  35657. getRenderWidth(): number;
  35658. getRenderHeight(): number;
  35659. readonly canRescale: boolean;
  35660. scale(ratio: number): void;
  35661. getReflectionTextureMatrix(): Matrix;
  35662. resize(size: number | {
  35663. width: number;
  35664. height: number;
  35665. } | {
  35666. ratio: number;
  35667. }): void;
  35668. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  35669. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  35670. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  35671. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  35672. /**
  35673. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35674. * This allowed control for front to back rendering or reversly depending of the special needs.
  35675. *
  35676. * @param renderingGroupId The rendering group id corresponding to its index
  35677. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35678. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35679. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35680. */
  35681. 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;
  35682. /**
  35683. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35684. *
  35685. * @param renderingGroupId The rendering group id corresponding to its index
  35686. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35687. */
  35688. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  35689. clone(): RenderTargetTexture;
  35690. serialize(): any;
  35691. disposeFramebufferObjects(): void;
  35692. dispose(): void;
  35693. _rebuild(): void;
  35694. /**
  35695. * Clear the info related to rendering groups preventing retention point in material dispose.
  35696. */
  35697. freeRenderingGroups(): void;
  35698. }
  35699. }
  35700. declare module BABYLON {
  35701. class Texture extends BaseTexture {
  35702. static NEAREST_SAMPLINGMODE: number;
  35703. static NEAREST_NEAREST_MIPLINEAR: number;
  35704. static BILINEAR_SAMPLINGMODE: number;
  35705. static LINEAR_LINEAR_MIPNEAREST: number;
  35706. static TRILINEAR_SAMPLINGMODE: number;
  35707. static LINEAR_LINEAR_MIPLINEAR: number;
  35708. static NEAREST_NEAREST_MIPNEAREST: number;
  35709. static NEAREST_LINEAR_MIPNEAREST: number;
  35710. static NEAREST_LINEAR_MIPLINEAR: number;
  35711. static NEAREST_LINEAR: number;
  35712. static NEAREST_NEAREST: number;
  35713. static LINEAR_NEAREST_MIPNEAREST: number;
  35714. static LINEAR_NEAREST_MIPLINEAR: number;
  35715. static LINEAR_LINEAR: number;
  35716. static LINEAR_NEAREST: number;
  35717. static EXPLICIT_MODE: number;
  35718. static SPHERICAL_MODE: number;
  35719. static PLANAR_MODE: number;
  35720. static CUBIC_MODE: number;
  35721. static PROJECTION_MODE: number;
  35722. static SKYBOX_MODE: number;
  35723. static INVCUBIC_MODE: number;
  35724. static EQUIRECTANGULAR_MODE: number;
  35725. static FIXED_EQUIRECTANGULAR_MODE: number;
  35726. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  35727. static CLAMP_ADDRESSMODE: number;
  35728. static WRAP_ADDRESSMODE: number;
  35729. static MIRROR_ADDRESSMODE: number;
  35730. /**
  35731. * 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
  35732. */
  35733. static UseSerializedUrlIfAny: boolean;
  35734. url: Nullable<string>;
  35735. uOffset: number;
  35736. vOffset: number;
  35737. uScale: number;
  35738. vScale: number;
  35739. uAng: number;
  35740. vAng: number;
  35741. wAng: number;
  35742. /**
  35743. * Defines the center of rotation (U)
  35744. */
  35745. uRotationCenter: number;
  35746. /**
  35747. * Defines the center of rotation (V)
  35748. */
  35749. vRotationCenter: number;
  35750. /**
  35751. * Defines the center of rotation (W)
  35752. */
  35753. wRotationCenter: number;
  35754. readonly noMipmap: boolean;
  35755. private _noMipmap;
  35756. _invertY: boolean;
  35757. private _rowGenerationMatrix;
  35758. private _cachedTextureMatrix;
  35759. private _projectionModeMatrix;
  35760. private _t0;
  35761. private _t1;
  35762. private _t2;
  35763. private _cachedUOffset;
  35764. private _cachedVOffset;
  35765. private _cachedUScale;
  35766. private _cachedVScale;
  35767. private _cachedUAng;
  35768. private _cachedVAng;
  35769. private _cachedWAng;
  35770. private _cachedProjectionMatrixId;
  35771. private _cachedCoordinatesMode;
  35772. _samplingMode: number;
  35773. /** @hidden */
  35774. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35775. private _deleteBuffer;
  35776. protected _format: Nullable<number>;
  35777. private _delayedOnLoad;
  35778. private _delayedOnError;
  35779. protected _onLoadObservable: Nullable<Observable<Texture>>;
  35780. protected _isBlocking: boolean;
  35781. isBlocking: boolean;
  35782. readonly samplingMode: number;
  35783. 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);
  35784. /**
  35785. * Update the url (and optional buffer) of this texture if url was null during construction.
  35786. * @param url the url of the texture
  35787. * @param buffer the buffer of the texture (defaults to null)
  35788. */
  35789. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  35790. delayLoad(): void;
  35791. updateSamplingMode(samplingMode: number): void;
  35792. private _prepareRowForTextureGeneration(x, y, z, t);
  35793. getTextureMatrix(): Matrix;
  35794. getReflectionTextureMatrix(): Matrix;
  35795. clone(): Texture;
  35796. readonly onLoadObservable: Observable<Texture>;
  35797. serialize(): any;
  35798. getClassName(): string;
  35799. dispose(): void;
  35800. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  35801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  35802. 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;
  35803. }
  35804. }
  35805. declare module BABYLON {
  35806. /**
  35807. * Settings for finer control over video usage
  35808. */
  35809. interface VideoTextureSettings {
  35810. /**
  35811. * Applies `autoplay` to video, if specified
  35812. */
  35813. autoPlay?: boolean;
  35814. /**
  35815. * Applies `loop` to video, if specified
  35816. */
  35817. loop?: boolean;
  35818. /**
  35819. * Automatically updates internal texture from video at every frame in the render loop
  35820. */
  35821. autoUpdateTexture: boolean;
  35822. /**
  35823. * Image src displayed during the video loading or until the user interacts with the video.
  35824. */
  35825. poster?: string;
  35826. }
  35827. class VideoTexture extends Texture {
  35828. /**
  35829. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35830. */
  35831. readonly autoUpdateTexture: boolean;
  35832. /**
  35833. * The video instance used by the texture internally
  35834. */
  35835. readonly video: HTMLVideoElement;
  35836. private _onUserActionRequestedObservable;
  35837. readonly onUserActionRequestedObservable: Observable<Texture>;
  35838. private _generateMipMaps;
  35839. private _engine;
  35840. private _stillImageCaptured;
  35841. /**
  35842. * Creates a video texture.
  35843. * Sample : https://doc.babylonjs.com/how_to/video_texture
  35844. * @param {string | null} name optional name, will detect from video source, if not defined
  35845. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  35846. * @param {BABYLON.Scene} scene is obviously the current scene.
  35847. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35848. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  35849. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35850. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  35851. */
  35852. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35853. private _getName(src);
  35854. private _getVideo(src);
  35855. private _createInternalTexture;
  35856. private reset;
  35857. /**
  35858. * Internal method to initiate `update`.
  35859. */
  35860. _rebuild(): void;
  35861. /**
  35862. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35863. */
  35864. update(): void;
  35865. /**
  35866. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35867. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35868. */
  35869. updateTexture(isVisible: boolean): void;
  35870. protected _updateInternalTexture: (e?: Event | undefined) => void;
  35871. /**
  35872. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35873. * @param url New url.
  35874. */
  35875. updateURL(url: string): void;
  35876. dispose(): void;
  35877. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35878. minWidth: number;
  35879. maxWidth: number;
  35880. minHeight: number;
  35881. maxHeight: number;
  35882. deviceId: string;
  35883. }): void;
  35884. }
  35885. }
  35886. declare var DracoDecoderModule: any;
  35887. declare var WebAssembly: any;
  35888. declare module BABYLON {
  35889. /**
  35890. * Configuration for Draco compression
  35891. */
  35892. interface IDracoCompressionConfiguration {
  35893. /**
  35894. * Configuration for the decoder.
  35895. */
  35896. decoder?: {
  35897. /**
  35898. * The url to the WebAssembly module.
  35899. */
  35900. wasmUrl?: string;
  35901. /**
  35902. * The url to the WebAssembly binary.
  35903. */
  35904. wasmBinaryUrl?: string;
  35905. /**
  35906. * The url to the fallback JavaScript module.
  35907. */
  35908. fallbackUrl?: string;
  35909. };
  35910. }
  35911. /**
  35912. * Draco compression (https://google.github.io/draco/)
  35913. *
  35914. * This class wraps the Draco module.
  35915. *
  35916. * **Encoder**
  35917. *
  35918. * The encoder is not currently implemented.
  35919. *
  35920. * **Decoder**
  35921. *
  35922. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  35923. *
  35924. * To update the configuration, use the following code:
  35925. * ```javascript
  35926. * BABYLON.DracoCompression.Configuration = {
  35927. * decoder: {
  35928. * wasmUrl: "<url to the WebAssembly library>",
  35929. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  35930. * fallbackUrl: "<url to the fallback JavaScript library>",
  35931. * }
  35932. * };
  35933. * ```
  35934. *
  35935. * 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.
  35936. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  35937. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  35938. *
  35939. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  35940. * ```javascript
  35941. * var dracoCompression = new BABYLON.DracoCompression();
  35942. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  35943. * [BABYLON.VertexBuffer.PositionKind]: 0
  35944. * });
  35945. * ```
  35946. *
  35947. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  35948. */
  35949. class DracoCompression implements IDisposable {
  35950. private static _DecoderModulePromise;
  35951. /**
  35952. * The configuration. Defaults to the following urls:
  35953. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  35954. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  35955. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  35956. */
  35957. static Configuration: IDracoCompressionConfiguration;
  35958. /**
  35959. * Returns true if the decoder is available.
  35960. */
  35961. static readonly DecoderAvailable: boolean;
  35962. /**
  35963. * Constructor
  35964. */
  35965. constructor();
  35966. /**
  35967. * Stop all async operations and release resources.
  35968. */
  35969. dispose(): void;
  35970. /**
  35971. * Decode Draco compressed mesh data to vertex data.
  35972. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  35973. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  35974. * @returns A promise that resolves with the decoded vertex data
  35975. */
  35976. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  35977. [kind: string]: number;
  35978. }): Promise<VertexData>;
  35979. private static _GetDecoderModule();
  35980. private static _LoadScriptAsync(url);
  35981. private static _LoadFileAsync(url);
  35982. }
  35983. }
  35984. declare module BABYLON {
  35985. /**
  35986. * Particle emitter emitting particles from the inside of a box.
  35987. * It emits the particles randomly between 2 given directions.
  35988. */
  35989. class BoxParticleEmitter implements IParticleEmitterType {
  35990. /**
  35991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35992. */
  35993. direction1: Vector3;
  35994. /**
  35995. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  35996. */
  35997. direction2: Vector3;
  35998. /**
  35999. * 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.
  36000. */
  36001. minEmitBox: Vector3;
  36002. /**
  36003. * 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.
  36004. */
  36005. maxEmitBox: Vector3;
  36006. /**
  36007. * Creates a new instance BoxParticleEmitter
  36008. */
  36009. constructor();
  36010. /**
  36011. * Called by the particle System when the direction is computed for the created particle.
  36012. * @param worldMatrix is the world matrix of the particle system
  36013. * @param directionToUpdate is the direction vector to update with the result
  36014. * @param particle is the particle we are computed the direction for
  36015. */
  36016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36017. /**
  36018. * Called by the particle System when the position is computed for the created particle.
  36019. * @param worldMatrix is the world matrix of the particle system
  36020. * @param positionToUpdate is the position vector to update with the result
  36021. * @param particle is the particle we are computed the position for
  36022. */
  36023. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36024. /**
  36025. * Clones the current emitter and returns a copy of it
  36026. * @returns the new emitter
  36027. */
  36028. clone(): BoxParticleEmitter;
  36029. /**
  36030. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36031. * @param effect defines the update shader
  36032. */
  36033. applyToShader(effect: Effect): void;
  36034. /**
  36035. * Returns a string to use to update the GPU particles update shader
  36036. * @returns a string containng the defines string
  36037. */
  36038. getEffectDefines(): string;
  36039. /**
  36040. * Returns the string "BoxParticleEmitter"
  36041. * @returns a string containing the class name
  36042. */
  36043. getClassName(): string;
  36044. /**
  36045. * Serializes the particle system to a JSON object.
  36046. * @returns the JSON object
  36047. */
  36048. serialize(): any;
  36049. /**
  36050. * Parse properties from a JSON object
  36051. * @param serializationObject defines the JSON object
  36052. */
  36053. parse(serializationObject: any): void;
  36054. }
  36055. }
  36056. declare module BABYLON {
  36057. /**
  36058. * Particle emitter emitting particles from the inside of a cone.
  36059. * It emits the particles alongside the cone volume from the base to the particle.
  36060. * The emission direction might be randomized.
  36061. */
  36062. class ConeParticleEmitter implements IParticleEmitterType {
  36063. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36064. directionRandomizer: number;
  36065. private _radius;
  36066. private _angle;
  36067. private _height;
  36068. /**
  36069. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36070. */
  36071. radiusRange: number;
  36072. /**
  36073. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  36074. */
  36075. heightRange: number;
  36076. /**
  36077. * Gets or sets the radius of the emission cone
  36078. */
  36079. radius: number;
  36080. /**
  36081. * Gets or sets the angle of the emission cone
  36082. */
  36083. angle: number;
  36084. private _buildHeight();
  36085. /**
  36086. * Creates a new instance ConeParticleEmitter
  36087. * @param radius the radius of the emission cone (1 by default)
  36088. * @param angles the cone base angle (PI by default)
  36089. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  36090. */
  36091. constructor(radius?: number, angle?: number,
  36092. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36093. directionRandomizer?: number);
  36094. /**
  36095. * Called by the particle System when the direction is computed for the created particle.
  36096. * @param worldMatrix is the world matrix of the particle system
  36097. * @param directionToUpdate is the direction vector to update with the result
  36098. * @param particle is the particle we are computed the direction for
  36099. */
  36100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36101. /**
  36102. * Called by the particle System when the position is computed for the created particle.
  36103. * @param worldMatrix is the world matrix of the particle system
  36104. * @param positionToUpdate is the position vector to update with the result
  36105. * @param particle is the particle we are computed the position for
  36106. */
  36107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36108. /**
  36109. * Clones the current emitter and returns a copy of it
  36110. * @returns the new emitter
  36111. */
  36112. clone(): ConeParticleEmitter;
  36113. /**
  36114. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36115. * @param effect defines the update shader
  36116. */
  36117. applyToShader(effect: Effect): void;
  36118. /**
  36119. * Returns a string to use to update the GPU particles update shader
  36120. * @returns a string containng the defines string
  36121. */
  36122. getEffectDefines(): string;
  36123. /**
  36124. * Returns the string "ConeParticleEmitter"
  36125. * @returns a string containing the class name
  36126. */
  36127. getClassName(): string;
  36128. /**
  36129. * Serializes the particle system to a JSON object.
  36130. * @returns the JSON object
  36131. */
  36132. serialize(): any;
  36133. /**
  36134. * Parse properties from a JSON object
  36135. * @param serializationObject defines the JSON object
  36136. */
  36137. parse(serializationObject: any): void;
  36138. }
  36139. }
  36140. declare module BABYLON {
  36141. /**
  36142. * Particle emitter represents a volume emitting particles.
  36143. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  36144. */
  36145. interface IParticleEmitterType {
  36146. /**
  36147. * Called by the particle System when the direction is computed for the created particle.
  36148. * @param worldMatrix is the world matrix of the particle system
  36149. * @param directionToUpdate is the direction vector to update with the result
  36150. * @param particle is the particle we are computed the direction for
  36151. */
  36152. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36153. /**
  36154. * Called by the particle System when the position is computed for the created particle.
  36155. * @param worldMatrix is the world matrix of the particle system
  36156. * @param positionToUpdate is the position vector to update with the result
  36157. * @param particle is the particle we are computed the position for
  36158. */
  36159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36160. /**
  36161. * Clones the current emitter and returns a copy of it
  36162. * @returns the new emitter
  36163. */
  36164. clone(): IParticleEmitterType;
  36165. /**
  36166. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36167. * @param effect defines the update shader
  36168. */
  36169. applyToShader(effect: Effect): void;
  36170. /**
  36171. * Returns a string to use to update the GPU particles update shader
  36172. * @returns the effect defines string
  36173. */
  36174. getEffectDefines(): string;
  36175. /**
  36176. * Returns a string representing the class name
  36177. * @returns a string containing the class name
  36178. */
  36179. getClassName(): string;
  36180. /**
  36181. * Serializes the particle system to a JSON object.
  36182. * @returns the JSON object
  36183. */
  36184. serialize(): any;
  36185. /**
  36186. * Parse properties from a JSON object
  36187. * @param serializationObject defines the JSON object
  36188. */
  36189. parse(serializationObject: any): void;
  36190. }
  36191. }
  36192. declare module BABYLON {
  36193. /**
  36194. * Particle emitter emitting particles from the inside of a sphere.
  36195. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  36196. */
  36197. class SphereParticleEmitter implements IParticleEmitterType {
  36198. /**
  36199. * The radius of the emission sphere.
  36200. */
  36201. radius: number;
  36202. /**
  36203. * How much to randomize the particle direction [0-1].
  36204. */
  36205. directionRandomizer: number;
  36206. /**
  36207. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36208. */
  36209. radiusRange: number;
  36210. /**
  36211. * Creates a new instance SphereParticleEmitter
  36212. * @param radius the radius of the emission sphere (1 by default)
  36213. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  36214. */
  36215. constructor(
  36216. /**
  36217. * The radius of the emission sphere.
  36218. */
  36219. radius?: number,
  36220. /**
  36221. * How much to randomize the particle direction [0-1].
  36222. */
  36223. directionRandomizer?: number);
  36224. /**
  36225. * Called by the particle System when the direction is computed for the created particle.
  36226. * @param worldMatrix is the world matrix of the particle system
  36227. * @param directionToUpdate is the direction vector to update with the result
  36228. * @param particle is the particle we are computed the direction for
  36229. */
  36230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36231. /**
  36232. * Called by the particle System when the position is computed for the created particle.
  36233. * @param worldMatrix is the world matrix of the particle system
  36234. * @param positionToUpdate is the position vector to update with the result
  36235. * @param particle is the particle we are computed the position for
  36236. */
  36237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36238. /**
  36239. * Clones the current emitter and returns a copy of it
  36240. * @returns the new emitter
  36241. */
  36242. clone(): SphereParticleEmitter;
  36243. /**
  36244. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36245. * @param effect defines the update shader
  36246. */
  36247. applyToShader(effect: Effect): void;
  36248. /**
  36249. * Returns a string to use to update the GPU particles update shader
  36250. * @returns a string containng the defines string
  36251. */
  36252. getEffectDefines(): string;
  36253. /**
  36254. * Returns the string "SphereParticleEmitter"
  36255. * @returns a string containing the class name
  36256. */
  36257. getClassName(): string;
  36258. /**
  36259. * Serializes the particle system to a JSON object.
  36260. * @returns the JSON object
  36261. */
  36262. serialize(): any;
  36263. /**
  36264. * Parse properties from a JSON object
  36265. * @param serializationObject defines the JSON object
  36266. */
  36267. parse(serializationObject: any): void;
  36268. }
  36269. /**
  36270. * Particle emitter emitting particles from the inside of a sphere.
  36271. * It emits the particles randomly between two vectors.
  36272. */
  36273. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  36274. /**
  36275. * The min limit of the emission direction.
  36276. */
  36277. direction1: Vector3;
  36278. /**
  36279. * The max limit of the emission direction.
  36280. */
  36281. direction2: Vector3;
  36282. /**
  36283. * Creates a new instance SphereDirectedParticleEmitter
  36284. * @param radius the radius of the emission sphere (1 by default)
  36285. * @param direction1 the min limit of the emission direction (up vector by default)
  36286. * @param direction2 the max limit of the emission direction (up vector by default)
  36287. */
  36288. constructor(radius?: number,
  36289. /**
  36290. * The min limit of the emission direction.
  36291. */
  36292. direction1?: Vector3,
  36293. /**
  36294. * The max limit of the emission direction.
  36295. */
  36296. direction2?: Vector3);
  36297. /**
  36298. * Called by the particle System when the direction is computed for the created particle.
  36299. * @param worldMatrix is the world matrix of the particle system
  36300. * @param directionToUpdate is the direction vector to update with the result
  36301. * @param particle is the particle we are computed the direction for
  36302. */
  36303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36304. /**
  36305. * Clones the current emitter and returns a copy of it
  36306. * @returns the new emitter
  36307. */
  36308. clone(): SphereDirectedParticleEmitter;
  36309. /**
  36310. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  36311. * @param effect defines the update shader
  36312. */
  36313. applyToShader(effect: Effect): void;
  36314. /**
  36315. * Returns a string to use to update the GPU particles update shader
  36316. * @returns a string containng the defines string
  36317. */
  36318. getEffectDefines(): string;
  36319. /**
  36320. * Returns the string "SphereDirectedParticleEmitter"
  36321. * @returns a string containing the class name
  36322. */
  36323. getClassName(): string;
  36324. /**
  36325. * Serializes the particle system to a JSON object.
  36326. * @returns the JSON object
  36327. */
  36328. serialize(): any;
  36329. /**
  36330. * Parse properties from a JSON object
  36331. * @param serializationObject defines the JSON object
  36332. */
  36333. parse(serializationObject: any): void;
  36334. }
  36335. }
  36336. declare module BABYLON {
  36337. class CannonJSPlugin implements IPhysicsEnginePlugin {
  36338. private _useDeltaForWorldStep;
  36339. world: any;
  36340. name: string;
  36341. private _physicsMaterials;
  36342. private _fixedTimeStep;
  36343. BJSCANNON: any;
  36344. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  36345. setGravity(gravity: Vector3): void;
  36346. setTimeStep(timeStep: number): void;
  36347. getTimeStep(): number;
  36348. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36352. private _processChildMeshes(mainImpostor);
  36353. removePhysicsBody(impostor: PhysicsImpostor): void;
  36354. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36356. private _addMaterial(name, friction, restitution);
  36357. private _checkWithEpsilon(value);
  36358. private _createShape(impostor);
  36359. private _createHeightmap(object, pointDepth?);
  36360. private _minus90X;
  36361. private _plus90X;
  36362. private _tmpPosition;
  36363. private _tmpDeltaPosition;
  36364. private _tmpUnityRotation;
  36365. private _updatePhysicsBodyTransformation(impostor);
  36366. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36368. isSupported(): boolean;
  36369. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36370. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36371. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36372. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36373. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36374. getBodyMass(impostor: PhysicsImpostor): number;
  36375. getBodyFriction(impostor: PhysicsImpostor): number;
  36376. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36377. getBodyRestitution(impostor: PhysicsImpostor): number;
  36378. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36379. sleepBody(impostor: PhysicsImpostor): void;
  36380. wakeUpBody(impostor: PhysicsImpostor): void;
  36381. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36382. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  36383. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  36384. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36385. getRadius(impostor: PhysicsImpostor): number;
  36386. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36387. dispose(): void;
  36388. private _extendNamespace();
  36389. }
  36390. }
  36391. declare module BABYLON {
  36392. class OimoJSPlugin implements IPhysicsEnginePlugin {
  36393. world: any;
  36394. name: string;
  36395. BJSOIMO: any;
  36396. constructor(iterations?: number);
  36397. setGravity(gravity: Vector3): void;
  36398. setTimeStep(timeStep: number): void;
  36399. getTimeStep(): number;
  36400. private _tmpImpostorsArray;
  36401. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36402. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36403. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36404. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36405. private _tmpPositionVector;
  36406. removePhysicsBody(impostor: PhysicsImpostor): void;
  36407. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36408. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36409. isSupported(): boolean;
  36410. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36411. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36412. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36413. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36414. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36415. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36416. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36417. getBodyMass(impostor: PhysicsImpostor): number;
  36418. getBodyFriction(impostor: PhysicsImpostor): number;
  36419. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36420. getBodyRestitution(impostor: PhysicsImpostor): number;
  36421. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36422. sleepBody(impostor: PhysicsImpostor): void;
  36423. wakeUpBody(impostor: PhysicsImpostor): void;
  36424. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36425. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  36426. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  36427. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36428. getRadius(impostor: PhysicsImpostor): number;
  36429. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36430. dispose(): void;
  36431. }
  36432. }
  36433. declare module BABYLON {
  36434. /**
  36435. * This represents a set of one or more post processes in Babylon.
  36436. * A post process can be used to apply a shader to a texture after it is rendered.
  36437. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  36438. */
  36439. class PostProcessRenderEffect {
  36440. private _postProcesses;
  36441. private _getPostProcesses;
  36442. private _singleInstance;
  36443. private _cameras;
  36444. private _indicesForCamera;
  36445. /**
  36446. * Name of the effect
  36447. */
  36448. _name: string;
  36449. /**
  36450. * Instantiates a post process render effect.
  36451. * A post process can be used to apply a shader to a texture after it is rendered.
  36452. * @param engine The engine the effect is tied to
  36453. * @param name The name of the effect
  36454. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  36455. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  36456. */
  36457. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  36458. /**
  36459. * Checks if all the post processes in the effect are supported.
  36460. */
  36461. readonly isSupported: boolean;
  36462. /**
  36463. * Updates the current state of the effect
  36464. */
  36465. _update(): void;
  36466. /**
  36467. * Attaches the effect on cameras
  36468. * @param cameras The camera to attach to.
  36469. */
  36470. _attachCameras(cameras: Camera): void;
  36471. /**
  36472. * Attaches the effect on cameras
  36473. * @param cameras The camera to attach to.
  36474. */
  36475. _attachCameras(cameras: Camera[]): void;
  36476. /**
  36477. * Detatches the effect on cameras
  36478. * @param cameras The camera to detatch from.
  36479. */
  36480. _detachCameras(cameras: Camera): void;
  36481. /**
  36482. * Detatches the effect on cameras
  36483. * @param cameras The camera to detatch from.
  36484. */
  36485. _detachCameras(cameras: Camera[]): void;
  36486. /**
  36487. * Enables the effect on given cameras
  36488. * @param cameras The camera to enable.
  36489. */
  36490. _enable(cameras: Camera): void;
  36491. /**
  36492. * Enables the effect on given cameras
  36493. * @param cameras The camera to enable.
  36494. */
  36495. _enable(cameras: Nullable<Camera[]>): void;
  36496. /**
  36497. * Disables the effect on the given cameras
  36498. * @param cameras The camera to disable.
  36499. */
  36500. _disable(cameras: Camera): void;
  36501. /**
  36502. * Disables the effect on the given cameras
  36503. * @param cameras The camera to disable.
  36504. */
  36505. _disable(cameras: Nullable<Camera[]>): void;
  36506. /**
  36507. * Gets a list of the post processes contained in the effect.
  36508. * @param camera The camera to get the post processes on.
  36509. * @returns The list of the post processes in the effect.
  36510. */
  36511. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  36512. }
  36513. }
  36514. declare module BABYLON {
  36515. class PostProcessRenderPipeline {
  36516. private engine;
  36517. private _renderEffects;
  36518. private _renderEffectsForIsolatedPass;
  36519. protected _cameras: Camera[];
  36520. _name: string;
  36521. constructor(engine: Engine, name: string);
  36522. getClassName(): string;
  36523. readonly isSupported: boolean;
  36524. addEffect(renderEffect: PostProcessRenderEffect): void;
  36525. _rebuild(): void;
  36526. _enableEffect(renderEffectName: string, cameras: Camera): void;
  36527. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  36528. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36529. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  36530. _attachCameras(cameras: Camera, unique: boolean): void;
  36531. _attachCameras(cameras: Camera[], unique: boolean): void;
  36532. _detachCameras(cameras: Camera): void;
  36533. _detachCameras(cameras: Nullable<Camera[]>): void;
  36534. _update(): void;
  36535. _reset(): void;
  36536. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  36537. dispose(): void;
  36538. }
  36539. }
  36540. declare module BABYLON {
  36541. class PostProcessRenderPipelineManager {
  36542. private _renderPipelines;
  36543. constructor();
  36544. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  36545. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  36546. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  36547. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  36548. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  36549. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36550. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36551. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  36552. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  36553. update(): void;
  36554. _rebuild(): void;
  36555. dispose(): void;
  36556. }
  36557. }
  36558. declare module BABYLON {
  36559. /**
  36560. * Helper class dealing with the extraction of spherical polynomial dataArray
  36561. * from a cube map.
  36562. */
  36563. class CubeMapToSphericalPolynomialTools {
  36564. private static FileFaces;
  36565. /**
  36566. * Converts a texture to the according Spherical Polynomial data.
  36567. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36568. *
  36569. * @param texture The texture to extract the information from.
  36570. * @return The Spherical Polynomial data.
  36571. */
  36572. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  36573. /**
  36574. * Converts a cubemap to the according Spherical Polynomial data.
  36575. * This extracts the first 3 orders only as they are the only one used in the lighting.
  36576. *
  36577. * @param cubeInfo The Cube map to extract the information from.
  36578. * @return The Spherical Polynomial data.
  36579. */
  36580. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  36581. }
  36582. }
  36583. declare module BABYLON {
  36584. /**
  36585. * Header information of HDR texture files.
  36586. */
  36587. interface HDRInfo {
  36588. /**
  36589. * The height of the texture in pixels.
  36590. */
  36591. height: number;
  36592. /**
  36593. * The width of the texture in pixels.
  36594. */
  36595. width: number;
  36596. /**
  36597. * The index of the beginning of the data in the binary file.
  36598. */
  36599. dataPosition: number;
  36600. }
  36601. /**
  36602. * This groups tools to convert HDR texture to native colors array.
  36603. */
  36604. class HDRTools {
  36605. private static Ldexp(mantissa, exponent);
  36606. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  36607. private static readStringLine(uint8array, startIndex);
  36608. /**
  36609. * Reads header information from an RGBE texture stored in a native array.
  36610. * More information on this format are available here:
  36611. * https://en.wikipedia.org/wiki/RGBE_image_format
  36612. *
  36613. * @param uint8array The binary file stored in native array.
  36614. * @return The header information.
  36615. */
  36616. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  36617. /**
  36618. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  36619. * This RGBE texture needs to store the information as a panorama.
  36620. *
  36621. * More information on this format are available here:
  36622. * https://en.wikipedia.org/wiki/RGBE_image_format
  36623. *
  36624. * @param buffer The binary file stored in an array buffer.
  36625. * @param size The expected size of the extracted cubemap.
  36626. * @return The Cube Map information.
  36627. */
  36628. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  36629. /**
  36630. * Returns the pixels data extracted from an RGBE texture.
  36631. * This pixels will be stored left to right up to down in the R G B order in one array.
  36632. *
  36633. * More information on this format are available here:
  36634. * https://en.wikipedia.org/wiki/RGBE_image_format
  36635. *
  36636. * @param uint8array The binary file stored in an array buffer.
  36637. * @param hdrInfo The header information of the file.
  36638. * @return The pixels data in RGB right to left up to down order.
  36639. */
  36640. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  36641. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  36642. }
  36643. }
  36644. declare module BABYLON {
  36645. /**
  36646. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  36647. */
  36648. interface CubeMapInfo {
  36649. /**
  36650. * The pixel array for the front face.
  36651. * This is stored in format, left to right, up to down format.
  36652. */
  36653. front: Nullable<ArrayBufferView>;
  36654. /**
  36655. * The pixel array for the back face.
  36656. * This is stored in format, left to right, up to down format.
  36657. */
  36658. back: Nullable<ArrayBufferView>;
  36659. /**
  36660. * The pixel array for the left face.
  36661. * This is stored in format, left to right, up to down format.
  36662. */
  36663. left: Nullable<ArrayBufferView>;
  36664. /**
  36665. * The pixel array for the right face.
  36666. * This is stored in format, left to right, up to down format.
  36667. */
  36668. right: Nullable<ArrayBufferView>;
  36669. /**
  36670. * The pixel array for the up face.
  36671. * This is stored in format, left to right, up to down format.
  36672. */
  36673. up: Nullable<ArrayBufferView>;
  36674. /**
  36675. * The pixel array for the down face.
  36676. * This is stored in format, left to right, up to down format.
  36677. */
  36678. down: Nullable<ArrayBufferView>;
  36679. /**
  36680. * The size of the cubemap stored.
  36681. *
  36682. * Each faces will be size * size pixels.
  36683. */
  36684. size: number;
  36685. /**
  36686. * The format of the texture.
  36687. *
  36688. * RGBA, RGB.
  36689. */
  36690. format: number;
  36691. /**
  36692. * The type of the texture data.
  36693. *
  36694. * UNSIGNED_INT, FLOAT.
  36695. */
  36696. type: number;
  36697. /**
  36698. * Specifies whether the texture is in gamma space.
  36699. */
  36700. gammaSpace: boolean;
  36701. }
  36702. /**
  36703. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  36704. */
  36705. class PanoramaToCubeMapTools {
  36706. private static FACE_FRONT;
  36707. private static FACE_BACK;
  36708. private static FACE_RIGHT;
  36709. private static FACE_LEFT;
  36710. private static FACE_DOWN;
  36711. private static FACE_UP;
  36712. /**
  36713. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  36714. *
  36715. * @param float32Array The source data.
  36716. * @param inputWidth The width of the input panorama.
  36717. * @param inputhHeight The height of the input panorama.
  36718. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  36719. * @return The cubemap data
  36720. */
  36721. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  36722. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  36723. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  36724. }
  36725. }
  36726. declare module BABYLON {
  36727. class CustomProceduralTexture extends ProceduralTexture {
  36728. private _animate;
  36729. private _time;
  36730. private _config;
  36731. private _texturePath;
  36732. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  36733. private loadJson(jsonUrl);
  36734. isReady(): boolean;
  36735. render(useCameraPostProcess?: boolean): void;
  36736. updateTextures(): void;
  36737. updateShaderUniforms(): void;
  36738. animate: boolean;
  36739. }
  36740. }
  36741. declare module BABYLON {
  36742. class ProceduralTexture extends Texture {
  36743. isCube: boolean;
  36744. private _size;
  36745. _generateMipMaps: boolean;
  36746. isEnabled: boolean;
  36747. private _currentRefreshId;
  36748. private _refreshRate;
  36749. onGenerated: () => void;
  36750. private _vertexBuffers;
  36751. private _indexBuffer;
  36752. private _effect;
  36753. private _uniforms;
  36754. private _samplers;
  36755. private _fragment;
  36756. _textures: {
  36757. [key: string]: Texture;
  36758. };
  36759. private _floats;
  36760. private _floatsArrays;
  36761. private _colors3;
  36762. private _colors4;
  36763. private _vectors2;
  36764. private _vectors3;
  36765. private _matrices;
  36766. private _fallbackTexture;
  36767. private _fallbackTextureUsed;
  36768. private _engine;
  36769. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  36770. private _createIndexBuffer();
  36771. _rebuild(): void;
  36772. reset(): void;
  36773. isReady(): boolean;
  36774. resetRefreshCounter(): void;
  36775. setFragment(fragment: any): void;
  36776. refreshRate: number;
  36777. _shouldRender(): boolean;
  36778. getRenderSize(): number;
  36779. resize(size: number, generateMipMaps: boolean): void;
  36780. private _checkUniform(uniformName);
  36781. setTexture(name: string, texture: Texture): ProceduralTexture;
  36782. setFloat(name: string, value: number): ProceduralTexture;
  36783. setFloats(name: string, value: number[]): ProceduralTexture;
  36784. setColor3(name: string, value: Color3): ProceduralTexture;
  36785. setColor4(name: string, value: Color4): ProceduralTexture;
  36786. setVector2(name: string, value: Vector2): ProceduralTexture;
  36787. setVector3(name: string, value: Vector3): ProceduralTexture;
  36788. setMatrix(name: string, value: Matrix): ProceduralTexture;
  36789. render(useCameraPostProcess?: boolean): void;
  36790. clone(): ProceduralTexture;
  36791. dispose(): void;
  36792. }
  36793. }
  36794. declare module BABYLON {
  36795. /**
  36796. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  36797. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  36798. */
  36799. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  36800. private _scene;
  36801. private _camerasToBeAttached;
  36802. /**
  36803. * ID of the sharpen post process,
  36804. */
  36805. private readonly SharpenPostProcessId;
  36806. /**
  36807. * ID of the image processing post process;
  36808. */
  36809. readonly ImageProcessingPostProcessId: string;
  36810. /**
  36811. * ID of the Fast Approximate Anti-Aliasing post process;
  36812. */
  36813. readonly FxaaPostProcessId: string;
  36814. /**
  36815. * ID of the chromatic aberration post process,
  36816. */
  36817. private readonly ChromaticAberrationPostProcessId;
  36818. /**
  36819. * ID of the grain post process
  36820. */
  36821. private readonly GrainPostProcessId;
  36822. /**
  36823. * Sharpen post process which will apply a sharpen convolution to enhance edges
  36824. */
  36825. sharpen: SharpenPostProcess;
  36826. private _sharpenEffect;
  36827. private bloom;
  36828. /**
  36829. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  36830. */
  36831. depthOfField: DepthOfFieldEffect;
  36832. /**
  36833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  36834. */
  36835. fxaa: FxaaPostProcess;
  36836. /**
  36837. * Image post processing pass used to perform operations such as tone mapping or color grading.
  36838. */
  36839. imageProcessing: ImageProcessingPostProcess;
  36840. /**
  36841. * Chromatic aberration post process which will shift rgb colors in the image
  36842. */
  36843. chromaticAberration: ChromaticAberrationPostProcess;
  36844. private _chromaticAberrationEffect;
  36845. /**
  36846. * Grain post process which add noise to the image
  36847. */
  36848. grain: GrainPostProcess;
  36849. private _grainEffect;
  36850. /**
  36851. * Glow post process which adds a glow to emmisive areas of the image
  36852. */
  36853. private _glowLayer;
  36854. /**
  36855. * Animations which can be used to tweak settings over a period of time
  36856. */
  36857. animations: Animation[];
  36858. private _imageProcessingConfigurationObserver;
  36859. private _sharpenEnabled;
  36860. private _bloomEnabled;
  36861. private _depthOfFieldEnabled;
  36862. private _depthOfFieldBlurLevel;
  36863. private _fxaaEnabled;
  36864. private _imageProcessingEnabled;
  36865. private _defaultPipelineTextureType;
  36866. private _bloomScale;
  36867. private _chromaticAberrationEnabled;
  36868. private _grainEnabled;
  36869. private _buildAllowed;
  36870. /**
  36871. * Enable or disable the sharpen process from the pipeline
  36872. */
  36873. sharpenEnabled: boolean;
  36874. private _resizeObserver;
  36875. private _hardwareScaleLevel;
  36876. private _bloomKernel;
  36877. /**
  36878. * Specifies the size of the bloom blur kernel, relative to the final output size
  36879. */
  36880. bloomKernel: number;
  36881. /**
  36882. * Specifies the weight of the bloom in the final rendering
  36883. */
  36884. private _bloomWeight;
  36885. /**
  36886. * Specifies the luma threshold for the area that will be blurred by the bloom
  36887. */
  36888. private _bloomThreshold;
  36889. private _hdr;
  36890. /**
  36891. * The strength of the bloom.
  36892. */
  36893. bloomWeight: number;
  36894. /**
  36895. * The strength of the bloom.
  36896. */
  36897. bloomThreshold: number;
  36898. /**
  36899. * The scale of the bloom, lower value will provide better performance.
  36900. */
  36901. bloomScale: number;
  36902. /**
  36903. * Enable or disable the bloom from the pipeline
  36904. */
  36905. bloomEnabled: boolean;
  36906. private _rebuildBloom();
  36907. /**
  36908. * If the depth of field is enabled.
  36909. */
  36910. depthOfFieldEnabled: boolean;
  36911. /**
  36912. * Blur level of the depth of field effect. (Higher blur will effect performance)
  36913. */
  36914. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  36915. /**
  36916. * If the anti aliasing is enabled.
  36917. */
  36918. fxaaEnabled: boolean;
  36919. private _samples;
  36920. /**
  36921. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  36922. */
  36923. samples: number;
  36924. /**
  36925. * If image processing is enabled.
  36926. */
  36927. imageProcessingEnabled: boolean;
  36928. /**
  36929. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  36930. */
  36931. glowLayerEnabled: boolean;
  36932. /**
  36933. * Enable or disable the chromaticAberration process from the pipeline
  36934. */
  36935. chromaticAberrationEnabled: boolean;
  36936. /**
  36937. * Enable or disable the grain process from the pipeline
  36938. */
  36939. grainEnabled: boolean;
  36940. /**
  36941. * @constructor
  36942. * @param {string} name - The rendering pipeline name (default: "")
  36943. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  36944. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  36945. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  36946. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  36947. */
  36948. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  36949. /**
  36950. * Force the compilation of the entire pipeline.
  36951. */
  36952. prepare(): void;
  36953. private _hasCleared;
  36954. private _prevPostProcess;
  36955. private _prevPrevPostProcess;
  36956. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  36957. private _buildPipeline();
  36958. private _disposePostProcesses(disposeNonRecreated?);
  36959. /**
  36960. * Adds a camera to the pipeline
  36961. * @param camera the camera to be added
  36962. */
  36963. addCamera(camera: Camera): void;
  36964. /**
  36965. * Removes a camera from the pipeline
  36966. * @param camera the camera to remove
  36967. */
  36968. removeCamera(camera: Camera): void;
  36969. /**
  36970. * Dispose of the pipeline and stop all post processes
  36971. */
  36972. dispose(): void;
  36973. /**
  36974. * Serialize the rendering pipeline (Used when exporting)
  36975. * @returns the serialized object
  36976. */
  36977. serialize(): any;
  36978. /**
  36979. * Parse the serialized pipeline
  36980. * @param source Source pipeline.
  36981. * @param scene The scene to load the pipeline to.
  36982. * @param rootUrl The URL of the serialized pipeline.
  36983. * @returns An instantiated pipeline from the serialized object.
  36984. */
  36985. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  36986. }
  36987. }
  36988. declare module BABYLON {
  36989. class LensRenderingPipeline extends PostProcessRenderPipeline {
  36990. /**
  36991. * The chromatic aberration PostProcess id in the pipeline
  36992. */
  36993. LensChromaticAberrationEffect: string;
  36994. /**
  36995. * The highlights enhancing PostProcess id in the pipeline
  36996. */
  36997. HighlightsEnhancingEffect: string;
  36998. /**
  36999. * The depth-of-field PostProcess id in the pipeline
  37000. */
  37001. LensDepthOfFieldEffect: string;
  37002. private _scene;
  37003. private _depthTexture;
  37004. private _grainTexture;
  37005. private _chromaticAberrationPostProcess;
  37006. private _highlightsPostProcess;
  37007. private _depthOfFieldPostProcess;
  37008. private _edgeBlur;
  37009. private _grainAmount;
  37010. private _chromaticAberration;
  37011. private _distortion;
  37012. private _highlightsGain;
  37013. private _highlightsThreshold;
  37014. private _dofDistance;
  37015. private _dofAperture;
  37016. private _dofDarken;
  37017. private _dofPentagon;
  37018. private _blurNoise;
  37019. /**
  37020. * @constructor
  37021. *
  37022. * Effect parameters are as follow:
  37023. * {
  37024. * chromatic_aberration: number; // from 0 to x (1 for realism)
  37025. * edge_blur: number; // from 0 to x (1 for realism)
  37026. * distortion: number; // from 0 to x (1 for realism)
  37027. * grain_amount: number; // from 0 to 1
  37028. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  37029. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  37030. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  37031. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  37032. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  37033. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  37034. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  37035. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  37036. * }
  37037. * Note: if an effect parameter is unset, effect is disabled
  37038. *
  37039. * @param {string} name - The rendering pipeline name
  37040. * @param {object} parameters - An object containing all parameters (see above)
  37041. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37042. * @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)
  37043. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37044. */
  37045. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  37046. setEdgeBlur(amount: number): void;
  37047. disableEdgeBlur(): void;
  37048. setGrainAmount(amount: number): void;
  37049. disableGrain(): void;
  37050. setChromaticAberration(amount: number): void;
  37051. disableChromaticAberration(): void;
  37052. setEdgeDistortion(amount: number): void;
  37053. disableEdgeDistortion(): void;
  37054. setFocusDistance(amount: number): void;
  37055. disableDepthOfField(): void;
  37056. setAperture(amount: number): void;
  37057. setDarkenOutOfFocus(amount: number): void;
  37058. enablePentagonBokeh(): void;
  37059. disablePentagonBokeh(): void;
  37060. enableNoiseBlur(): void;
  37061. disableNoiseBlur(): void;
  37062. setHighlightsGain(amount: number): void;
  37063. setHighlightsThreshold(amount: number): void;
  37064. disableHighlights(): void;
  37065. /**
  37066. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  37067. */
  37068. dispose(disableDepthRender?: boolean): void;
  37069. private _createChromaticAberrationPostProcess(ratio);
  37070. private _createHighlightsPostProcess(ratio);
  37071. private _createDepthOfFieldPostProcess(ratio);
  37072. private _createGrainTexture();
  37073. }
  37074. }
  37075. declare module BABYLON {
  37076. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  37077. /**
  37078. * The PassPostProcess id in the pipeline that contains the original scene color
  37079. */
  37080. SSAOOriginalSceneColorEffect: string;
  37081. /**
  37082. * The SSAO PostProcess id in the pipeline
  37083. */
  37084. SSAORenderEffect: string;
  37085. /**
  37086. * The horizontal blur PostProcess id in the pipeline
  37087. */
  37088. SSAOBlurHRenderEffect: string;
  37089. /**
  37090. * The vertical blur PostProcess id in the pipeline
  37091. */
  37092. SSAOBlurVRenderEffect: string;
  37093. /**
  37094. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37095. */
  37096. SSAOCombineRenderEffect: string;
  37097. /**
  37098. * The output strength of the SSAO post-process. Default value is 1.0.
  37099. */
  37100. totalStrength: number;
  37101. /**
  37102. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  37103. */
  37104. maxZ: number;
  37105. /**
  37106. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  37107. */
  37108. minZAspect: number;
  37109. /**
  37110. * Number of samples used for the SSAO calculations. Default value is 8
  37111. */
  37112. private _samples;
  37113. /**
  37114. * Ratio object used for SSAO ratio and blur ratio
  37115. */
  37116. private _ratio;
  37117. /**
  37118. * Dynamically generated sphere sampler.
  37119. */
  37120. private _sampleSphere;
  37121. /**
  37122. * Blur filter offsets
  37123. */
  37124. private _samplerOffsets;
  37125. samples: number;
  37126. /**
  37127. * Are we using bilateral blur ?
  37128. */
  37129. private _expensiveBlur;
  37130. expensiveBlur: boolean;
  37131. /**
  37132. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  37133. */
  37134. radius: number;
  37135. /**
  37136. * The base color of the SSAO post-process
  37137. * The final result is "base + ssao" between [0, 1]
  37138. */
  37139. base: number;
  37140. /**
  37141. * Support test.
  37142. */
  37143. static readonly IsSupported: boolean;
  37144. private _scene;
  37145. private _depthTexture;
  37146. private _normalTexture;
  37147. private _randomTexture;
  37148. private _originalColorPostProcess;
  37149. private _ssaoPostProcess;
  37150. private _blurHPostProcess;
  37151. private _blurVPostProcess;
  37152. private _ssaoCombinePostProcess;
  37153. private _firstUpdate;
  37154. /**
  37155. * @constructor
  37156. * @param {string} name - The rendering pipeline name
  37157. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37158. * @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 }
  37159. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37160. */
  37161. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37162. /**
  37163. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37164. */
  37165. dispose(disableGeometryBufferRenderer?: boolean): void;
  37166. private _createBlurPostProcess(ssaoRatio, blurRatio);
  37167. _rebuild(): void;
  37168. private _generateHemisphere();
  37169. private _createSSAOPostProcess(ratio);
  37170. private _createSSAOCombinePostProcess(ratio);
  37171. private _createRandomTexture();
  37172. /**
  37173. * Serialize the rendering pipeline (Used when exporting)
  37174. * @returns the serialized object
  37175. */
  37176. serialize(): any;
  37177. /**
  37178. * Parse the serialized pipeline
  37179. * @param source Source pipeline.
  37180. * @param scene The scene to load the pipeline to.
  37181. * @param rootUrl The URL of the serialized pipeline.
  37182. * @returns An instantiated pipeline from the serialized object.
  37183. */
  37184. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  37185. }
  37186. }
  37187. declare module BABYLON {
  37188. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  37189. /**
  37190. * The PassPostProcess id in the pipeline that contains the original scene color
  37191. */
  37192. SSAOOriginalSceneColorEffect: string;
  37193. /**
  37194. * The SSAO PostProcess id in the pipeline
  37195. */
  37196. SSAORenderEffect: string;
  37197. /**
  37198. * The horizontal blur PostProcess id in the pipeline
  37199. */
  37200. SSAOBlurHRenderEffect: string;
  37201. /**
  37202. * The vertical blur PostProcess id in the pipeline
  37203. */
  37204. SSAOBlurVRenderEffect: string;
  37205. /**
  37206. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37207. */
  37208. SSAOCombineRenderEffect: string;
  37209. /**
  37210. * The output strength of the SSAO post-process. Default value is 1.0.
  37211. */
  37212. totalStrength: number;
  37213. /**
  37214. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  37215. */
  37216. radius: number;
  37217. /**
  37218. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  37219. * Must not be equal to fallOff and superior to fallOff.
  37220. * Default value is 0.975
  37221. */
  37222. area: number;
  37223. /**
  37224. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  37225. * Must not be equal to area and inferior to area.
  37226. * Default value is 0.0
  37227. */
  37228. fallOff: number;
  37229. /**
  37230. * The base color of the SSAO post-process
  37231. * The final result is "base + ssao" between [0, 1]
  37232. */
  37233. base: number;
  37234. private _scene;
  37235. private _depthTexture;
  37236. private _randomTexture;
  37237. private _originalColorPostProcess;
  37238. private _ssaoPostProcess;
  37239. private _blurHPostProcess;
  37240. private _blurVPostProcess;
  37241. private _ssaoCombinePostProcess;
  37242. private _firstUpdate;
  37243. /**
  37244. * @constructor
  37245. * @param {string} name - The rendering pipeline name
  37246. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37247. * @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 }
  37248. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37249. */
  37250. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  37251. /**
  37252. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  37253. */
  37254. dispose(disableDepthRender?: boolean): void;
  37255. private _createBlurPostProcess(ratio);
  37256. _rebuild(): void;
  37257. private _createSSAOPostProcess(ratio);
  37258. private _createSSAOCombinePostProcess(ratio);
  37259. private _createRandomTexture();
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37264. /**
  37265. * Public members
  37266. */
  37267. originalPostProcess: Nullable<PostProcess>;
  37268. downSampleX4PostProcess: Nullable<PostProcess>;
  37269. brightPassPostProcess: Nullable<PostProcess>;
  37270. blurHPostProcesses: PostProcess[];
  37271. blurVPostProcesses: PostProcess[];
  37272. textureAdderPostProcess: Nullable<PostProcess>;
  37273. volumetricLightPostProcess: Nullable<PostProcess>;
  37274. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  37275. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  37276. volumetricLightMergePostProces: Nullable<PostProcess>;
  37277. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  37278. luminancePostProcess: Nullable<PostProcess>;
  37279. luminanceDownSamplePostProcesses: PostProcess[];
  37280. hdrPostProcess: Nullable<PostProcess>;
  37281. textureAdderFinalPostProcess: Nullable<PostProcess>;
  37282. lensFlareFinalPostProcess: Nullable<PostProcess>;
  37283. hdrFinalPostProcess: Nullable<PostProcess>;
  37284. lensFlarePostProcess: Nullable<PostProcess>;
  37285. lensFlareComposePostProcess: Nullable<PostProcess>;
  37286. motionBlurPostProcess: Nullable<PostProcess>;
  37287. depthOfFieldPostProcess: Nullable<PostProcess>;
  37288. brightThreshold: number;
  37289. blurWidth: number;
  37290. horizontalBlur: boolean;
  37291. exposure: number;
  37292. lensTexture: Nullable<Texture>;
  37293. volumetricLightCoefficient: number;
  37294. volumetricLightPower: number;
  37295. volumetricLightBlurScale: number;
  37296. sourceLight: Nullable<SpotLight | DirectionalLight>;
  37297. hdrMinimumLuminance: number;
  37298. hdrDecreaseRate: number;
  37299. hdrIncreaseRate: number;
  37300. lensColorTexture: Nullable<Texture>;
  37301. lensFlareStrength: number;
  37302. lensFlareGhostDispersal: number;
  37303. lensFlareHaloWidth: number;
  37304. lensFlareDistortionStrength: number;
  37305. lensStarTexture: Nullable<Texture>;
  37306. lensFlareDirtTexture: Nullable<Texture>;
  37307. depthOfFieldDistance: number;
  37308. depthOfFieldBlurWidth: number;
  37309. motionStrength: number;
  37310. animations: Animation[];
  37311. /**
  37312. * Private members
  37313. */
  37314. private _scene;
  37315. private _currentDepthOfFieldSource;
  37316. private _basePostProcess;
  37317. private _hdrCurrentLuminance;
  37318. private _floatTextureType;
  37319. private _ratio;
  37320. private _bloomEnabled;
  37321. private _depthOfFieldEnabled;
  37322. private _vlsEnabled;
  37323. private _lensFlareEnabled;
  37324. private _hdrEnabled;
  37325. private _motionBlurEnabled;
  37326. private _motionBlurSamples;
  37327. private _volumetricLightStepsCount;
  37328. BloomEnabled: boolean;
  37329. DepthOfFieldEnabled: boolean;
  37330. LensFlareEnabled: boolean;
  37331. HDREnabled: boolean;
  37332. VLSEnabled: boolean;
  37333. MotionBlurEnabled: boolean;
  37334. volumetricLightStepsCount: number;
  37335. motionBlurSamples: number;
  37336. /**
  37337. * @constructor
  37338. * @param {string} name - The rendering pipeline name
  37339. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37340. * @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)
  37341. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  37342. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37343. */
  37344. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  37345. private _buildPipeline();
  37346. private _createDownSampleX4PostProcess(scene, ratio);
  37347. private _createBrightPassPostProcess(scene, ratio);
  37348. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  37349. private _createTextureAdderPostProcess(scene, ratio);
  37350. private _createVolumetricLightPostProcess(scene, ratio);
  37351. private _createLuminancePostProcesses(scene, textureType);
  37352. private _createHdrPostProcess(scene, ratio);
  37353. private _createLensFlarePostProcess(scene, ratio);
  37354. private _createDepthOfFieldPostProcess(scene, ratio);
  37355. private _createMotionBlurPostProcess(scene, ratio);
  37356. private _getDepthTexture();
  37357. private _disposePostProcesses();
  37358. /**
  37359. * Dispose of the pipeline and stop all post processes
  37360. */
  37361. dispose(): void;
  37362. /**
  37363. * Serialize the rendering pipeline (Used when exporting)
  37364. * @returns the serialized object
  37365. */
  37366. serialize(): any;
  37367. /**
  37368. * Parse the serialized pipeline
  37369. * @param source Source pipeline.
  37370. * @param scene The scene to load the pipeline to.
  37371. * @param rootUrl The URL of the serialized pipeline.
  37372. * @returns An instantiated pipeline from the serialized object.
  37373. */
  37374. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  37375. static LuminanceSteps: number;
  37376. }
  37377. }