babylon.d.ts 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isReady;
  377. /** @hidden */
  378. _currentRenderId: number;
  379. private _parentRenderId;
  380. protected _childRenderId: number;
  381. /** @hidden */
  382. _waitingParentId: Nullable<string>;
  383. /** @hidden */
  384. _scene: Scene;
  385. /** @hidden */
  386. _cache: any;
  387. private _parentNode;
  388. private _children;
  389. /**
  390. * Gets a boolean indicating if the node has been disposed
  391. * @returns true if the node was disposed
  392. */
  393. isDisposed(): boolean;
  394. /**
  395. * Gets or sets the parent of the node
  396. */
  397. parent: Nullable<Node>;
  398. private _animationPropertiesOverride;
  399. /**
  400. * Gets or sets the animation properties override
  401. */
  402. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  403. /**
  404. * Gets a string idenfifying the name of the class
  405. * @returns "Node" string
  406. */
  407. getClassName(): string;
  408. /**
  409. * An event triggered when the mesh is disposed
  410. */
  411. onDisposeObservable: Observable<Node>;
  412. private _onDisposeObserver;
  413. /**
  414. * Sets a callback that will be raised when the node will be disposed
  415. */
  416. onDispose: () => void;
  417. /**
  418. * Creates a new Node
  419. * @param {string} name - the name and id to be given to this node
  420. * @param {BABYLON.Scene} the scene this node will be added to
  421. */
  422. constructor(name: string, scene?: Nullable<Scene>);
  423. /**
  424. * Gets the scene of the node
  425. * @returns a {BABYLON.Scene}
  426. */
  427. getScene(): Scene;
  428. /**
  429. * Gets the engine of the node
  430. * @returns a {BABYLON.Engine}
  431. */
  432. getEngine(): Engine;
  433. private _behaviors;
  434. /**
  435. * Attach a behavior to the node
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. * @param behavior defines the behavior to attach
  438. * @returns the current Node
  439. */
  440. addBehavior(behavior: Behavior<Node>): Node;
  441. /**
  442. * Remove an attached behavior
  443. * @see http://doc.babylonjs.com/features/behaviour
  444. * @param behavior defines the behavior to attach
  445. * @returns the current Node
  446. */
  447. removeBehavior(behavior: Behavior<Node>): Node;
  448. /**
  449. * Gets the list of attached behaviors
  450. * @see http://doc.babylonjs.com/features/behaviour
  451. */
  452. readonly behaviors: Behavior<Node>[];
  453. /**
  454. * Gets an attached behavior by name
  455. * @param name defines the name of the behavior to look for
  456. * @see http://doc.babylonjs.com/features/behaviour
  457. * @returns null if behavior was not found else the requested behavior
  458. */
  459. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  460. /**
  461. * Returns the world matrix of the node
  462. * @returns a matrix containing the node's world matrix
  463. */
  464. getWorldMatrix(): Matrix;
  465. /** @hidden */
  466. _getWorldMatrixDeterminant(): number;
  467. /** @hidden */
  468. _initCache(): void;
  469. /** @hidden */
  470. updateCache(force?: boolean): void;
  471. /** @hidden */
  472. _updateCache(ignoreParentClass?: boolean): void;
  473. /** @hidden */
  474. _isSynchronized(): boolean;
  475. /** @hidden */
  476. _markSyncedWithParent(): void;
  477. /** @hidden */
  478. isSynchronizedWithParent(): boolean;
  479. /** @hidden */
  480. isSynchronized(updateCache?: boolean): boolean;
  481. /** @hidden */
  482. hasNewParent(update?: boolean): boolean;
  483. /**
  484. * Is this node ready to be used/rendered
  485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  486. * @return true if the node is ready
  487. */
  488. isReady(completeCheck?: boolean): boolean;
  489. /**
  490. * Is this node enabled?
  491. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  492. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  493. * @return whether this node (and its parent) is enabled
  494. */
  495. isEnabled(checkAncestors?: boolean): boolean;
  496. /**
  497. * Set the enabled state of this node
  498. * @param value defines the new enabled state
  499. */
  500. setEnabled(value: boolean): void;
  501. /**
  502. * Is this node a descendant of the given node?
  503. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  504. * @param ancestor defines the parent node to inspect
  505. * @returns a boolean indicating if this node is a descendant of the given node
  506. */
  507. isDescendantOf(ancestor: Node): boolean;
  508. /** @hidden */
  509. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  510. /**
  511. * Will return all nodes that have this node as ascendant
  512. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  513. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  514. * @return all children nodes of all types
  515. */
  516. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  517. /**
  518. * Get all child-meshes of this node
  519. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  520. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  521. * @returns an array of {BABYLON.AbstractMesh}
  522. */
  523. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  524. /**
  525. * Get all child-transformNodes of this node
  526. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  527. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  528. * @returns an array of {BABYLON.TransformNode}
  529. */
  530. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  531. /**
  532. * Get all direct children of this node
  533. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  534. * @returns an array of {BABYLON.Node}
  535. */
  536. getChildren(predicate?: (node: Node) => boolean): Node[];
  537. /** @hidden */
  538. _setReady(state: boolean): void;
  539. /**
  540. * Get an animation by name
  541. * @param name defines the name of the animation to look for
  542. * @returns null if not found else the requested animation
  543. */
  544. getAnimationByName(name: string): Nullable<Animation>;
  545. /**
  546. * Creates an animation range for this node
  547. * @param name defines the name of the range
  548. * @param from defines the starting key
  549. * @param to defines the end key
  550. */
  551. createAnimationRange(name: string, from: number, to: number): void;
  552. /**
  553. * Delete a specific animation range
  554. * @param name defines the name of the range to delete
  555. * @param deleteFrames defines if animation frames from the range must be deleted as well
  556. */
  557. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  558. /**
  559. * Get an animation range by name
  560. * @param name defines the name of the animation range to look for
  561. * @returns null if not found else the requested animation range
  562. */
  563. getAnimationRange(name: string): Nullable<AnimationRange>;
  564. /**
  565. * Will start the animation sequence
  566. * @param name defines the range frames for animation sequence
  567. * @param loop defines if the animation should loop (false by default)
  568. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  569. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  570. * @returns the object created for this animation. If range does not exist, it will return null
  571. */
  572. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  573. /**
  574. * Serialize animation ranges into a JSON compatible object
  575. * @returns serialization object
  576. */
  577. serializeAnimationRanges(): any;
  578. /**
  579. * Computes the world matrix of the node
  580. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  581. * @returns the world matrix
  582. */
  583. computeWorldMatrix(force?: boolean): Matrix;
  584. /**
  585. * Releases resources associated with this node.
  586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  588. */
  589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  590. /**
  591. * Parse animation range data from a serialization object and store them into a given node
  592. * @param node defines where to store the animation ranges
  593. * @param parsedNode defines the serialization object to read data from
  594. * @param scene defines the hosting scene
  595. */
  596. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * Define an interface for all classes that will hold resources
  602. */
  603. interface IDisposable {
  604. /**
  605. * Releases all held resources
  606. */
  607. dispose(): void;
  608. }
  609. /**
  610. * Interface used to let developers provide their own mesh selection mechanism
  611. */
  612. interface IActiveMeshCandidateProvider {
  613. /**
  614. * Return the list of active meshes
  615. * @param scene defines the current scene
  616. * @returns the list of active meshes
  617. */
  618. getMeshes(scene: Scene): AbstractMesh[];
  619. /**
  620. * Indicates if the meshes have been checked to make sure they are isEnabled()
  621. */
  622. readonly checksIsEnabled: boolean;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. private _spritePredicate;
  778. /**
  779. * An event triggered when the scene is disposed.
  780. */
  781. onDisposeObservable: Observable<Scene>;
  782. private _onDisposeObserver;
  783. /** Sets a function to be executed when this scene is disposed. */
  784. onDispose: () => void;
  785. /**
  786. * An event triggered before rendering the scene (right after animations and physics)
  787. */
  788. onBeforeRenderObservable: Observable<Scene>;
  789. private _onBeforeRenderObserver;
  790. /** Sets a function to be executed before rendering this scene */
  791. beforeRender: Nullable<() => void>;
  792. /**
  793. * An event triggered after rendering the scene
  794. */
  795. onAfterRenderObservable: Observable<Scene>;
  796. private _onAfterRenderObserver;
  797. /** Sets a function to be executed after rendering this scene */
  798. afterRender: Nullable<() => void>;
  799. /**
  800. * An event triggered before animating the scene
  801. */
  802. onBeforeAnimationsObservable: Observable<Scene>;
  803. /**
  804. * An event triggered after animations processing
  805. */
  806. onAfterAnimationsObservable: Observable<Scene>;
  807. /**
  808. * An event triggered before draw calls are ready to be sent
  809. */
  810. onBeforeDrawPhaseObservable: Observable<Scene>;
  811. /**
  812. * An event triggered after draw calls have been sent
  813. */
  814. onAfterDrawPhaseObservable: Observable<Scene>;
  815. /**
  816. * An event triggered when physic simulation is about to be run
  817. */
  818. onBeforePhysicsObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when physic simulation has been done
  821. */
  822. onAfterPhysicsObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when the scene is ready
  825. */
  826. onReadyObservable: Observable<Scene>;
  827. /**
  828. * An event triggered before rendering a camera
  829. */
  830. onBeforeCameraRenderObservable: Observable<Camera>;
  831. private _onBeforeCameraRenderObserver;
  832. /** Sets a function to be executed before rendering a camera*/
  833. beforeCameraRender: () => void;
  834. /**
  835. * An event triggered after rendering a camera
  836. */
  837. onAfterCameraRenderObservable: Observable<Camera>;
  838. private _onAfterCameraRenderObserver;
  839. /** Sets a function to be executed after rendering a camera*/
  840. afterCameraRender: () => void;
  841. /**
  842. * An event triggered when active meshes evaluation is about to start
  843. */
  844. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  845. /**
  846. * An event triggered when active meshes evaluation is done
  847. */
  848. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when particles rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  852. */
  853. onBeforeParticlesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when particles rendering is done
  856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  857. */
  858. onAfterParticlesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when sprites rendering is about to start
  861. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  862. */
  863. onBeforeSpritesRenderingObservable: Observable<Scene>;
  864. /**
  865. * An event triggered when sprites rendering is done
  866. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  867. */
  868. onAfterSpritesRenderingObservable: Observable<Scene>;
  869. /**
  870. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  871. */
  872. onDataLoadedObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when a camera is created
  875. */
  876. onNewCameraAddedObservable: Observable<Camera>;
  877. /**
  878. * An event triggered when a camera is removed
  879. */
  880. onCameraRemovedObservable: Observable<Camera>;
  881. /**
  882. * An event triggered when a light is created
  883. */
  884. onNewLightAddedObservable: Observable<Light>;
  885. /**
  886. * An event triggered when a light is removed
  887. */
  888. onLightRemovedObservable: Observable<Light>;
  889. /**
  890. * An event triggered when a geometry is created
  891. */
  892. onNewGeometryAddedObservable: Observable<Geometry>;
  893. /**
  894. * An event triggered when a geometry is removed
  895. */
  896. onGeometryRemovedObservable: Observable<Geometry>;
  897. /**
  898. * An event triggered when a transform node is created
  899. */
  900. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  901. /**
  902. * An event triggered when a transform node is removed
  903. */
  904. onTransformNodeRemovedObservable: Observable<TransformNode>;
  905. /**
  906. * An event triggered when a mesh is created
  907. */
  908. onNewMeshAddedObservable: Observable<AbstractMesh>;
  909. /**
  910. * An event triggered when a mesh is removed
  911. */
  912. onMeshRemovedObservable: Observable<AbstractMesh>;
  913. /**
  914. * An event triggered when render targets are about to be rendered
  915. * Can happen multiple times per frame.
  916. */
  917. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  918. /**
  919. * An event triggered when render targets were rendered.
  920. * Can happen multiple times per frame.
  921. */
  922. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  923. /**
  924. * An event triggered before calculating deterministic simulation step
  925. */
  926. onBeforeStepObservable: Observable<Scene>;
  927. /**
  928. * An event triggered after calculating deterministic simulation step
  929. */
  930. onAfterStepObservable: Observable<Scene>;
  931. /**
  932. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  933. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  934. * 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)
  935. */
  936. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  937. /**
  938. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  939. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  940. * 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)
  941. */
  942. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  943. private _registeredForLateAnimationBindings;
  944. /**
  945. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  946. */
  947. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  948. /**
  949. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  950. */
  951. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  952. /**
  953. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  954. */
  955. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  956. private _onPointerMove;
  957. private _onPointerDown;
  958. private _onPointerUp;
  959. /** Deprecated. Use onPointerObservable instead */
  960. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  965. /** Deprecated. Use onPointerObservable instead */
  966. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  967. /**
  968. * 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).
  969. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  970. */
  971. onPrePointerObservable: Observable<PointerInfoPre>;
  972. /**
  973. * Observable event triggered each time an input event is received from the rendering canvas
  974. */
  975. onPointerObservable: Observable<PointerInfo>;
  976. /**
  977. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  978. */
  979. readonly unTranslatedPointer: Vector2;
  980. /** The distance in pixel that you have to move to prevent some events */
  981. static DragMovementThreshold: number;
  982. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  983. static LongPressDelay: number;
  984. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  985. static DoubleClickDelay: number;
  986. /** If you need to check double click without raising a single click at first click, enable this flag */
  987. static ExclusiveDoubleClickMode: boolean;
  988. private _initClickEvent;
  989. private _initActionManager;
  990. private _delayedSimpleClick;
  991. private _delayedSimpleClickTimeout;
  992. private _previousDelayedSimpleClickTimeout;
  993. private _meshPickProceed;
  994. private _previousButtonPressed;
  995. private _currentPickResult;
  996. private _previousPickResult;
  997. private _totalPointersPressed;
  998. private _doubleClickOccured;
  999. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1000. cameraToUseForPointers: Nullable<Camera>;
  1001. private _pointerX;
  1002. private _pointerY;
  1003. private _unTranslatedPointerX;
  1004. private _unTranslatedPointerY;
  1005. private _startingPointerPosition;
  1006. private _previousStartingPointerPosition;
  1007. private _startingPointerTime;
  1008. private _previousStartingPointerTime;
  1009. private _pointerCaptures;
  1010. private _timeAccumulator;
  1011. private _currentStepId;
  1012. private _currentInternalStep;
  1013. /** @hidden */
  1014. _mirroredCameraPosition: Nullable<Vector3>;
  1015. /**
  1016. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1017. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1018. */
  1019. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1020. /**
  1021. * Observable event triggered each time an keyboard event is received from the hosting window
  1022. */
  1023. onKeyboardObservable: Observable<KeyboardInfo>;
  1024. private _onKeyDown;
  1025. private _onKeyUp;
  1026. private _onCanvasFocusObserver;
  1027. private _onCanvasBlurObserver;
  1028. private _useRightHandedSystem;
  1029. /**
  1030. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1031. */
  1032. useRightHandedSystem: boolean;
  1033. /**
  1034. * Sets the step Id used by deterministic lock step
  1035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1036. * @param newStepId defines the step Id
  1037. */
  1038. setStepId(newStepId: number): void;
  1039. /**
  1040. * Gets the step Id used by deterministic lock step
  1041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1042. * @returns the step Id
  1043. */
  1044. getStepId(): number;
  1045. /**
  1046. * Gets the internal step used by deterministic lock step
  1047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1048. * @returns the internal step
  1049. */
  1050. getInternalStep(): number;
  1051. private _fogEnabled;
  1052. /**
  1053. * Gets or sets a boolean indicating if fog is enabled on this scene
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogEnabled: boolean;
  1057. private _fogMode;
  1058. /**
  1059. * Gets or sets the fog mode to use
  1060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1061. */
  1062. fogMode: number;
  1063. /**
  1064. * Gets or sets the fog color to use
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. */
  1067. fogColor: Color3;
  1068. /**
  1069. * Gets or sets the fog density to use
  1070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1071. */
  1072. fogDensity: number;
  1073. /**
  1074. * Gets or sets the fog start distance to use
  1075. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1076. */
  1077. fogStart: number;
  1078. /**
  1079. * Gets or sets the fog end distance to use
  1080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1081. */
  1082. fogEnd: number;
  1083. private _shadowsEnabled;
  1084. /**
  1085. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1086. */
  1087. shadowsEnabled: boolean;
  1088. private _lightsEnabled;
  1089. /**
  1090. * Gets or sets a boolean indicating if lights are enabled on this scene
  1091. */
  1092. lightsEnabled: boolean;
  1093. /** All of the active cameras added to this scene. */
  1094. activeCameras: Camera[];
  1095. /** The current active camera */
  1096. activeCamera: Nullable<Camera>;
  1097. private _defaultMaterial;
  1098. /** The default material used on meshes when no material is affected */
  1099. /** The default material used on meshes when no material is affected */
  1100. defaultMaterial: Material;
  1101. private _texturesEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if textures are enabled on this scene
  1104. */
  1105. texturesEnabled: boolean;
  1106. /**
  1107. * Gets or sets a boolean indicating if particles are enabled on this scene
  1108. */
  1109. particlesEnabled: boolean;
  1110. /**
  1111. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1112. */
  1113. spritesEnabled: boolean;
  1114. /**
  1115. * All of the sprite managers added to this scene
  1116. * @see http://doc.babylonjs.com/babylon101/sprites
  1117. */
  1118. spriteManagers: SpriteManager[];
  1119. private _skeletonsEnabled;
  1120. /**
  1121. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1122. */
  1123. skeletonsEnabled: boolean;
  1124. /**
  1125. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1126. */
  1127. lensFlaresEnabled: boolean;
  1128. /**
  1129. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1131. */
  1132. collisionsEnabled: boolean;
  1133. private _workerCollisions;
  1134. /** @hidden */
  1135. collisionCoordinator: ICollisionCoordinator;
  1136. /**
  1137. * Defines the gravity applied to this scene (used only for collisions)
  1138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1139. */
  1140. gravity: Vector3;
  1141. /**
  1142. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1143. */
  1144. postProcessesEnabled: boolean;
  1145. /**
  1146. * The list of postprocesses added to the scene
  1147. */
  1148. postProcesses: PostProcess[];
  1149. /**
  1150. * Gets the current postprocess manager
  1151. */
  1152. postProcessManager: PostProcessManager;
  1153. /**
  1154. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1155. */
  1156. renderTargetsEnabled: boolean;
  1157. /**
  1158. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1159. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1160. */
  1161. dumpNextRenderTargets: boolean;
  1162. /**
  1163. * The list of user defined render targets added to the scene
  1164. */
  1165. customRenderTargets: RenderTargetTexture[];
  1166. /**
  1167. * Defines if texture loading must be delayed
  1168. * If true, textures will only be loaded when they need to be rendered
  1169. */
  1170. useDelayedTextureLoading: boolean;
  1171. /**
  1172. * Gets the list of meshes imported to the scene through SceneLoader
  1173. */
  1174. importedMeshesFiles: String[];
  1175. /**
  1176. * Gets or sets a boolean indicating if probes are enabled on this scene
  1177. */
  1178. probesEnabled: boolean;
  1179. /**
  1180. * The list of reflection probes added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1182. */
  1183. reflectionProbes: ReflectionProbe[];
  1184. /**
  1185. * @hidden
  1186. */
  1187. database: Database;
  1188. /**
  1189. * Gets or sets the action manager associated with the scene
  1190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1191. */
  1192. actionManager: ActionManager;
  1193. private _meshesForIntersections;
  1194. /**
  1195. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1196. */
  1197. proceduralTexturesEnabled: boolean;
  1198. /**
  1199. * The list of procedural textures added to the scene
  1200. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1201. */
  1202. proceduralTextures: ProceduralTexture[];
  1203. private _mainSoundTrack;
  1204. /**
  1205. * The list of sound tracks added to the scene
  1206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1207. */
  1208. soundTracks: SoundTrack[];
  1209. private _audioEnabled;
  1210. private _headphone;
  1211. /**
  1212. * Gets the main soundtrack associated with the scene
  1213. */
  1214. readonly mainSoundTrack: SoundTrack;
  1215. /**
  1216. * Gets or sets the VRExperienceHelper attached to the scene
  1217. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1218. * @ignorenaming
  1219. */
  1220. VRHelper: VRExperienceHelper;
  1221. private _engine;
  1222. private _totalVertices;
  1223. /** @hidden */
  1224. _activeIndices: PerfCounter;
  1225. /** @hidden */
  1226. _activeParticles: PerfCounter;
  1227. /** @hidden */
  1228. _activeBones: PerfCounter;
  1229. private _animationRatio;
  1230. private _animationTimeLast;
  1231. private _animationTime;
  1232. /**
  1233. * Gets or sets a general scale for animation speed
  1234. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1235. */
  1236. animationTimeScale: number;
  1237. /** @hidden */
  1238. _cachedMaterial: Nullable<Material>;
  1239. /** @hidden */
  1240. _cachedEffect: Nullable<Effect>;
  1241. /** @hidden */
  1242. _cachedVisibility: Nullable<number>;
  1243. private _renderId;
  1244. private _executeWhenReadyTimeoutId;
  1245. private _intermediateRendering;
  1246. private _viewUpdateFlag;
  1247. private _projectionUpdateFlag;
  1248. private _alternateViewUpdateFlag;
  1249. private _alternateProjectionUpdateFlag;
  1250. /** @hidden */
  1251. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1252. private _activeRequests;
  1253. private _pendingData;
  1254. private _isDisposed;
  1255. /**
  1256. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1257. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1258. */
  1259. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1260. private _activeMeshes;
  1261. private _processedMaterials;
  1262. private _renderTargets;
  1263. /** @hidden */
  1264. _activeParticleSystems: SmartArray<IParticleSystem>;
  1265. private _activeSkeletons;
  1266. private _softwareSkinnedMeshes;
  1267. private _renderingManager;
  1268. private _physicsEngine;
  1269. /** @hidden */
  1270. _activeAnimatables: Animatable[];
  1271. private _transformMatrix;
  1272. private _sceneUbo;
  1273. private _alternateSceneUbo;
  1274. private _pickWithRayInverseMatrix;
  1275. private _outlineRenderer;
  1276. private _viewMatrix;
  1277. private _projectionMatrix;
  1278. private _alternateViewMatrix;
  1279. private _alternateProjectionMatrix;
  1280. private _alternateTransformMatrix;
  1281. private _useAlternateCameraConfiguration;
  1282. private _alternateRendering;
  1283. /** @hidden */
  1284. _forcedViewPosition: Nullable<Vector3>;
  1285. /** @hidden */
  1286. readonly _isAlternateRenderingEnabled: boolean;
  1287. private _frustumPlanes;
  1288. /**
  1289. * Gets the list of frustum planes (built from the active camera)
  1290. */
  1291. readonly frustumPlanes: Plane[];
  1292. /**
  1293. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1294. * This is useful if there are more lights that the maximum simulteanous authorized
  1295. */
  1296. requireLightSorting: boolean;
  1297. private _selectionOctree;
  1298. private _pointerOverMesh;
  1299. private _pointerOverSprite;
  1300. private _debugLayer;
  1301. private _pickedDownMesh;
  1302. private _pickedUpMesh;
  1303. private _pickedDownSprite;
  1304. private _externalData;
  1305. private _uid;
  1306. /**
  1307. * @hidden
  1308. * Backing store of defined scene components.
  1309. */
  1310. _components: ISceneComponent[];
  1311. /**
  1312. * @hidden
  1313. * Backing store of defined scene components.
  1314. */
  1315. _serializableComponents: ISceneSerializableComponent[];
  1316. /**
  1317. * List of components to register on the next registration step.
  1318. */
  1319. private _transientComponents;
  1320. /**
  1321. * Registers the transient components if needed.
  1322. */
  1323. private _registerTransientComponents;
  1324. /**
  1325. * @hidden
  1326. * Add a component to the scene.
  1327. * Note that the ccomponent could be registered on th next frame if this is called after
  1328. * the register component stage.
  1329. * @param component Defines the component to add to the scene
  1330. */
  1331. _addComponent(component: ISceneComponent): void;
  1332. /**
  1333. * @hidden
  1334. * Gets a component from the scene.
  1335. * @param name defines the name of the component to retrieve
  1336. * @returns the component or null if not present
  1337. */
  1338. _getComponent(name: string): Nullable<ISceneComponent>;
  1339. /**
  1340. * @hidden
  1341. * Defines the actions happening before camera updates.
  1342. */
  1343. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1344. /**
  1345. * @hidden
  1346. * Defines the actions happening before camera updates.
  1347. */
  1348. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1349. /**
  1350. * @hidden
  1351. * Defines the actions happening during the per mesh ready checks.
  1352. */
  1353. _isReadyForMeshStage: Stage<MeshStageAction>;
  1354. /**
  1355. * @hidden
  1356. * Defines the actions happening before evaluate active mesh checks.
  1357. */
  1358. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1359. /**
  1360. * @hidden
  1361. * Defines the actions happening during the evaluate sub mesh checks.
  1362. */
  1363. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1364. /**
  1365. * @hidden
  1366. * Defines the actions happening during the active mesh stage.
  1367. */
  1368. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1369. /**
  1370. * @hidden
  1371. * Defines the actions happening during the per camera render target step.
  1372. */
  1373. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1374. /**
  1375. * @hidden
  1376. * Defines the actions happening just before the active camera is drawing.
  1377. */
  1378. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1379. /**
  1380. * Defines the actions happening just before a rendering group is drawing.
  1381. */
  1382. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just after a rendering group has been drawn.
  1386. */
  1387. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just after the active camera has been drawn.
  1391. */
  1392. _afterCameraDrawStage: Stage<CameraStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening when Geometries are rebuilding.
  1396. */
  1397. _rebuildGeometryStage: Stage<SimpleStageAction>;
  1398. /**
  1399. * Creates a new Scene
  1400. * @param engine defines the engine to use to render this scene
  1401. */
  1402. constructor(engine: Engine);
  1403. /**
  1404. * Gets the debug layer (aka Inspector) associated with the scene
  1405. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1406. */
  1407. readonly debugLayer: DebugLayer;
  1408. /**
  1409. * Gets a boolean indicating if collisions are processed on a web worker
  1410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1411. */
  1412. workerCollisions: boolean;
  1413. /**
  1414. * Gets the octree used to boost mesh selection (picking)
  1415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1416. */
  1417. readonly selectionOctree: Octree<AbstractMesh>;
  1418. /**
  1419. * Gets the mesh that is currently under the pointer
  1420. */
  1421. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1422. /**
  1423. * Gets the current on-screen X position of the pointer
  1424. */
  1425. readonly pointerX: number;
  1426. /**
  1427. * Gets the current on-screen Y position of the pointer
  1428. */
  1429. readonly pointerY: number;
  1430. /**
  1431. * Gets the cached material (ie. the latest rendered one)
  1432. * @returns the cached material
  1433. */
  1434. getCachedMaterial(): Nullable<Material>;
  1435. /**
  1436. * Gets the cached effect (ie. the latest rendered one)
  1437. * @returns the cached effect
  1438. */
  1439. getCachedEffect(): Nullable<Effect>;
  1440. /**
  1441. * Gets the cached visibility state (ie. the latest rendered one)
  1442. * @returns the cached visibility state
  1443. */
  1444. getCachedVisibility(): Nullable<number>;
  1445. /**
  1446. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1447. * @param material defines the current material
  1448. * @param effect defines the current effect
  1449. * @param visibility defines the current visibility state
  1450. * @returns true if one parameter is not cached
  1451. */
  1452. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1453. /**
  1454. * Gets the outline renderer associated with the scene
  1455. * @returns a OutlineRenderer
  1456. */
  1457. getOutlineRenderer(): OutlineRenderer;
  1458. /**
  1459. * Gets the engine associated with the scene
  1460. * @returns an Engine
  1461. */
  1462. getEngine(): Engine;
  1463. /**
  1464. * Gets the total number of vertices rendered per frame
  1465. * @returns the total number of vertices rendered per frame
  1466. */
  1467. getTotalVertices(): number;
  1468. /**
  1469. * Gets the performance counter for total vertices
  1470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1471. */
  1472. readonly totalVerticesPerfCounter: PerfCounter;
  1473. /**
  1474. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1475. * @returns the total number of active indices rendered per frame
  1476. */
  1477. getActiveIndices(): number;
  1478. /**
  1479. * Gets the performance counter for active indices
  1480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1481. */
  1482. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1483. /**
  1484. * Gets the total number of active particles rendered per frame
  1485. * @returns the total number of active particles rendered per frame
  1486. */
  1487. getActiveParticles(): number;
  1488. /**
  1489. * Gets the performance counter for active particles
  1490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1491. */
  1492. readonly activeParticlesPerfCounter: PerfCounter;
  1493. /**
  1494. * Gets the total number of active bones rendered per frame
  1495. * @returns the total number of active bones rendered per frame
  1496. */
  1497. getActiveBones(): number;
  1498. /**
  1499. * Gets the performance counter for active bones
  1500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1501. */
  1502. readonly activeBonesPerfCounter: PerfCounter;
  1503. /** @hidden */
  1504. getInterFramePerfCounter(): number;
  1505. /** @hidden */
  1506. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1507. /** @hidden */
  1508. getLastFrameDuration(): number;
  1509. /** @hidden */
  1510. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1511. /** @hidden */
  1512. getEvaluateActiveMeshesDuration(): number;
  1513. /** @hidden */
  1514. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1515. /**
  1516. * Gets the array of active meshes
  1517. * @returns an array of AbstractMesh
  1518. */
  1519. getActiveMeshes(): SmartArray<AbstractMesh>;
  1520. /** @hidden */
  1521. getRenderTargetsDuration(): number;
  1522. /** @hidden */
  1523. getRenderDuration(): number;
  1524. /** @hidden */
  1525. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1526. /** @hidden */
  1527. getParticlesDuration(): number;
  1528. /** @hidden */
  1529. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1530. /** @hidden */
  1531. getSpritesDuration(): number;
  1532. /** @hidden */
  1533. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1534. /**
  1535. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1536. * @returns a number
  1537. */
  1538. getAnimationRatio(): number;
  1539. /**
  1540. * Gets an unique Id for the current frame
  1541. * @returns a number
  1542. */
  1543. getRenderId(): number;
  1544. /** Call this function if you want to manually increment the render Id*/
  1545. incrementRenderId(): void;
  1546. private _updatePointerPosition;
  1547. private _createUbo;
  1548. private _createAlternateUbo;
  1549. private _pickSpriteButKeepRay;
  1550. private _setRayOnPointerInfo;
  1551. /**
  1552. * Use this method to simulate a pointer move on a mesh
  1553. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1554. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1555. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1556. * @returns the current scene
  1557. */
  1558. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1559. private _processPointerMove;
  1560. private _checkPrePointerObservable;
  1561. /**
  1562. * Use this method to simulate a pointer down on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerDown;
  1570. /**
  1571. * Use this method to simulate a pointer up on a mesh
  1572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1575. * @returns the current scene
  1576. */
  1577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1578. private _processPointerUp;
  1579. /**
  1580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1582. * @returns true if the pointer was captured
  1583. */
  1584. isPointerCaptured(pointerId?: number): boolean;
  1585. /**
  1586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1587. * @param attachUp defines if you want to attach events to pointerup
  1588. * @param attachDown defines if you want to attach events to pointerdown
  1589. * @param attachMove defines if you want to attach events to pointermove
  1590. */
  1591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1592. /** Detaches all event handlers*/
  1593. detachControl(): void;
  1594. /**
  1595. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1596. * Delay loaded resources are not taking in account
  1597. * @return true if all required resources are ready
  1598. */
  1599. isReady(): boolean;
  1600. /** Resets all cached information relative to material (including effect and visibility) */
  1601. resetCachedMaterial(): void;
  1602. /**
  1603. * Registers a function to be called before every frame render
  1604. * @param func defines the function to register
  1605. */
  1606. registerBeforeRender(func: () => void): void;
  1607. /**
  1608. * Unregisters a function called before every frame render
  1609. * @param func defines the function to unregister
  1610. */
  1611. unregisterBeforeRender(func: () => void): void;
  1612. /**
  1613. * Registers a function to be called after every frame render
  1614. * @param func defines the function to register
  1615. */
  1616. registerAfterRender(func: () => void): void;
  1617. /**
  1618. * Unregisters a function called after every frame render
  1619. * @param func defines the function to unregister
  1620. */
  1621. unregisterAfterRender(func: () => void): void;
  1622. private _executeOnceBeforeRender;
  1623. /**
  1624. * The provided function will run before render once and will be disposed afterwards.
  1625. * A timeout delay can be provided so that the function will be executed in N ms.
  1626. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1627. * @param func The function to be executed.
  1628. * @param timeout optional delay in ms
  1629. */
  1630. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1631. /** @hidden */
  1632. _addPendingData(data: any): void;
  1633. /** @hidden */
  1634. _removePendingData(data: any): void;
  1635. /**
  1636. * Returns the number of items waiting to be loaded
  1637. * @returns the number of items waiting to be loaded
  1638. */
  1639. getWaitingItemsCount(): number;
  1640. /**
  1641. * Returns a boolean indicating if the scene is still loading data
  1642. */
  1643. readonly isLoading: boolean;
  1644. /**
  1645. * Registers a function to be executed when the scene is ready
  1646. * @param {Function} func - the function to be executed
  1647. */
  1648. executeWhenReady(func: () => void): void;
  1649. /**
  1650. * Returns a promise that resolves when the scene is ready
  1651. * @returns A promise that resolves when the scene is ready
  1652. */
  1653. whenReadyAsync(): Promise<void>;
  1654. /** @hidden */
  1655. _checkIsReady(): void;
  1656. /**
  1657. * Will start the animation sequence of a given target
  1658. * @param target defines the target
  1659. * @param from defines from which frame should animation start
  1660. * @param to defines until which frame should animation run.
  1661. * @param weight defines the weight to apply to the animation (1.0 by default)
  1662. * @param loop defines if the animation loops
  1663. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1664. * @param onAnimationEnd defines the function to be executed when the animation ends
  1665. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1666. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1667. * @returns the animatable object created for this animation
  1668. */
  1669. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1670. /**
  1671. * Will start the animation sequence of a given target
  1672. * @param target defines the target
  1673. * @param from defines from which frame should animation start
  1674. * @param to defines until which frame should animation run.
  1675. * @param loop defines if the animation loops
  1676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1677. * @param onAnimationEnd defines the function to be executed when the animation ends
  1678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1679. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1680. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1681. * @returns the animatable object created for this animation
  1682. */
  1683. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1684. /**
  1685. * Begin a new animation on a given node
  1686. * @param target defines the target where the animation will take place
  1687. * @param animations defines the list of animations to start
  1688. * @param from defines the initial value
  1689. * @param to defines the final value
  1690. * @param loop defines if you want animation to loop (off by default)
  1691. * @param speedRatio defines the speed ratio to apply to all animations
  1692. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1693. * @returns the list of created animatables
  1694. */
  1695. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1696. /**
  1697. * Begin a new animation on a given node and its hierarchy
  1698. * @param target defines the root node where the animation will take place
  1699. * @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.
  1700. * @param animations defines the list of animations to start
  1701. * @param from defines the initial value
  1702. * @param to defines the final value
  1703. * @param loop defines if you want animation to loop (off by default)
  1704. * @param speedRatio defines the speed ratio to apply to all animations
  1705. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1706. * @returns the list of animatables created for all nodes
  1707. */
  1708. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1709. /**
  1710. * Gets the animatable associated with a specific target
  1711. * @param target defines the target of the animatable
  1712. * @returns the required animatable if found
  1713. */
  1714. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1715. /**
  1716. * Gets all animatables associated with a given target
  1717. * @param target defines the target to look animatables for
  1718. * @returns an array of Animatables
  1719. */
  1720. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1721. /**
  1722. * Gets all animatable attached to the scene
  1723. */
  1724. readonly animatables: Animatable[];
  1725. /**
  1726. * Will stop the animation of the given target
  1727. * @param target - the target
  1728. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1729. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1730. */
  1731. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1732. /**
  1733. * Stops and removes all animations that have been applied to the scene
  1734. */
  1735. stopAllAnimations(): void;
  1736. private _animate;
  1737. /** @hidden */
  1738. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1739. private _processLateAnimationBindingsForMatrices;
  1740. private _processLateAnimationBindingsForQuaternions;
  1741. private _processLateAnimationBindings;
  1742. /** @hidden */
  1743. _switchToAlternateCameraConfiguration(active: boolean): void;
  1744. /**
  1745. * Gets the current view matrix
  1746. * @returns a Matrix
  1747. */
  1748. getViewMatrix(): Matrix;
  1749. /**
  1750. * Gets the current projection matrix
  1751. * @returns a Matrix
  1752. */
  1753. getProjectionMatrix(): Matrix;
  1754. /**
  1755. * Gets the current transform matrix
  1756. * @returns a Matrix made of View * Projection
  1757. */
  1758. getTransformMatrix(): Matrix;
  1759. /**
  1760. * Sets the current transform matrix
  1761. * @param view defines the View matrix to use
  1762. * @param projection defines the Projection matrix to use
  1763. */
  1764. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1765. /** @hidden */
  1766. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1767. /**
  1768. * Gets the uniform buffer used to store scene data
  1769. * @returns a UniformBuffer
  1770. */
  1771. getSceneUniformBuffer(): UniformBuffer;
  1772. /**
  1773. * Gets an unique (relatively to the current scene) Id
  1774. * @returns an unique number for the scene
  1775. */
  1776. getUniqueId(): number;
  1777. /**
  1778. * Add a mesh to the list of scene's meshes
  1779. * @param newMesh defines the mesh to add
  1780. * @param recursive if all child meshes should also be added to the scene
  1781. */
  1782. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1783. /**
  1784. * Remove a mesh for the list of scene's meshes
  1785. * @param toRemove defines the mesh to remove
  1786. * @param recursive if all child meshes should also be removed from the scene
  1787. * @returns the index where the mesh was in the mesh list
  1788. */
  1789. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1790. /**
  1791. * Add a transform node to the list of scene's transform nodes
  1792. * @param newTransformNode defines the transform node to add
  1793. */
  1794. addTransformNode(newTransformNode: TransformNode): void;
  1795. /**
  1796. * Remove a transform node for the list of scene's transform nodes
  1797. * @param toRemove defines the transform node to remove
  1798. * @returns the index where the transform node was in the transform node list
  1799. */
  1800. removeTransformNode(toRemove: TransformNode): number;
  1801. /**
  1802. * Remove a skeleton for the list of scene's skeletons
  1803. * @param toRemove defines the skeleton to remove
  1804. * @returns the index where the skeleton was in the skeleton list
  1805. */
  1806. removeSkeleton(toRemove: Skeleton): number;
  1807. /**
  1808. * Remove a morph target for the list of scene's morph targets
  1809. * @param toRemove defines the morph target to remove
  1810. * @returns the index where the morph target was in the morph target list
  1811. */
  1812. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1813. /**
  1814. * Remove a light for the list of scene's lights
  1815. * @param toRemove defines the light to remove
  1816. * @returns the index where the light was in the light list
  1817. */
  1818. removeLight(toRemove: Light): number;
  1819. /**
  1820. * Remove a camera for the list of scene's cameras
  1821. * @param toRemove defines the camera to remove
  1822. * @returns the index where the camera was in the camera list
  1823. */
  1824. removeCamera(toRemove: Camera): number;
  1825. /**
  1826. * Remove a particle system for the list of scene's particle systems
  1827. * @param toRemove defines the particle system to remove
  1828. * @returns the index where the particle system was in the particle system list
  1829. */
  1830. removeParticleSystem(toRemove: IParticleSystem): number;
  1831. /**
  1832. * Remove a animation for the list of scene's animations
  1833. * @param toRemove defines the animation to remove
  1834. * @returns the index where the animation was in the animation list
  1835. */
  1836. removeAnimation(toRemove: Animation): number;
  1837. /**
  1838. * Removes the given animation group from this scene.
  1839. * @param toRemove The animation group to remove
  1840. * @returns The index of the removed animation group
  1841. */
  1842. removeAnimationGroup(toRemove: AnimationGroup): number;
  1843. /**
  1844. * Removes the given multi-material from this scene.
  1845. * @param toRemove The multi-material to remove
  1846. * @returns The index of the removed multi-material
  1847. */
  1848. removeMultiMaterial(toRemove: MultiMaterial): number;
  1849. /**
  1850. * Removes the given material from this scene.
  1851. * @param toRemove The material to remove
  1852. * @returns The index of the removed material
  1853. */
  1854. removeMaterial(toRemove: Material): number;
  1855. /**
  1856. * Removes the given action manager from this scene.
  1857. * @param toRemove The action manager to remove
  1858. * @returns The index of the removed action manager
  1859. */
  1860. removeActionManager(toRemove: ActionManager): number;
  1861. /**
  1862. * Removes the given texture from this scene.
  1863. * @param toRemove The texture to remove
  1864. * @returns The index of the removed texture
  1865. */
  1866. removeTexture(toRemove: BaseTexture): number;
  1867. /**
  1868. * Adds the given light to this scene
  1869. * @param newLight The light to add
  1870. */
  1871. addLight(newLight: Light): void;
  1872. /**
  1873. * Sorts the list list based on light priorities
  1874. */
  1875. sortLightsByPriority(): void;
  1876. /**
  1877. * Adds the given camera to this scene
  1878. * @param newCamera The camera to add
  1879. */
  1880. addCamera(newCamera: Camera): void;
  1881. /**
  1882. * Adds the given skeleton to this scene
  1883. * @param newSkeleton The skeleton to add
  1884. */
  1885. addSkeleton(newSkeleton: Skeleton): void;
  1886. /**
  1887. * Adds the given particle system to this scene
  1888. * @param newParticleSystem The particle system to add
  1889. */
  1890. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1891. /**
  1892. * Adds the given animation to this scene
  1893. * @param newAnimation The animation to add
  1894. */
  1895. addAnimation(newAnimation: Animation): void;
  1896. /**
  1897. * Adds the given animation group to this scene.
  1898. * @param newAnimationGroup The animation group to add
  1899. */
  1900. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1901. /**
  1902. * Adds the given multi-material to this scene
  1903. * @param newMultiMaterial The multi-material to add
  1904. */
  1905. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1906. /**
  1907. * Adds the given material to this scene
  1908. * @param newMaterial The material to add
  1909. */
  1910. addMaterial(newMaterial: Material): void;
  1911. /**
  1912. * Adds the given morph target to this scene
  1913. * @param newMorphTargetManager The morph target to add
  1914. */
  1915. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1916. /**
  1917. * Adds the given geometry to this scene
  1918. * @param newGeometry The geometry to add
  1919. */
  1920. addGeometry(newGeometry: Geometry): void;
  1921. /**
  1922. * Adds the given action manager to this scene
  1923. * @param newActionManager The action manager to add
  1924. */
  1925. addActionManager(newActionManager: ActionManager): void;
  1926. /**
  1927. * Adds the given texture to this scene.
  1928. * @param newTexture The texture to add
  1929. */
  1930. addTexture(newTexture: BaseTexture): void;
  1931. /**
  1932. * Switch active camera
  1933. * @param newCamera defines the new active camera
  1934. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1935. */
  1936. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1937. /**
  1938. * sets the active camera of the scene using its ID
  1939. * @param id defines the camera's ID
  1940. * @return the new active camera or null if none found.
  1941. */
  1942. setActiveCameraByID(id: string): Nullable<Camera>;
  1943. /**
  1944. * sets the active camera of the scene using its name
  1945. * @param name defines the camera's name
  1946. * @returns the new active camera or null if none found.
  1947. */
  1948. setActiveCameraByName(name: string): Nullable<Camera>;
  1949. /**
  1950. * get an animation group using its name
  1951. * @param name defines the material's name
  1952. * @return the animation group or null if none found.
  1953. */
  1954. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1955. /**
  1956. * get a material using its id
  1957. * @param id defines the material's ID
  1958. * @return the material or null if none found.
  1959. */
  1960. getMaterialByID(id: string): Nullable<Material>;
  1961. /**
  1962. * Gets a material using its name
  1963. * @param name defines the material's name
  1964. * @return the material or null if none found.
  1965. */
  1966. getMaterialByName(name: string): Nullable<Material>;
  1967. /**
  1968. * Gets a camera using its id
  1969. * @param id defines the id to look for
  1970. * @returns the camera or null if not found
  1971. */
  1972. getCameraByID(id: string): Nullable<Camera>;
  1973. /**
  1974. * Gets a camera using its unique id
  1975. * @param uniqueId defines the unique id to look for
  1976. * @returns the camera or null if not found
  1977. */
  1978. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1979. /**
  1980. * Gets a camera using its name
  1981. * @param name defines the camera's name
  1982. * @return the camera or null if none found.
  1983. */
  1984. getCameraByName(name: string): Nullable<Camera>;
  1985. /**
  1986. * Gets a bone using its id
  1987. * @param id defines the bone's id
  1988. * @return the bone or null if not found
  1989. */
  1990. getBoneByID(id: string): Nullable<Bone>;
  1991. /**
  1992. * Gets a bone using its id
  1993. * @param name defines the bone's name
  1994. * @return the bone or null if not found
  1995. */
  1996. getBoneByName(name: string): Nullable<Bone>;
  1997. /**
  1998. * Gets a light node using its name
  1999. * @param name defines the the light's name
  2000. * @return the light or null if none found.
  2001. */
  2002. getLightByName(name: string): Nullable<Light>;
  2003. /**
  2004. * Gets a light node using its id
  2005. * @param id defines the light's id
  2006. * @return the light or null if none found.
  2007. */
  2008. getLightByID(id: string): Nullable<Light>;
  2009. /**
  2010. * Gets a light node using its scene-generated unique ID
  2011. * @param uniqueId defines the light's unique id
  2012. * @return the light or null if none found.
  2013. */
  2014. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2015. /**
  2016. * Gets a particle system by id
  2017. * @param id defines the particle system id
  2018. * @return the corresponding system or null if none found
  2019. */
  2020. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2021. /**
  2022. * Gets a geometry using its ID
  2023. * @param id defines the geometry's id
  2024. * @return the geometry or null if none found.
  2025. */
  2026. getGeometryByID(id: string): Nullable<Geometry>;
  2027. /**
  2028. * Add a new geometry to this scene
  2029. * @param geometry defines the geometry to be added to the scene.
  2030. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2031. * @return a boolean defining if the geometry was added or not
  2032. */
  2033. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2034. /**
  2035. * Removes an existing geometry
  2036. * @param geometry defines the geometry to be removed from the scene
  2037. * @return a boolean defining if the geometry was removed or not
  2038. */
  2039. removeGeometry(geometry: Geometry): boolean;
  2040. /**
  2041. * Gets the list of geometries attached to the scene
  2042. * @returns an array of Geometry
  2043. */
  2044. getGeometries(): Geometry[];
  2045. /**
  2046. * Gets the first added mesh found of a given ID
  2047. * @param id defines the id to search for
  2048. * @return the mesh found or null if not found at all
  2049. */
  2050. getMeshByID(id: string): Nullable<AbstractMesh>;
  2051. /**
  2052. * Gets a list of meshes using their id
  2053. * @param id defines the id to search for
  2054. * @returns a list of meshes
  2055. */
  2056. getMeshesByID(id: string): Array<AbstractMesh>;
  2057. /**
  2058. * Gets the first added transform node found of a given ID
  2059. * @param id defines the id to search for
  2060. * @return the found transform node or null if not found at all.
  2061. */
  2062. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2063. /**
  2064. * Gets a list of transform nodes using their id
  2065. * @param id defines the id to search for
  2066. * @returns a list of transform nodes
  2067. */
  2068. getTransformNodesByID(id: string): Array<TransformNode>;
  2069. /**
  2070. * Gets a mesh with its auto-generated unique id
  2071. * @param uniqueId defines the unique id to search for
  2072. * @return the found mesh or null if not found at all.
  2073. */
  2074. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2075. /**
  2076. * Gets a the last added mesh using a given id
  2077. * @param id defines the id to search for
  2078. * @return the found mesh or null if not found at all.
  2079. */
  2080. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2081. /**
  2082. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2083. * @param id defines the id to search for
  2084. * @return the found node or null if not found at all
  2085. */
  2086. getLastEntryByID(id: string): Nullable<Node>;
  2087. /**
  2088. * Gets a node (Mesh, Camera, Light) using a given id
  2089. * @param id defines the id to search for
  2090. * @return the found node or null if not found at all
  2091. */
  2092. getNodeByID(id: string): Nullable<Node>;
  2093. /**
  2094. * Gets a node (Mesh, Camera, Light) using a given name
  2095. * @param name defines the name to search for
  2096. * @return the found node or null if not found at all.
  2097. */
  2098. getNodeByName(name: string): Nullable<Node>;
  2099. /**
  2100. * Gets a mesh using a given name
  2101. * @param name defines the name to search for
  2102. * @return the found mesh or null if not found at all.
  2103. */
  2104. getMeshByName(name: string): Nullable<AbstractMesh>;
  2105. /**
  2106. * Gets a transform node using a given name
  2107. * @param name defines the name to search for
  2108. * @return the found transform node or null if not found at all.
  2109. */
  2110. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2111. /**
  2112. * Gets a sound using a given name
  2113. * @param name defines the name to search for
  2114. * @return the found sound or null if not found at all.
  2115. */
  2116. getSoundByName(name: string): Nullable<Sound>;
  2117. /**
  2118. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2119. * @param id defines the id to search for
  2120. * @return the found skeleton or null if not found at all.
  2121. */
  2122. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2123. /**
  2124. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2125. * @param id defines the id to search for
  2126. * @return the found skeleton or null if not found at all.
  2127. */
  2128. getSkeletonById(id: string): Nullable<Skeleton>;
  2129. /**
  2130. * Gets a skeleton using a given name
  2131. * @param name defines the name to search for
  2132. * @return the found skeleton or null if not found at all.
  2133. */
  2134. getSkeletonByName(name: string): Nullable<Skeleton>;
  2135. /**
  2136. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2137. * @param id defines the id to search for
  2138. * @return the found morph target manager or null if not found at all.
  2139. */
  2140. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2141. /**
  2142. * Gets a boolean indicating if the given mesh is active
  2143. * @param mesh defines the mesh to look for
  2144. * @returns true if the mesh is in the active list
  2145. */
  2146. isActiveMesh(mesh: AbstractMesh): boolean;
  2147. /**
  2148. * Return a unique id as a string which can serve as an identifier for the scene
  2149. */
  2150. readonly uid: string;
  2151. /**
  2152. * Add an externaly attached data from its key.
  2153. * This method call will fail and return false, if such key already exists.
  2154. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2155. * @param key the unique key that identifies the data
  2156. * @param data the data object to associate to the key for this Engine instance
  2157. * @return true if no such key were already present and the data was added successfully, false otherwise
  2158. */
  2159. addExternalData<T>(key: string, data: T): boolean;
  2160. /**
  2161. * Get an externaly attached data from its key
  2162. * @param key the unique key that identifies the data
  2163. * @return the associated data, if present (can be null), or undefined if not present
  2164. */
  2165. getExternalData<T>(key: string): Nullable<T>;
  2166. /**
  2167. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2168. * @param key the unique key that identifies the data
  2169. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2170. * @return the associated data, can be null if the factory returned null.
  2171. */
  2172. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2173. /**
  2174. * Remove an externaly attached data from the Engine instance
  2175. * @param key the unique key that identifies the data
  2176. * @return true if the data was successfully removed, false if it doesn't exist
  2177. */
  2178. removeExternalData(key: string): boolean;
  2179. private _evaluateSubMesh;
  2180. /**
  2181. * Clear the processed materials smart array preventing retention point in material dispose.
  2182. */
  2183. freeProcessedMaterials(): void;
  2184. /**
  2185. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2186. */
  2187. freeActiveMeshes(): void;
  2188. /**
  2189. * Clear the info related to rendering groups preventing retention points during dispose.
  2190. */
  2191. freeRenderingGroups(): void;
  2192. /** @hidden */
  2193. _isInIntermediateRendering(): boolean;
  2194. private _activeMeshCandidateProvider;
  2195. /**
  2196. * Defines the current active mesh candidate provider
  2197. * @param provider defines the provider to use
  2198. */
  2199. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2200. /**
  2201. * Gets the current active mesh candidate provider
  2202. * @returns the current active mesh candidate provider
  2203. */
  2204. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2205. private _activeMeshesFrozen;
  2206. /**
  2207. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2208. * @returns the current scene
  2209. */
  2210. freezeActiveMeshes(): Scene;
  2211. /**
  2212. * Use this function to restart evaluating active meshes on every frame
  2213. * @returns the current scene
  2214. */
  2215. unfreezeActiveMeshes(): Scene;
  2216. private _evaluateActiveMeshes;
  2217. private _activeMesh;
  2218. /**
  2219. * Update the transform matrix to update from the current active camera
  2220. * @param force defines a boolean used to force the update even if cache is up to date
  2221. */
  2222. updateTransformMatrix(force?: boolean): void;
  2223. /**
  2224. * 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)
  2225. * @param alternateCamera defines the camera to use
  2226. */
  2227. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2228. /** @hidden */
  2229. _allowPostProcessClear: boolean;
  2230. private _renderForCamera;
  2231. private _processSubCameras;
  2232. private _checkIntersections;
  2233. /**
  2234. * Render the scene
  2235. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2236. */
  2237. render(updateCameras?: boolean): void;
  2238. private _updateAudioParameters;
  2239. /**
  2240. * Gets or sets if audio support is enabled
  2241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2242. */
  2243. audioEnabled: boolean;
  2244. private _disableAudio;
  2245. private _enableAudio;
  2246. /**
  2247. * Gets or sets if audio will be output to headphones
  2248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2249. */
  2250. headphone: boolean;
  2251. private _switchAudioModeForHeadphones;
  2252. private _switchAudioModeForNormalSpeakers;
  2253. /**
  2254. * Freeze all materials
  2255. * A frozen material will not be updatable but should be faster to render
  2256. */
  2257. freezeMaterials(): void;
  2258. /**
  2259. * Unfreeze all materials
  2260. * A frozen material will not be updatable but should be faster to render
  2261. */
  2262. unfreezeMaterials(): void;
  2263. /**
  2264. * Releases all held ressources
  2265. */
  2266. dispose(): void;
  2267. /**
  2268. * Gets if the scene is already disposed
  2269. */
  2270. readonly isDisposed: boolean;
  2271. /**
  2272. * Releases sounds & soundtracks
  2273. */
  2274. disposeSounds(): void;
  2275. /**
  2276. * Call this function to reduce memory footprint of the scene.
  2277. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2278. */
  2279. clearCachedVertexData(): void;
  2280. /**
  2281. * This function will remove the local cached buffer data from texture.
  2282. * It will save memory but will prevent the texture from being rebuilt
  2283. */
  2284. cleanCachedTextureBuffer(): void;
  2285. /**
  2286. * Get the world extend vectors with an optional filter
  2287. *
  2288. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2289. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2290. */
  2291. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2292. min: Vector3;
  2293. max: Vector3;
  2294. };
  2295. /**
  2296. * Creates or updates the octree used to boost selection (picking)
  2297. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2298. * @param maxCapacity defines the maximum capacity per leaf
  2299. * @param maxDepth defines the maximum depth of the octree
  2300. * @returns an octree of AbstractMesh
  2301. */
  2302. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2303. /**
  2304. * Creates a ray that can be used to pick in the scene
  2305. * @param x defines the x coordinate of the origin (on-screen)
  2306. * @param y defines the y coordinate of the origin (on-screen)
  2307. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2308. * @param camera defines the camera to use for the picking
  2309. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2310. * @returns a Ray
  2311. */
  2312. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2313. /**
  2314. * Creates a ray that can be used to pick in the scene
  2315. * @param x defines the x coordinate of the origin (on-screen)
  2316. * @param y defines the y coordinate of the origin (on-screen)
  2317. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2318. * @param result defines the ray where to store the picking ray
  2319. * @param camera defines the camera to use for the picking
  2320. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2321. * @returns the current scene
  2322. */
  2323. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2324. /**
  2325. * Creates a ray that can be used to pick in the scene
  2326. * @param x defines the x coordinate of the origin (on-screen)
  2327. * @param y defines the y coordinate of the origin (on-screen)
  2328. * @param camera defines the camera to use for the picking
  2329. * @returns a Ray
  2330. */
  2331. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2332. /**
  2333. * Creates a ray that can be used to pick in the scene
  2334. * @param x defines the x coordinate of the origin (on-screen)
  2335. * @param y defines the y coordinate of the origin (on-screen)
  2336. * @param result defines the ray where to store the picking ray
  2337. * @param camera defines the camera to use for the picking
  2338. * @returns the current scene
  2339. */
  2340. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2341. private _internalPick;
  2342. private _internalMultiPick;
  2343. private _internalPickSprites;
  2344. private _tempPickingRay;
  2345. /** Launch a ray to try to pick a mesh in the scene
  2346. * @param x position on screen
  2347. * @param y position on screen
  2348. * @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
  2349. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2350. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2351. * @returns a PickingInfo
  2352. */
  2353. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2354. /** Launch a ray to try to pick a sprite in the scene
  2355. * @param x position on screen
  2356. * @param y position on screen
  2357. * @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
  2358. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2359. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2360. * @returns a PickingInfo
  2361. */
  2362. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2363. private _cachedRayForTransform;
  2364. /** Use the given ray to pick a mesh in the scene
  2365. * @param ray The ray to use to pick meshes
  2366. * @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
  2367. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2368. * @returns a PickingInfo
  2369. */
  2370. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2371. /**
  2372. * Launch a ray to try to pick a mesh in the scene
  2373. * @param x X position on screen
  2374. * @param y Y position on screen
  2375. * @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
  2376. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2377. * @returns an array of PickingInfo
  2378. */
  2379. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2380. /**
  2381. * Launch a ray to try to pick a mesh in the scene
  2382. * @param ray Ray to use
  2383. * @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
  2384. * @returns an array of PickingInfo
  2385. */
  2386. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2387. /**
  2388. * Force the value of meshUnderPointer
  2389. * @param mesh defines the mesh to use
  2390. */
  2391. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2392. /**
  2393. * Gets the mesh under the pointer
  2394. * @returns a Mesh or null if no mesh is under the pointer
  2395. */
  2396. getPointerOverMesh(): Nullable<AbstractMesh>;
  2397. /**
  2398. * Force the sprite under the pointer
  2399. * @param sprite defines the sprite to use
  2400. */
  2401. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2402. /**
  2403. * Gets the sprite under the pointer
  2404. * @returns a Sprite or null if no sprite is under the pointer
  2405. */
  2406. getPointerOverSprite(): Nullable<Sprite>;
  2407. /**
  2408. * Gets the current physics engine
  2409. * @returns a PhysicsEngine or null if none attached
  2410. */
  2411. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2412. /**
  2413. * Enables physics to the current scene
  2414. * @param gravity defines the scene's gravity for the physics engine
  2415. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2416. * @return a boolean indicating if the physics engine was initialized
  2417. */
  2418. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2419. /**
  2420. * Disables and disposes the physics engine associated with the scene
  2421. */
  2422. disablePhysicsEngine(): void;
  2423. /**
  2424. * Gets a boolean indicating if there is an active physics engine
  2425. * @returns a boolean indicating if there is an active physics engine
  2426. */
  2427. isPhysicsEnabled(): boolean;
  2428. /**
  2429. * Deletes a physics compound impostor
  2430. * @param compound defines the compound to delete
  2431. */
  2432. deleteCompoundImpostor(compound: any): void;
  2433. /** @hidden */
  2434. _rebuildGeometries(): void;
  2435. /** @hidden */
  2436. _rebuildTextures(): void;
  2437. /**
  2438. * Creates a default light for the scene.
  2439. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2440. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2441. */
  2442. createDefaultLight(replace?: boolean): void;
  2443. /**
  2444. * Creates a default camera for the scene.
  2445. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2446. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2447. * @param replace has default false, when true replaces the active camera in the scene
  2448. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2449. */
  2450. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2451. /**
  2452. * Creates a default camera and a default light.
  2453. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2454. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2455. * @param replace has the default false, when true replaces the active camera/light in the scene
  2456. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2457. */
  2458. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2459. /**
  2460. * Creates a new sky box
  2461. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2462. * @param environmentTexture defines the texture to use as environment texture
  2463. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2464. * @param scale defines the overall scale of the skybox
  2465. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2466. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2467. * @returns a new mesh holding the sky box
  2468. */
  2469. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2470. /**
  2471. * Creates a new environment
  2472. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2473. * @param options defines the options you can use to configure the environment
  2474. * @returns the new EnvironmentHelper
  2475. */
  2476. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2477. /**
  2478. * Creates a new VREXperienceHelper
  2479. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2480. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2481. * @returns a new VREXperienceHelper
  2482. */
  2483. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2484. private _getByTags;
  2485. /**
  2486. * Get a list of meshes by tags
  2487. * @param tagsQuery defines the tags query to use
  2488. * @param forEach defines a predicate used to filter results
  2489. * @returns an array of Mesh
  2490. */
  2491. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2492. /**
  2493. * Get a list of cameras by tags
  2494. * @param tagsQuery defines the tags query to use
  2495. * @param forEach defines a predicate used to filter results
  2496. * @returns an array of Camera
  2497. */
  2498. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2499. /**
  2500. * Get a list of lights by tags
  2501. * @param tagsQuery defines the tags query to use
  2502. * @param forEach defines a predicate used to filter results
  2503. * @returns an array of Light
  2504. */
  2505. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2506. /**
  2507. * Get a list of materials by tags
  2508. * @param tagsQuery defines the tags query to use
  2509. * @param forEach defines a predicate used to filter results
  2510. * @returns an array of Material
  2511. */
  2512. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2513. /**
  2514. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2515. * This allowed control for front to back rendering or reversly depending of the special needs.
  2516. *
  2517. * @param renderingGroupId The rendering group id corresponding to its index
  2518. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2519. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2520. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2521. */
  2522. 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;
  2523. /**
  2524. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2525. *
  2526. * @param renderingGroupId The rendering group id corresponding to its index
  2527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2528. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2529. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2530. */
  2531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2532. /**
  2533. * Gets the current auto clear configuration for one rendering group of the rendering
  2534. * manager.
  2535. * @param index the rendering group index to get the information for
  2536. * @returns The auto clear setup for the requested rendering group
  2537. */
  2538. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2539. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2540. blockMaterialDirtyMechanism: boolean;
  2541. /**
  2542. * Will flag all materials as dirty to trigger new shader compilation
  2543. * @param flag defines the flag used to specify which material part must be marked as dirty
  2544. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2545. */
  2546. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2547. /** @hidden */
  2548. _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;
  2549. /** @hidden */
  2550. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2551. }
  2552. }
  2553. declare module BABYLON {
  2554. /**
  2555. * Groups all the scene component constants in one place to ease maintenance.
  2556. * @hidden
  2557. */
  2558. class SceneComponentConstants {
  2559. static readonly NAME_EFFECTLAYER: string;
  2560. static readonly NAME_LAYER: string;
  2561. static readonly NAME_LENSFLARESYSTEM: string;
  2562. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2563. static readonly NAME_PARTICLESYSTEM: string;
  2564. static readonly NAME_GAMEPAD: string;
  2565. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2566. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2567. static readonly NAME_DEPTHRENDERER: string;
  2568. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2569. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2570. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2571. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2572. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2573. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2574. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2575. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2576. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2577. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2578. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2579. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2580. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2581. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2582. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2583. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2584. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2585. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2586. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2587. static readonly STEP_REBUILDGEOMETRY_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2588. }
  2589. /**
  2590. * This represents a scene component.
  2591. *
  2592. * This is used to decouple the dependency the scene is having on the different workloads like
  2593. * layers, post processes...
  2594. */
  2595. interface ISceneComponent {
  2596. /**
  2597. * The name of the component. Each component must have a unique name.
  2598. */
  2599. name: string;
  2600. /**
  2601. * The scene the component belongs to.
  2602. */
  2603. scene: Scene;
  2604. /**
  2605. * Register the component to one instance of a scene.
  2606. */
  2607. register(): void;
  2608. /**
  2609. * Rebuilds the elements related to this component in case of
  2610. * context lost for instance.
  2611. */
  2612. rebuild(): void;
  2613. /**
  2614. * Disposes the component and the associated ressources.
  2615. */
  2616. dispose(): void;
  2617. }
  2618. /**
  2619. * This represents a SERIALIZABLE scene component.
  2620. *
  2621. * This extends Scene Component to add Serialization methods on top.
  2622. */
  2623. interface ISceneSerializableComponent extends ISceneComponent {
  2624. /**
  2625. * Adds all the element from the container to the scene
  2626. * @param container the container holding the elements
  2627. */
  2628. addFromContainer(container: AbstractScene): void;
  2629. /**
  2630. * Removes all the elements in the container from the scene
  2631. * @param container contains the elements to remove
  2632. */
  2633. removeFromContainer(container: AbstractScene): void;
  2634. /**
  2635. * Serializes the component data to the specified json object
  2636. * @param serializationObject The object to serialize to
  2637. */
  2638. serialize(serializationObject: any): void;
  2639. }
  2640. /**
  2641. * Strong typing of a Mesh related stage step action
  2642. */
  2643. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2644. /**
  2645. * Strong typing of a Evaluate Sub Mesh related stage step action
  2646. */
  2647. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2648. /**
  2649. * Strong typing of a Active Mesh related stage step action
  2650. */
  2651. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2652. /**
  2653. * Strong typing of a Camera related stage step action
  2654. */
  2655. type CameraStageAction = (camera: Camera) => void;
  2656. /**
  2657. * Strong typing of a RenderingGroup related stage step action
  2658. */
  2659. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2660. /**
  2661. * Strong typing of a simple stage step action
  2662. */
  2663. type SimpleStageAction = () => void;
  2664. /**
  2665. * Strong typing of a render target action.
  2666. */
  2667. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2668. /**
  2669. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2670. * @hidden
  2671. */
  2672. class Stage<T extends Function> extends Array<{
  2673. index: number;
  2674. component: ISceneComponent;
  2675. action: T;
  2676. }> {
  2677. /**
  2678. * Hide ctor from the rest of the world.
  2679. * @param items The items to add.
  2680. */
  2681. private constructor();
  2682. /**
  2683. * Creates a new Stage.
  2684. * @returns A new instance of a Stage
  2685. */
  2686. static Create<T extends Function>(): Stage<T>;
  2687. /**
  2688. * Registers a step in an ordered way in the targeted stage.
  2689. * @param index Defines the position to register the step in
  2690. * @param component Defines the component attached to the step
  2691. * @param action Defines the action to launch during the step
  2692. */
  2693. registerStep(index: number, component: ISceneComponent, action: T): void;
  2694. /**
  2695. * Clears all the steps from the stage.
  2696. */
  2697. clear(): void;
  2698. }
  2699. }
  2700. declare module BABYLON {
  2701. type Nullable<T> = T | null;
  2702. type float = number;
  2703. type double = number;
  2704. type int = number;
  2705. type FloatArray = number[] | Float32Array;
  2706. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2707. /**
  2708. * Alias for types that can be used by a Buffer or VertexBuffer.
  2709. */
  2710. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2711. }
  2712. declare module BABYLON {
  2713. /**
  2714. * The action to be carried out following a trigger
  2715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2716. */
  2717. class Action {
  2718. /** the trigger, with or without parameters, for the action */
  2719. triggerOptions: any;
  2720. /**
  2721. * Trigger for the action
  2722. */
  2723. trigger: number;
  2724. /**
  2725. * Internal only - manager for action
  2726. * @hidden
  2727. */
  2728. _actionManager: ActionManager;
  2729. private _nextActiveAction;
  2730. private _child;
  2731. private _condition?;
  2732. private _triggerParameter;
  2733. /**
  2734. * An event triggered prior to action being executed.
  2735. */
  2736. onBeforeExecuteObservable: Observable<Action>;
  2737. /**
  2738. * Creates a new Action
  2739. * @param triggerOptions the trigger, with or without parameters, for the action
  2740. * @param condition an optional determinant of action
  2741. */
  2742. constructor(
  2743. /** the trigger, with or without parameters, for the action */
  2744. triggerOptions: any, condition?: Condition);
  2745. /**
  2746. * Internal only
  2747. * @hidden
  2748. */
  2749. _prepare(): void;
  2750. /**
  2751. * Gets the trigger parameters
  2752. * @returns the trigger parameters
  2753. */
  2754. getTriggerParameter(): any;
  2755. /**
  2756. * Internal only - executes current action event
  2757. * @hidden
  2758. */
  2759. _executeCurrent(evt?: ActionEvent): void;
  2760. /**
  2761. * Execute placeholder for child classes
  2762. * @param evt optional action event
  2763. */
  2764. execute(evt?: ActionEvent): void;
  2765. /**
  2766. * Skips to next active action
  2767. */
  2768. skipToNextActiveAction(): void;
  2769. /**
  2770. * Adds action to chain of actions, may be a DoNothingAction
  2771. * @param action defines the next action to execute
  2772. * @returns The action passed in
  2773. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2774. */
  2775. then(action: Action): Action;
  2776. /**
  2777. * Internal only
  2778. * @hidden
  2779. */
  2780. _getProperty(propertyPath: string): string;
  2781. /**
  2782. * Internal only
  2783. * @hidden
  2784. */
  2785. _getEffectiveTarget(target: any, propertyPath: string): any;
  2786. /**
  2787. * Serialize placeholder for child classes
  2788. * @param parent of child
  2789. * @returns the serialized object
  2790. */
  2791. serialize(parent: any): any;
  2792. /**
  2793. * Internal only called by serialize
  2794. * @hidden
  2795. */
  2796. protected _serialize(serializedAction: any, parent?: any): any;
  2797. /**
  2798. * Internal only
  2799. * @hidden
  2800. */
  2801. static _SerializeValueAsString: (value: any) => string;
  2802. /**
  2803. * Internal only
  2804. * @hidden
  2805. */
  2806. static _GetTargetProperty: (target: Scene | Node) => {
  2807. name: string;
  2808. targetType: string;
  2809. value: string;
  2810. };
  2811. }
  2812. }
  2813. declare module BABYLON {
  2814. /**
  2815. * ActionEvent is the event being sent when an action is triggered.
  2816. */
  2817. class ActionEvent {
  2818. /** The mesh or sprite that triggered the action */
  2819. source: any;
  2820. /** The X mouse cursor position at the time of the event */
  2821. pointerX: number;
  2822. /** The Y mouse cursor position at the time of the event */
  2823. pointerY: number;
  2824. /** The mesh that is currently pointed at (can be null) */
  2825. meshUnderPointer: Nullable<AbstractMesh>;
  2826. /** the original (browser) event that triggered the ActionEvent */
  2827. sourceEvent?: any;
  2828. /** additional data for the event */
  2829. additionalData?: any;
  2830. /**
  2831. * Creates a new ActionEvent
  2832. * @param source The mesh or sprite that triggered the action
  2833. * @param pointerX The X mouse cursor position at the time of the event
  2834. * @param pointerY The Y mouse cursor position at the time of the event
  2835. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2836. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2837. * @param additionalData additional data for the event
  2838. */
  2839. constructor(
  2840. /** The mesh or sprite that triggered the action */
  2841. source: any,
  2842. /** The X mouse cursor position at the time of the event */
  2843. pointerX: number,
  2844. /** The Y mouse cursor position at the time of the event */
  2845. pointerY: number,
  2846. /** The mesh that is currently pointed at (can be null) */
  2847. meshUnderPointer: Nullable<AbstractMesh>,
  2848. /** the original (browser) event that triggered the ActionEvent */
  2849. sourceEvent?: any,
  2850. /** additional data for the event */
  2851. additionalData?: any);
  2852. /**
  2853. * Helper function to auto-create an ActionEvent from a source mesh.
  2854. * @param source The source mesh that triggered the event
  2855. * @param evt The original (browser) event
  2856. * @param additionalData additional data for the event
  2857. * @returns the new ActionEvent
  2858. */
  2859. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2860. /**
  2861. * Helper function to auto-create an ActionEvent from a source sprite
  2862. * @param source The source sprite that triggered the event
  2863. * @param scene Scene associated with the sprite
  2864. * @param evt The original (browser) event
  2865. * @param additionalData additional data for the event
  2866. * @returns the new ActionEvent
  2867. */
  2868. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2869. /**
  2870. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2871. * @param scene the scene where the event occurred
  2872. * @param evt The original (browser) event
  2873. * @returns the new ActionEvent
  2874. */
  2875. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2876. /**
  2877. * Helper function to auto-create an ActionEvent from a primitive
  2878. * @param prim defines the target primitive
  2879. * @param pointerPos defines the pointer position
  2880. * @param evt The original (browser) event
  2881. * @param additionalData additional data for the event
  2882. * @returns the new ActionEvent
  2883. */
  2884. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2885. }
  2886. /**
  2887. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2888. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2890. */
  2891. class ActionManager {
  2892. private static _NothingTrigger;
  2893. private static _OnPickTrigger;
  2894. private static _OnLeftPickTrigger;
  2895. private static _OnRightPickTrigger;
  2896. private static _OnCenterPickTrigger;
  2897. private static _OnPickDownTrigger;
  2898. private static _OnDoublePickTrigger;
  2899. private static _OnPickUpTrigger;
  2900. private static _OnLongPressTrigger;
  2901. private static _OnPointerOverTrigger;
  2902. private static _OnPointerOutTrigger;
  2903. private static _OnEveryFrameTrigger;
  2904. private static _OnIntersectionEnterTrigger;
  2905. private static _OnIntersectionExitTrigger;
  2906. private static _OnKeyDownTrigger;
  2907. private static _OnKeyUpTrigger;
  2908. private static _OnPickOutTrigger;
  2909. /**
  2910. * Nothing
  2911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2912. */
  2913. static readonly NothingTrigger: number;
  2914. /**
  2915. * On pick
  2916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2917. */
  2918. static readonly OnPickTrigger: number;
  2919. /**
  2920. * On left pick
  2921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2922. */
  2923. static readonly OnLeftPickTrigger: number;
  2924. /**
  2925. * On right pick
  2926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2927. */
  2928. static readonly OnRightPickTrigger: number;
  2929. /**
  2930. * On center pick
  2931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2932. */
  2933. static readonly OnCenterPickTrigger: number;
  2934. /**
  2935. * On pick down
  2936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2937. */
  2938. static readonly OnPickDownTrigger: number;
  2939. /**
  2940. * On double pick
  2941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2942. */
  2943. static readonly OnDoublePickTrigger: number;
  2944. /**
  2945. * On pick up
  2946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2947. */
  2948. static readonly OnPickUpTrigger: number;
  2949. /**
  2950. * On pick out.
  2951. * This trigger will only be raised if you also declared a OnPickDown
  2952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2953. */
  2954. static readonly OnPickOutTrigger: number;
  2955. /**
  2956. * On long press
  2957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2958. */
  2959. static readonly OnLongPressTrigger: number;
  2960. /**
  2961. * On pointer over
  2962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2963. */
  2964. static readonly OnPointerOverTrigger: number;
  2965. /**
  2966. * On pointer out
  2967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2968. */
  2969. static readonly OnPointerOutTrigger: number;
  2970. /**
  2971. * On every frame
  2972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2973. */
  2974. static readonly OnEveryFrameTrigger: number;
  2975. /**
  2976. * On intersection enter
  2977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2978. */
  2979. static readonly OnIntersectionEnterTrigger: number;
  2980. /**
  2981. * On intersection exit
  2982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2983. */
  2984. static readonly OnIntersectionExitTrigger: number;
  2985. /**
  2986. * On key down
  2987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2988. */
  2989. static readonly OnKeyDownTrigger: number;
  2990. /**
  2991. * On key up
  2992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2993. */
  2994. static readonly OnKeyUpTrigger: number;
  2995. /** Gets the list of active triggers */
  2996. static Triggers: {
  2997. [key: string]: number;
  2998. };
  2999. /** Gets the list of actions */
  3000. actions: Action[];
  3001. /** Gets the cursor to use when hovering items */
  3002. hoverCursor: string;
  3003. private _scene;
  3004. /**
  3005. * Creates a new action manager
  3006. * @param scene defines the hosting scene
  3007. */
  3008. constructor(scene: Scene);
  3009. /**
  3010. * Releases all associated resources
  3011. */
  3012. dispose(): void;
  3013. /**
  3014. * Gets hosting scene
  3015. * @returns the hosting scene
  3016. */
  3017. getScene(): Scene;
  3018. /**
  3019. * Does this action manager handles actions of any of the given triggers
  3020. * @param triggers defines the triggers to be tested
  3021. * @return a boolean indicating whether one (or more) of the triggers is handled
  3022. */
  3023. hasSpecificTriggers(triggers: number[]): boolean;
  3024. /**
  3025. * Does this action manager handles actions of a given trigger
  3026. * @param trigger defines the trigger to be tested
  3027. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3028. * @return whether the trigger is handled
  3029. */
  3030. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3031. /**
  3032. * Does this action manager has pointer triggers
  3033. */
  3034. readonly hasPointerTriggers: boolean;
  3035. /**
  3036. * Does this action manager has pick triggers
  3037. */
  3038. readonly hasPickTriggers: boolean;
  3039. /**
  3040. * Does exist one action manager with at least one trigger
  3041. **/
  3042. static readonly HasTriggers: boolean;
  3043. /**
  3044. * Does exist one action manager with at least one pick trigger
  3045. **/
  3046. static readonly HasPickTriggers: boolean;
  3047. /**
  3048. * Does exist one action manager that handles actions of a given trigger
  3049. * @param trigger defines the trigger to be tested
  3050. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3051. **/
  3052. static HasSpecificTrigger(trigger: number): boolean;
  3053. /**
  3054. * Registers an action to this action manager
  3055. * @param action defines the action to be registered
  3056. * @return the action amended (prepared) after registration
  3057. */
  3058. registerAction(action: Action): Nullable<Action>;
  3059. /**
  3060. * Unregisters an action to this action manager
  3061. * @param action defines the action to be unregistered
  3062. * @return a boolean indicating whether the action has been unregistered
  3063. */
  3064. unregisterAction(action: Action): Boolean;
  3065. /**
  3066. * Process a specific trigger
  3067. * @param trigger defines the trigger to process
  3068. * @param evt defines the event details to be processed
  3069. */
  3070. processTrigger(trigger: number, evt?: ActionEvent): void;
  3071. /** @hidden */
  3072. _getEffectiveTarget(target: any, propertyPath: string): any;
  3073. /** @hidden */
  3074. _getProperty(propertyPath: string): string;
  3075. /**
  3076. * Serialize this manager to a JSON object
  3077. * @param name defines the property name to store this manager
  3078. * @returns a JSON representation of this manager
  3079. */
  3080. serialize(name: string): any;
  3081. /**
  3082. * Creates a new ActionManager from a JSON data
  3083. * @param parsedActions defines the JSON data to read from
  3084. * @param object defines the hosting mesh
  3085. * @param scene defines the hosting scene
  3086. */
  3087. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3088. /**
  3089. * Get a trigger name by index
  3090. * @param trigger defines the trigger index
  3091. * @returns a trigger name
  3092. */
  3093. static GetTriggerName(trigger: number): string;
  3094. }
  3095. }
  3096. declare module BABYLON {
  3097. /**
  3098. * A Condition applied to an Action
  3099. */
  3100. class Condition {
  3101. /**
  3102. * Internal only - manager for action
  3103. * @hidden
  3104. */
  3105. _actionManager: ActionManager;
  3106. /**
  3107. * Internal only
  3108. * @hidden
  3109. */
  3110. _evaluationId: number;
  3111. /**
  3112. * Internal only
  3113. * @hidden
  3114. */
  3115. _currentResult: boolean;
  3116. /**
  3117. * Creates a new Condition
  3118. * @param actionManager the manager of the action the condition is applied to
  3119. */
  3120. constructor(actionManager: ActionManager);
  3121. /**
  3122. * Check if the current condition is valid
  3123. * @returns a boolean
  3124. */
  3125. isValid(): boolean;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. _getProperty(propertyPath: string): string;
  3131. /**
  3132. * Internal only
  3133. * @hidden
  3134. */
  3135. _getEffectiveTarget(target: any, propertyPath: string): any;
  3136. /**
  3137. * Serialize placeholder for child classes
  3138. * @returns the serialized object
  3139. */
  3140. serialize(): any;
  3141. /**
  3142. * Internal only
  3143. * @hidden
  3144. */
  3145. protected _serialize(serializedCondition: any): any;
  3146. }
  3147. /**
  3148. * Defines specific conditional operators as extensions of Condition
  3149. */
  3150. class ValueCondition extends Condition {
  3151. /** path to specify the property of the target the conditional operator uses */
  3152. propertyPath: string;
  3153. /** the value compared by the conditional operator against the current value of the property */
  3154. value: any;
  3155. /** the conditional operator, default ValueCondition.IsEqual */
  3156. operator: number;
  3157. /**
  3158. * Internal only
  3159. * @hidden
  3160. */
  3161. private static _IsEqual;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private static _IsDifferent;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private static _IsGreater;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private static _IsLesser;
  3177. /**
  3178. * returns the number for IsEqual
  3179. */
  3180. static readonly IsEqual: number;
  3181. /**
  3182. * Returns the number for IsDifferent
  3183. */
  3184. static readonly IsDifferent: number;
  3185. /**
  3186. * Returns the number for IsGreater
  3187. */
  3188. static readonly IsGreater: number;
  3189. /**
  3190. * Returns the number for IsLesser
  3191. */
  3192. static readonly IsLesser: number;
  3193. /**
  3194. * Internal only The action manager for the condition
  3195. * @hidden
  3196. */
  3197. _actionManager: ActionManager;
  3198. /**
  3199. * Internal only
  3200. * @hidden
  3201. */
  3202. private _target;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. private _effectiveTarget;
  3208. /**
  3209. * Internal only
  3210. * @hidden
  3211. */
  3212. private _property;
  3213. /**
  3214. * Creates a new ValueCondition
  3215. * @param actionManager manager for the action the condition applies to
  3216. * @param target for the action
  3217. * @param propertyPath path to specify the property of the target the conditional operator uses
  3218. * @param value the value compared by the conditional operator against the current value of the property
  3219. * @param operator the conditional operator, default ValueCondition.IsEqual
  3220. */
  3221. constructor(actionManager: ActionManager, target: any,
  3222. /** path to specify the property of the target the conditional operator uses */
  3223. propertyPath: string,
  3224. /** the value compared by the conditional operator against the current value of the property */
  3225. value: any,
  3226. /** the conditional operator, default ValueCondition.IsEqual */
  3227. operator?: number);
  3228. /**
  3229. * Compares the given value with the property value for the specified conditional operator
  3230. * @returns the result of the comparison
  3231. */
  3232. isValid(): boolean;
  3233. /**
  3234. * Serialize the ValueCondition into a JSON compatible object
  3235. * @returns serialization object
  3236. */
  3237. serialize(): any;
  3238. /**
  3239. * Gets the name of the conditional operator for the ValueCondition
  3240. * @param operator the conditional operator
  3241. * @returns the name
  3242. */
  3243. static GetOperatorName(operator: number): string;
  3244. }
  3245. /**
  3246. * Defines a predicate condition as an extension of Condition
  3247. */
  3248. class PredicateCondition extends Condition {
  3249. /** defines the predicate function used to validate the condition */
  3250. predicate: () => boolean;
  3251. /**
  3252. * Internal only - manager for action
  3253. * @hidden
  3254. */
  3255. _actionManager: ActionManager;
  3256. /**
  3257. * Creates a new PredicateCondition
  3258. * @param actionManager manager for the action the condition applies to
  3259. * @param predicate defines the predicate function used to validate the condition
  3260. */
  3261. constructor(actionManager: ActionManager,
  3262. /** defines the predicate function used to validate the condition */
  3263. predicate: () => boolean);
  3264. /**
  3265. * @returns the validity of the predicate condition
  3266. */
  3267. isValid(): boolean;
  3268. }
  3269. /**
  3270. * Defines a state condition as an extension of Condition
  3271. */
  3272. class StateCondition extends Condition {
  3273. value: string;
  3274. /**
  3275. * Internal only - manager for action
  3276. * @hidden
  3277. */
  3278. _actionManager: ActionManager;
  3279. /**
  3280. * Internal only
  3281. * @hidden
  3282. */
  3283. private _target;
  3284. /**
  3285. * Creates a new StateCondition
  3286. * @param actionManager manager for the action the condition applies to
  3287. * @param target of the condition
  3288. * @param value to compare with target state
  3289. */
  3290. constructor(actionManager: ActionManager, target: any, value: string);
  3291. /**
  3292. * @returns the validity of the state
  3293. */
  3294. isValid(): boolean;
  3295. /**
  3296. * Serialize the StateCondition into a JSON compatible object
  3297. * @returns serialization object
  3298. */
  3299. serialize(): any;
  3300. }
  3301. }
  3302. declare module BABYLON {
  3303. class SwitchBooleanAction extends Action {
  3304. propertyPath: string;
  3305. private _target;
  3306. private _effectiveTarget;
  3307. private _property;
  3308. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3309. /** @hidden */
  3310. _prepare(): void;
  3311. execute(): void;
  3312. serialize(parent: any): any;
  3313. }
  3314. class SetStateAction extends Action {
  3315. value: string;
  3316. private _target;
  3317. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3318. execute(): void;
  3319. serialize(parent: any): any;
  3320. }
  3321. class SetValueAction extends Action {
  3322. propertyPath: string;
  3323. value: any;
  3324. private _target;
  3325. private _effectiveTarget;
  3326. private _property;
  3327. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3328. /** @hidden */
  3329. _prepare(): void;
  3330. execute(): void;
  3331. serialize(parent: any): any;
  3332. }
  3333. class IncrementValueAction extends Action {
  3334. propertyPath: string;
  3335. value: any;
  3336. private _target;
  3337. private _effectiveTarget;
  3338. private _property;
  3339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3340. /** @hidden */
  3341. _prepare(): void;
  3342. execute(): void;
  3343. serialize(parent: any): any;
  3344. }
  3345. class PlayAnimationAction extends Action {
  3346. from: number;
  3347. to: number;
  3348. loop?: boolean | undefined;
  3349. private _target;
  3350. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3351. /** @hidden */
  3352. _prepare(): void;
  3353. execute(): void;
  3354. serialize(parent: any): any;
  3355. }
  3356. class StopAnimationAction extends Action {
  3357. private _target;
  3358. constructor(triggerOptions: any, target: any, condition?: Condition);
  3359. /** @hidden */
  3360. _prepare(): void;
  3361. execute(): void;
  3362. serialize(parent: any): any;
  3363. }
  3364. class DoNothingAction extends Action {
  3365. constructor(triggerOptions?: any, condition?: Condition);
  3366. execute(): void;
  3367. serialize(parent: any): any;
  3368. }
  3369. class CombineAction extends Action {
  3370. children: Action[];
  3371. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3372. /** @hidden */
  3373. _prepare(): void;
  3374. execute(evt: ActionEvent): void;
  3375. serialize(parent: any): any;
  3376. }
  3377. class ExecuteCodeAction extends Action {
  3378. func: (evt: ActionEvent) => void;
  3379. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3380. execute(evt: ActionEvent): void;
  3381. }
  3382. class SetParentAction extends Action {
  3383. private _parent;
  3384. private _target;
  3385. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3386. /** @hidden */
  3387. _prepare(): void;
  3388. execute(): void;
  3389. serialize(parent: any): any;
  3390. }
  3391. class PlaySoundAction extends Action {
  3392. private _sound;
  3393. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3394. /** @hidden */
  3395. _prepare(): void;
  3396. execute(): void;
  3397. serialize(parent: any): any;
  3398. }
  3399. class StopSoundAction extends Action {
  3400. private _sound;
  3401. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3402. /** @hidden */
  3403. _prepare(): void;
  3404. execute(): void;
  3405. serialize(parent: any): any;
  3406. }
  3407. }
  3408. declare module BABYLON {
  3409. class InterpolateValueAction extends Action {
  3410. propertyPath: string;
  3411. value: any;
  3412. duration: number;
  3413. stopOtherAnimations?: boolean | undefined;
  3414. onInterpolationDone?: (() => void) | undefined;
  3415. private _target;
  3416. private _effectiveTarget;
  3417. private _property;
  3418. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3420. /** @hidden */
  3421. _prepare(): void;
  3422. execute(): void;
  3423. serialize(parent: any): any;
  3424. }
  3425. }
  3426. declare module BABYLON {
  3427. /**
  3428. * Class used to store an actual running animation
  3429. */
  3430. class Animatable {
  3431. /** defines the target object */
  3432. target: any;
  3433. /** defines the starting frame number (default is 0) */
  3434. fromFrame: number;
  3435. /** defines the ending frame number (default is 100) */
  3436. toFrame: number;
  3437. /** defines if the animation must loop (default is false) */
  3438. loopAnimation: boolean;
  3439. /** defines a callback to call when animation ends if it is not looping */
  3440. onAnimationEnd?: (() => void) | null | undefined;
  3441. private _localDelayOffset;
  3442. private _pausedDelay;
  3443. private _runtimeAnimations;
  3444. private _paused;
  3445. private _scene;
  3446. private _speedRatio;
  3447. private _weight;
  3448. private _syncRoot;
  3449. /**
  3450. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3451. * This will only apply for non looping animation (default is true)
  3452. */
  3453. disposeOnEnd: boolean;
  3454. /**
  3455. * Gets a boolean indicating if the animation has started
  3456. */
  3457. animationStarted: boolean;
  3458. /**
  3459. * Observer raised when the animation ends
  3460. */
  3461. onAnimationEndObservable: Observable<Animatable>;
  3462. /**
  3463. * Gets the root Animatable used to synchronize and normalize animations
  3464. */
  3465. readonly syncRoot: Animatable;
  3466. /**
  3467. * Gets the current frame of the first RuntimeAnimation
  3468. * Used to synchronize Animatables
  3469. */
  3470. readonly masterFrame: number;
  3471. /**
  3472. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3473. */
  3474. weight: number;
  3475. /**
  3476. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3477. */
  3478. speedRatio: number;
  3479. /**
  3480. * Creates a new Animatable
  3481. * @param scene defines the hosting scene
  3482. * @param target defines the target object
  3483. * @param fromFrame defines the starting frame number (default is 0)
  3484. * @param toFrame defines the ending frame number (default is 100)
  3485. * @param loopAnimation defines if the animation must loop (default is false)
  3486. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3487. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3488. * @param animations defines a group of animation to add to the new Animatable
  3489. */
  3490. constructor(scene: Scene,
  3491. /** defines the target object */
  3492. target: any,
  3493. /** defines the starting frame number (default is 0) */
  3494. fromFrame?: number,
  3495. /** defines the ending frame number (default is 100) */
  3496. toFrame?: number,
  3497. /** defines if the animation must loop (default is false) */
  3498. loopAnimation?: boolean, speedRatio?: number,
  3499. /** defines a callback to call when animation ends if it is not looping */
  3500. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3501. /**
  3502. * Synchronize and normalize current Animatable with a source Animatable
  3503. * This is useful when using animation weights and when animations are not of the same length
  3504. * @param root defines the root Animatable to synchronize with
  3505. * @returns the current Animatable
  3506. */
  3507. syncWith(root: Animatable): Animatable;
  3508. /**
  3509. * Gets the list of runtime animations
  3510. * @returns an array of RuntimeAnimation
  3511. */
  3512. getAnimations(): RuntimeAnimation[];
  3513. /**
  3514. * Adds more animations to the current animatable
  3515. * @param target defines the target of the animations
  3516. * @param animations defines the new animations to add
  3517. */
  3518. appendAnimations(target: any, animations: Animation[]): void;
  3519. /**
  3520. * Gets the source animation for a specific property
  3521. * @param property defines the propertyu to look for
  3522. * @returns null or the source animation for the given property
  3523. */
  3524. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3525. /**
  3526. * Gets the runtime animation for a specific property
  3527. * @param property defines the propertyu to look for
  3528. * @returns null or the runtime animation for the given property
  3529. */
  3530. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3531. /**
  3532. * Resets the animatable to its original state
  3533. */
  3534. reset(): void;
  3535. /**
  3536. * Allows the animatable to blend with current running animations
  3537. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3538. * @param blendingSpeed defines the blending speed to use
  3539. */
  3540. enableBlending(blendingSpeed: number): void;
  3541. /**
  3542. * Disable animation blending
  3543. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3544. */
  3545. disableBlending(): void;
  3546. /**
  3547. * Jump directly to a given frame
  3548. * @param frame defines the frame to jump to
  3549. */
  3550. goToFrame(frame: number): void;
  3551. /**
  3552. * Pause the animation
  3553. */
  3554. pause(): void;
  3555. /**
  3556. * Restart the animation
  3557. */
  3558. restart(): void;
  3559. private _raiseOnAnimationEnd;
  3560. /**
  3561. * Stop and delete the current animation
  3562. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3563. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3564. */
  3565. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3566. /**
  3567. * Wait asynchronously for the animation to end
  3568. * @returns a promise which will be fullfilled when the animation ends
  3569. */
  3570. waitAsync(): Promise<Animatable>;
  3571. /** @hidden */
  3572. _animate(delay: number): boolean;
  3573. }
  3574. }
  3575. declare module BABYLON {
  3576. /**
  3577. * Represents the range of an animation
  3578. */
  3579. class AnimationRange {
  3580. /**The name of the animation range**/
  3581. name: string;
  3582. /**The starting frame of the animation */
  3583. from: number;
  3584. /**The ending frame of the animation*/
  3585. to: number;
  3586. /**
  3587. * Initializes the range of an animation
  3588. * @param name The name of the animation range
  3589. * @param from The starting frame of the animation
  3590. * @param to The ending frame of the animation
  3591. */
  3592. constructor(
  3593. /**The name of the animation range**/
  3594. name: string,
  3595. /**The starting frame of the animation */
  3596. from: number,
  3597. /**The ending frame of the animation*/
  3598. to: number);
  3599. /**
  3600. * Makes a copy of the animation range
  3601. * @returns A copy of the animation range
  3602. */
  3603. clone(): AnimationRange;
  3604. }
  3605. /**
  3606. * Composed of a frame, and an action function
  3607. */
  3608. class AnimationEvent {
  3609. /** The frame for which the event is triggered **/
  3610. frame: number;
  3611. /** The event to perform when triggered **/
  3612. action: (currentFrame: number) => void;
  3613. /** Specifies if the event should be triggered only once**/
  3614. onlyOnce?: boolean | undefined;
  3615. /**
  3616. * Specifies if the animation event is done
  3617. */
  3618. isDone: boolean;
  3619. /**
  3620. * Initializes the animation event
  3621. * @param frame The frame for which the event is triggered
  3622. * @param action The event to perform when triggered
  3623. * @param onlyOnce Specifies if the event should be triggered only once
  3624. */
  3625. constructor(
  3626. /** The frame for which the event is triggered **/
  3627. frame: number,
  3628. /** The event to perform when triggered **/
  3629. action: (currentFrame: number) => void,
  3630. /** Specifies if the event should be triggered only once**/
  3631. onlyOnce?: boolean | undefined);
  3632. /** @hidden */
  3633. _clone(): AnimationEvent;
  3634. }
  3635. /**
  3636. * A cursor which tracks a point on a path
  3637. */
  3638. class PathCursor {
  3639. private path;
  3640. /**
  3641. * Stores path cursor callbacks for when an onchange event is triggered
  3642. */
  3643. private _onchange;
  3644. /**
  3645. * The value of the path cursor
  3646. */
  3647. value: number;
  3648. /**
  3649. * The animation array of the path cursor
  3650. */
  3651. animations: Animation[];
  3652. /**
  3653. * Initializes the path cursor
  3654. * @param path The path to track
  3655. */
  3656. constructor(path: Path2);
  3657. /**
  3658. * Gets the cursor point on the path
  3659. * @returns A point on the path cursor at the cursor location
  3660. */
  3661. getPoint(): Vector3;
  3662. /**
  3663. * Moves the cursor ahead by the step amount
  3664. * @param step The amount to move the cursor forward
  3665. * @returns This path cursor
  3666. */
  3667. moveAhead(step?: number): PathCursor;
  3668. /**
  3669. * Moves the cursor behind by the step amount
  3670. * @param step The amount to move the cursor back
  3671. * @returns This path cursor
  3672. */
  3673. moveBack(step?: number): PathCursor;
  3674. /**
  3675. * Moves the cursor by the step amount
  3676. * If the step amount is greater than one, an exception is thrown
  3677. * @param step The amount to move the cursor
  3678. * @returns This path cursor
  3679. */
  3680. move(step: number): PathCursor;
  3681. /**
  3682. * Ensures that the value is limited between zero and one
  3683. * @returns This path cursor
  3684. */
  3685. private ensureLimits;
  3686. /**
  3687. * Runs onchange callbacks on change (used by the animation engine)
  3688. * @returns This path cursor
  3689. */
  3690. private raiseOnChange;
  3691. /**
  3692. * Executes a function on change
  3693. * @param f A path cursor onchange callback
  3694. * @returns This path cursor
  3695. */
  3696. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3697. }
  3698. /**
  3699. * Defines an interface which represents an animation key frame
  3700. */
  3701. interface IAnimationKey {
  3702. /**
  3703. * Frame of the key frame
  3704. */
  3705. frame: number;
  3706. /**
  3707. * Value at the specifies key frame
  3708. */
  3709. value: any;
  3710. /**
  3711. * The input tangent for the cubic hermite spline
  3712. */
  3713. inTangent?: any;
  3714. /**
  3715. * The output tangent for the cubic hermite spline
  3716. */
  3717. outTangent?: any;
  3718. /**
  3719. * The animation interpolation type
  3720. */
  3721. interpolation?: AnimationKeyInterpolation;
  3722. }
  3723. /**
  3724. * Enum for the animation key frame interpolation type
  3725. */
  3726. enum AnimationKeyInterpolation {
  3727. /**
  3728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3729. */
  3730. STEP = 1
  3731. }
  3732. /**
  3733. * Class used to store any kind of animation
  3734. */
  3735. class Animation {
  3736. /**Name of the animation */
  3737. name: string;
  3738. /**Property to animate */
  3739. targetProperty: string;
  3740. /**The frames per second of the animation */
  3741. framePerSecond: number;
  3742. /**The data type of the animation */
  3743. dataType: number;
  3744. /**The loop mode of the animation */
  3745. loopMode?: number | undefined;
  3746. /**Specifies if blending should be enabled */
  3747. enableBlending?: boolean | undefined;
  3748. /**
  3749. * Use matrix interpolation instead of using direct key value when animating matrices
  3750. */
  3751. static AllowMatricesInterpolation: boolean;
  3752. /**
  3753. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3754. */
  3755. static AllowMatrixDecomposeForInterpolation: boolean;
  3756. /**
  3757. * Stores the key frames of the animation
  3758. */
  3759. private _keys;
  3760. /**
  3761. * Stores the easing function of the animation
  3762. */
  3763. private _easingFunction;
  3764. /**
  3765. * @hidden Internal use only
  3766. */
  3767. _runtimeAnimations: RuntimeAnimation[];
  3768. /**
  3769. * The set of event that will be linked to this animation
  3770. */
  3771. private _events;
  3772. /**
  3773. * Stores an array of target property paths
  3774. */
  3775. targetPropertyPath: string[];
  3776. /**
  3777. * Stores the blending speed of the animation
  3778. */
  3779. blendingSpeed: number;
  3780. /**
  3781. * Stores the animation ranges for the animation
  3782. */
  3783. private _ranges;
  3784. /**
  3785. * @hidden Internal use
  3786. */
  3787. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3788. /**
  3789. * Sets up an animation
  3790. * @param property The property to animate
  3791. * @param animationType The animation type to apply
  3792. * @param framePerSecond The frames per second of the animation
  3793. * @param easingFunction The easing function used in the animation
  3794. * @returns The created animation
  3795. */
  3796. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3797. /**
  3798. * Create and start an animation on a node
  3799. * @param name defines the name of the global animation that will be run on all nodes
  3800. * @param node defines the root node where the animation will take place
  3801. * @param targetProperty defines property to animate
  3802. * @param framePerSecond defines the number of frame per second yo use
  3803. * @param totalFrame defines the number of frames in total
  3804. * @param from defines the initial value
  3805. * @param to defines the final value
  3806. * @param loopMode defines which loop mode you want to use (off by default)
  3807. * @param easingFunction defines the easing function to use (linear by default)
  3808. * @param onAnimationEnd defines the callback to call when animation end
  3809. * @returns the animatable created for this animation
  3810. */
  3811. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3812. /**
  3813. * Create and start an animation on a node and its descendants
  3814. * @param name defines the name of the global animation that will be run on all nodes
  3815. * @param node defines the root node where the animation will take place
  3816. * @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
  3817. * @param targetProperty defines property to animate
  3818. * @param framePerSecond defines the number of frame per second to use
  3819. * @param totalFrame defines the number of frames in total
  3820. * @param from defines the initial value
  3821. * @param to defines the final value
  3822. * @param loopMode defines which loop mode you want to use (off by default)
  3823. * @param easingFunction defines the easing function to use (linear by default)
  3824. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3825. * @returns the list of animatables created for all nodes
  3826. * @example https://www.babylonjs-playground.com/#MH0VLI
  3827. */
  3828. 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[]>;
  3829. /**
  3830. * Creates a new animation, merges it with the existing animations and starts it
  3831. * @param name Name of the animation
  3832. * @param node Node which contains the scene that begins the animations
  3833. * @param targetProperty Specifies which property to animate
  3834. * @param framePerSecond The frames per second of the animation
  3835. * @param totalFrame The total number of frames
  3836. * @param from The frame at the beginning of the animation
  3837. * @param to The frame at the end of the animation
  3838. * @param loopMode Specifies the loop mode of the animation
  3839. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3840. * @param onAnimationEnd Callback to run once the animation is complete
  3841. * @returns Nullable animation
  3842. */
  3843. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3844. /**
  3845. * Transition property of an host to the target Value
  3846. * @param property The property to transition
  3847. * @param targetValue The target Value of the property
  3848. * @param host The object where the property to animate belongs
  3849. * @param scene Scene used to run the animation
  3850. * @param frameRate Framerate (in frame/s) to use
  3851. * @param transition The transition type we want to use
  3852. * @param duration The duration of the animation, in milliseconds
  3853. * @param onAnimationEnd Callback trigger at the end of the animation
  3854. * @returns Nullable animation
  3855. */
  3856. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3857. /**
  3858. * Return the array of runtime animations currently using this animation
  3859. */
  3860. readonly runtimeAnimations: RuntimeAnimation[];
  3861. /**
  3862. * Specifies if any of the runtime animations are currently running
  3863. */
  3864. readonly hasRunningRuntimeAnimations: boolean;
  3865. /**
  3866. * Initializes the animation
  3867. * @param name Name of the animation
  3868. * @param targetProperty Property to animate
  3869. * @param framePerSecond The frames per second of the animation
  3870. * @param dataType The data type of the animation
  3871. * @param loopMode The loop mode of the animation
  3872. * @param enableBlendings Specifies if blending should be enabled
  3873. */
  3874. constructor(
  3875. /**Name of the animation */
  3876. name: string,
  3877. /**Property to animate */
  3878. targetProperty: string,
  3879. /**The frames per second of the animation */
  3880. framePerSecond: number,
  3881. /**The data type of the animation */
  3882. dataType: number,
  3883. /**The loop mode of the animation */
  3884. loopMode?: number | undefined,
  3885. /**Specifies if blending should be enabled */
  3886. enableBlending?: boolean | undefined);
  3887. /**
  3888. * Converts the animation to a string
  3889. * @param fullDetails support for multiple levels of logging within scene loading
  3890. * @returns String form of the animation
  3891. */
  3892. toString(fullDetails?: boolean): string;
  3893. /**
  3894. * Add an event to this animation
  3895. * @param event Event to add
  3896. */
  3897. addEvent(event: AnimationEvent): void;
  3898. /**
  3899. * Remove all events found at the given frame
  3900. * @param frame The frame to remove events from
  3901. */
  3902. removeEvents(frame: number): void;
  3903. /**
  3904. * Retrieves all the events from the animation
  3905. * @returns Events from the animation
  3906. */
  3907. getEvents(): AnimationEvent[];
  3908. /**
  3909. * Creates an animation range
  3910. * @param name Name of the animation range
  3911. * @param from Starting frame of the animation range
  3912. * @param to Ending frame of the animation
  3913. */
  3914. createRange(name: string, from: number, to: number): void;
  3915. /**
  3916. * Deletes an animation range by name
  3917. * @param name Name of the animation range to delete
  3918. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3919. */
  3920. deleteRange(name: string, deleteFrames?: boolean): void;
  3921. /**
  3922. * Gets the animation range by name, or null if not defined
  3923. * @param name Name of the animation range
  3924. * @returns Nullable animation range
  3925. */
  3926. getRange(name: string): Nullable<AnimationRange>;
  3927. /**
  3928. * Gets the key frames from the animation
  3929. * @returns The key frames of the animation
  3930. */
  3931. getKeys(): Array<IAnimationKey>;
  3932. /**
  3933. * Gets the highest frame rate of the animation
  3934. * @returns Highest frame rate of the animation
  3935. */
  3936. getHighestFrame(): number;
  3937. /**
  3938. * Gets the easing function of the animation
  3939. * @returns Easing function of the animation
  3940. */
  3941. getEasingFunction(): IEasingFunction;
  3942. /**
  3943. * Sets the easing function of the animation
  3944. * @param easingFunction A custom mathematical formula for animation
  3945. */
  3946. setEasingFunction(easingFunction: EasingFunction): void;
  3947. /**
  3948. * Interpolates a scalar linearly
  3949. * @param startValue Start value of the animation curve
  3950. * @param endValue End value of the animation curve
  3951. * @param gradient Scalar amount to interpolate
  3952. * @returns Interpolated scalar value
  3953. */
  3954. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3955. /**
  3956. * Interpolates a scalar cubically
  3957. * @param startValue Start value of the animation curve
  3958. * @param outTangent End tangent of the animation
  3959. * @param endValue End value of the animation curve
  3960. * @param inTangent Start tangent of the animation curve
  3961. * @param gradient Scalar amount to interpolate
  3962. * @returns Interpolated scalar value
  3963. */
  3964. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3965. /**
  3966. * Interpolates a quaternion using a spherical linear interpolation
  3967. * @param startValue Start value of the animation curve
  3968. * @param endValue End value of the animation curve
  3969. * @param gradient Scalar amount to interpolate
  3970. * @returns Interpolated quaternion value
  3971. */
  3972. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3973. /**
  3974. * Interpolates a quaternion cubically
  3975. * @param startValue Start value of the animation curve
  3976. * @param outTangent End tangent of the animation curve
  3977. * @param endValue End value of the animation curve
  3978. * @param inTangent Start tangent of the animation curve
  3979. * @param gradient Scalar amount to interpolate
  3980. * @returns Interpolated quaternion value
  3981. */
  3982. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3983. /**
  3984. * Interpolates a Vector3 linearl
  3985. * @param startValue Start value of the animation curve
  3986. * @param endValue End value of the animation curve
  3987. * @param gradient Scalar amount to interpolate
  3988. * @returns Interpolated scalar value
  3989. */
  3990. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3991. /**
  3992. * Interpolates a Vector3 cubically
  3993. * @param startValue Start value of the animation curve
  3994. * @param outTangent End tangent of the animation
  3995. * @param endValue End value of the animation curve
  3996. * @param inTangent Start tangent of the animation curve
  3997. * @param gradient Scalar amount to interpolate
  3998. * @returns InterpolatedVector3 value
  3999. */
  4000. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4001. /**
  4002. * Interpolates a Vector2 linearly
  4003. * @param startValue Start value of the animation curve
  4004. * @param endValue End value of the animation curve
  4005. * @param gradient Scalar amount to interpolate
  4006. * @returns Interpolated Vector2 value
  4007. */
  4008. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4009. /**
  4010. * Interpolates a Vector2 cubically
  4011. * @param startValue Start value of the animation curve
  4012. * @param outTangent End tangent of the animation
  4013. * @param endValue End value of the animation curve
  4014. * @param inTangent Start tangent of the animation curve
  4015. * @param gradient Scalar amount to interpolate
  4016. * @returns Interpolated Vector2 value
  4017. */
  4018. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4019. /**
  4020. * Interpolates a size linearly
  4021. * @param startValue Start value of the animation curve
  4022. * @param endValue End value of the animation curve
  4023. * @param gradient Scalar amount to interpolate
  4024. * @returns Interpolated Size value
  4025. */
  4026. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4027. /**
  4028. * Interpolates a Color3 linearly
  4029. * @param startValue Start value of the animation curve
  4030. * @param endValue End value of the animation curve
  4031. * @param gradient Scalar amount to interpolate
  4032. * @returns Interpolated Color3 value
  4033. */
  4034. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4035. /**
  4036. * @hidden Internal use only
  4037. */
  4038. _getKeyValue(value: any): any;
  4039. /**
  4040. * @hidden Internal use only
  4041. */
  4042. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4043. /**
  4044. * Defines the function to use to interpolate matrices
  4045. * @param startValue defines the start matrix
  4046. * @param endValue defines the end matrix
  4047. * @param gradient defines the gradient between both matrices
  4048. * @param result defines an optional target matrix where to store the interpolation
  4049. * @returns the interpolated matrix
  4050. */
  4051. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4052. /**
  4053. * Makes a copy of the animation
  4054. * @returns Cloned animation
  4055. */
  4056. clone(): Animation;
  4057. /**
  4058. * Sets the key frames of the animation
  4059. * @param values The animation key frames to set
  4060. */
  4061. setKeys(values: Array<IAnimationKey>): void;
  4062. /**
  4063. * Serializes the animation to an object
  4064. * @returns Serialized object
  4065. */
  4066. serialize(): any;
  4067. /**
  4068. * Float animation type
  4069. */
  4070. private static _ANIMATIONTYPE_FLOAT;
  4071. /**
  4072. * Vector3 animation type
  4073. */
  4074. private static _ANIMATIONTYPE_VECTOR3;
  4075. /**
  4076. * Quaternion animation type
  4077. */
  4078. private static _ANIMATIONTYPE_QUATERNION;
  4079. /**
  4080. * Matrix animation type
  4081. */
  4082. private static _ANIMATIONTYPE_MATRIX;
  4083. /**
  4084. * Color3 animation type
  4085. */
  4086. private static _ANIMATIONTYPE_COLOR3;
  4087. /**
  4088. * Vector2 animation type
  4089. */
  4090. private static _ANIMATIONTYPE_VECTOR2;
  4091. /**
  4092. * Size animation type
  4093. */
  4094. private static _ANIMATIONTYPE_SIZE;
  4095. /**
  4096. * Relative Loop Mode
  4097. */
  4098. private static _ANIMATIONLOOPMODE_RELATIVE;
  4099. /**
  4100. * Cycle Loop Mode
  4101. */
  4102. private static _ANIMATIONLOOPMODE_CYCLE;
  4103. /**
  4104. * Constant Loop Mode
  4105. */
  4106. private static _ANIMATIONLOOPMODE_CONSTANT;
  4107. /**
  4108. * Get the float animation type
  4109. */
  4110. static readonly ANIMATIONTYPE_FLOAT: number;
  4111. /**
  4112. * Get the Vector3 animation type
  4113. */
  4114. static readonly ANIMATIONTYPE_VECTOR3: number;
  4115. /**
  4116. * Get the Vector2 animation type
  4117. */
  4118. static readonly ANIMATIONTYPE_VECTOR2: number;
  4119. /**
  4120. * Get the Size animation type
  4121. */
  4122. static readonly ANIMATIONTYPE_SIZE: number;
  4123. /**
  4124. * Get the Quaternion animation type
  4125. */
  4126. static readonly ANIMATIONTYPE_QUATERNION: number;
  4127. /**
  4128. * Get the Matrix animation type
  4129. */
  4130. static readonly ANIMATIONTYPE_MATRIX: number;
  4131. /**
  4132. * Get the Color3 animation type
  4133. */
  4134. static readonly ANIMATIONTYPE_COLOR3: number;
  4135. /**
  4136. * Get the Relative Loop Mode
  4137. */
  4138. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4139. /**
  4140. * Get the Cycle Loop Mode
  4141. */
  4142. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4143. /**
  4144. * Get the Constant Loop Mode
  4145. */
  4146. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4147. /** @hidden */
  4148. static _UniversalLerp(left: any, right: any, amount: number): any;
  4149. /**
  4150. * Parses an animation object and creates an animation
  4151. * @param parsedAnimation Parsed animation object
  4152. * @returns Animation object
  4153. */
  4154. static Parse(parsedAnimation: any): Animation;
  4155. /**
  4156. * Appends the serialized animations from the source animations
  4157. * @param source Source containing the animations
  4158. * @param destination Target to store the animations
  4159. */
  4160. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4161. }
  4162. }
  4163. declare module BABYLON {
  4164. /**
  4165. * This class defines the direct association between an animation and a target
  4166. */
  4167. class TargetedAnimation {
  4168. animation: Animation;
  4169. target: any;
  4170. }
  4171. /**
  4172. * Use this class to create coordinated animations on multiple targets
  4173. */
  4174. class AnimationGroup implements IDisposable {
  4175. name: string;
  4176. private _scene;
  4177. private _targetedAnimations;
  4178. private _animatables;
  4179. private _from;
  4180. private _to;
  4181. private _isStarted;
  4182. private _speedRatio;
  4183. onAnimationEndObservable: Observable<TargetedAnimation>;
  4184. /**
  4185. * This observable will notify when all animations have ended.
  4186. */
  4187. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4188. /**
  4189. * This observable will notify when all animations have paused.
  4190. */
  4191. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4192. /**
  4193. * Gets the first frame
  4194. */
  4195. readonly from: number;
  4196. /**
  4197. * Gets the last frame
  4198. */
  4199. readonly to: number;
  4200. /**
  4201. * Define if the animations are started
  4202. */
  4203. readonly isStarted: boolean;
  4204. /**
  4205. * Gets or sets the speed ratio to use for all animations
  4206. */
  4207. /**
  4208. * Gets or sets the speed ratio to use for all animations
  4209. */
  4210. speedRatio: number;
  4211. /**
  4212. * Gets the targeted animations for this animation group
  4213. */
  4214. readonly targetedAnimations: Array<TargetedAnimation>;
  4215. /**
  4216. * returning the list of animatables controlled by this animation group.
  4217. */
  4218. readonly animatables: Array<Animatable>;
  4219. constructor(name: string, scene?: Nullable<Scene>);
  4220. /**
  4221. * Add an animation (with its target) in the group
  4222. * @param animation defines the animation we want to add
  4223. * @param target defines the target of the animation
  4224. * @returns the {BABYLON.TargetedAnimation} object
  4225. */
  4226. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4227. /**
  4228. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4229. * It can add constant keys at begin or end
  4230. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4231. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4232. */
  4233. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4234. /**
  4235. * Start all animations on given targets
  4236. * @param loop defines if animations must loop
  4237. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4238. * @param from defines the from key (optional)
  4239. * @param to defines the to key (optional)
  4240. * @returns the current animation group
  4241. */
  4242. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4243. /**
  4244. * Pause all animations
  4245. */
  4246. pause(): AnimationGroup;
  4247. /**
  4248. * Play all animations to initial state
  4249. * This function will start() the animations if they were not started or will restart() them if they were paused
  4250. * @param loop defines if animations must loop
  4251. */
  4252. play(loop?: boolean): AnimationGroup;
  4253. /**
  4254. * Reset all animations to initial state
  4255. */
  4256. reset(): AnimationGroup;
  4257. /**
  4258. * Restart animations from key 0
  4259. */
  4260. restart(): AnimationGroup;
  4261. /**
  4262. * Stop all animations
  4263. */
  4264. stop(): AnimationGroup;
  4265. /**
  4266. * Set animation weight for all animatables
  4267. * @param weight defines the weight to use
  4268. * @return the animationGroup
  4269. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4270. */
  4271. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4272. /**
  4273. * Synchronize and normalize all animatables with a source animatable
  4274. * @param root defines the root animatable to synchronize with
  4275. * @return the animationGroup
  4276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4277. */
  4278. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4279. /**
  4280. * Goes to a specific frame in this animation group
  4281. * @param frame the frame number to go to
  4282. * @return the animationGroup
  4283. */
  4284. goToFrame(frame: number): AnimationGroup;
  4285. /**
  4286. * Dispose all associated resources
  4287. */
  4288. dispose(): void;
  4289. private _checkAnimationGroupEnded;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /**
  4294. * Class used to override all child animations of a given target
  4295. */
  4296. class AnimationPropertiesOverride {
  4297. /**
  4298. * Gets or sets a value indicating if animation blending must be used
  4299. */
  4300. enableBlending: boolean;
  4301. /**
  4302. * Gets or sets the blending speed to use when enableBlending is true
  4303. */
  4304. blendingSpeed: number;
  4305. /**
  4306. * Gets or sets the default loop mode to use
  4307. */
  4308. loopMode: number;
  4309. }
  4310. }
  4311. declare module BABYLON {
  4312. interface IEasingFunction {
  4313. ease(gradient: number): number;
  4314. }
  4315. class EasingFunction implements IEasingFunction {
  4316. private static _EASINGMODE_EASEIN;
  4317. private static _EASINGMODE_EASEOUT;
  4318. private static _EASINGMODE_EASEINOUT;
  4319. static readonly EASINGMODE_EASEIN: number;
  4320. static readonly EASINGMODE_EASEOUT: number;
  4321. static readonly EASINGMODE_EASEINOUT: number;
  4322. private _easingMode;
  4323. setEasingMode(easingMode: number): void;
  4324. getEasingMode(): number;
  4325. easeInCore(gradient: number): number;
  4326. ease(gradient: number): number;
  4327. }
  4328. class CircleEase extends EasingFunction implements IEasingFunction {
  4329. easeInCore(gradient: number): number;
  4330. }
  4331. class BackEase extends EasingFunction implements IEasingFunction {
  4332. amplitude: number;
  4333. constructor(amplitude?: number);
  4334. easeInCore(gradient: number): number;
  4335. }
  4336. class BounceEase extends EasingFunction implements IEasingFunction {
  4337. bounces: number;
  4338. bounciness: number;
  4339. constructor(bounces?: number, bounciness?: number);
  4340. easeInCore(gradient: number): number;
  4341. }
  4342. class CubicEase extends EasingFunction implements IEasingFunction {
  4343. easeInCore(gradient: number): number;
  4344. }
  4345. class ElasticEase extends EasingFunction implements IEasingFunction {
  4346. oscillations: number;
  4347. springiness: number;
  4348. constructor(oscillations?: number, springiness?: number);
  4349. easeInCore(gradient: number): number;
  4350. }
  4351. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4352. exponent: number;
  4353. constructor(exponent?: number);
  4354. easeInCore(gradient: number): number;
  4355. }
  4356. class PowerEase extends EasingFunction implements IEasingFunction {
  4357. power: number;
  4358. constructor(power?: number);
  4359. easeInCore(gradient: number): number;
  4360. }
  4361. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4362. easeInCore(gradient: number): number;
  4363. }
  4364. class QuarticEase extends EasingFunction implements IEasingFunction {
  4365. easeInCore(gradient: number): number;
  4366. }
  4367. class QuinticEase extends EasingFunction implements IEasingFunction {
  4368. easeInCore(gradient: number): number;
  4369. }
  4370. class SineEase extends EasingFunction implements IEasingFunction {
  4371. easeInCore(gradient: number): number;
  4372. }
  4373. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4374. x1: number;
  4375. y1: number;
  4376. x2: number;
  4377. y2: number;
  4378. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4379. easeInCore(gradient: number): number;
  4380. }
  4381. }
  4382. declare module BABYLON {
  4383. /**
  4384. * Defines a runtime animation
  4385. */
  4386. class RuntimeAnimation {
  4387. private _events;
  4388. /**
  4389. * The current frame of the runtime animation
  4390. */
  4391. private _currentFrame;
  4392. /**
  4393. * The animation used by the runtime animation
  4394. */
  4395. private _animation;
  4396. /**
  4397. * The target of the runtime animation
  4398. */
  4399. private _target;
  4400. /**
  4401. * The initiating animatable
  4402. */
  4403. private _host;
  4404. /**
  4405. * The original value of the runtime animation
  4406. */
  4407. private _originalValue;
  4408. /**
  4409. * The original blend value of the runtime animation
  4410. */
  4411. private _originalBlendValue;
  4412. /**
  4413. * The offsets cache of the runtime animation
  4414. */
  4415. private _offsetsCache;
  4416. /**
  4417. * The high limits cache of the runtime animation
  4418. */
  4419. private _highLimitsCache;
  4420. /**
  4421. * Specifies if the runtime animation has been stopped
  4422. */
  4423. private _stopped;
  4424. /**
  4425. * The blending factor of the runtime animation
  4426. */
  4427. private _blendingFactor;
  4428. /**
  4429. * The BabylonJS scene
  4430. */
  4431. private _scene;
  4432. /**
  4433. * The current value of the runtime animation
  4434. */
  4435. private _currentValue;
  4436. /** @hidden */
  4437. _workValue: any;
  4438. /**
  4439. * The active target of the runtime animation
  4440. */
  4441. private _activeTarget;
  4442. /**
  4443. * The target path of the runtime animation
  4444. */
  4445. private _targetPath;
  4446. /**
  4447. * The weight of the runtime animation
  4448. */
  4449. private _weight;
  4450. /**
  4451. * The ratio offset of the runtime animation
  4452. */
  4453. private _ratioOffset;
  4454. /**
  4455. * The previous delay of the runtime animation
  4456. */
  4457. private _previousDelay;
  4458. /**
  4459. * The previous ratio of the runtime animation
  4460. */
  4461. private _previousRatio;
  4462. /**
  4463. * Gets the current frame of the runtime animation
  4464. */
  4465. readonly currentFrame: number;
  4466. /**
  4467. * Gets the weight of the runtime animation
  4468. */
  4469. readonly weight: number;
  4470. /**
  4471. * Gets the current value of the runtime animation
  4472. */
  4473. readonly currentValue: any;
  4474. /**
  4475. * Gets the target path of the runtime animation
  4476. */
  4477. readonly targetPath: string;
  4478. /**
  4479. * Gets the actual target of the runtime animation
  4480. */
  4481. readonly target: any;
  4482. /**
  4483. * Create a new RuntimeAnimation object
  4484. * @param target defines the target of the animation
  4485. * @param animation defines the source animation object
  4486. * @param scene defines the hosting scene
  4487. * @param host defines the initiating Animatable
  4488. */
  4489. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4490. /**
  4491. * Gets the animation from the runtime animation
  4492. */
  4493. readonly animation: Animation;
  4494. /**
  4495. * Resets the runtime animation to the beginning
  4496. * @param restoreOriginal defines whether to restore the target property to the original value
  4497. */
  4498. reset(restoreOriginal?: boolean): void;
  4499. /**
  4500. * Specifies if the runtime animation is stopped
  4501. * @returns Boolean specifying if the runtime animation is stopped
  4502. */
  4503. isStopped(): boolean;
  4504. /**
  4505. * Disposes of the runtime animation
  4506. */
  4507. dispose(): void;
  4508. /**
  4509. * Interpolates the animation from the current frame
  4510. * @param currentFrame The frame to interpolate the animation to
  4511. * @param repeatCount The number of times that the animation should loop
  4512. * @param loopMode The type of looping mode to use
  4513. * @param offsetValue Animation offset value
  4514. * @param highLimitValue The high limit value
  4515. * @returns The interpolated value
  4516. */
  4517. private _interpolate;
  4518. /**
  4519. * Apply the interpolated value to the target
  4520. * @param currentValue defines the value computed by the animation
  4521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4522. */
  4523. setValue(currentValue: any, weight?: number): void;
  4524. private _setValue;
  4525. /**
  4526. * Gets the loop pmode of the runtime animation
  4527. * @returns Loop Mode
  4528. */
  4529. private _getCorrectLoopMode;
  4530. /**
  4531. * Move the current animation to a given frame
  4532. * @param frame defines the frame to move to
  4533. */
  4534. goToFrame(frame: number): void;
  4535. /**
  4536. * @hidden Internal use only
  4537. */
  4538. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4539. /**
  4540. * Execute the current animation
  4541. * @param delay defines the delay to add to the current frame
  4542. * @param from defines the lower bound of the animation range
  4543. * @param to defines the upper bound of the animation range
  4544. * @param loop defines if the current animation must loop
  4545. * @param speedRatio defines the current speed ratio
  4546. * @param weight defines the weight of the animation (default is -1 so no weight)
  4547. * @returns a boolean indicating if the animation is running
  4548. */
  4549. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4550. }
  4551. }
  4552. declare module BABYLON {
  4553. /**
  4554. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4556. */
  4557. class Analyser {
  4558. /**
  4559. * Gets or sets the smoothing
  4560. * @ignorenaming
  4561. */
  4562. SMOOTHING: number;
  4563. /**
  4564. * Gets or sets the FFT table size
  4565. * @ignorenaming
  4566. */
  4567. FFT_SIZE: number;
  4568. /**
  4569. * Gets or sets the bar graph amplitude
  4570. * @ignorenaming
  4571. */
  4572. BARGRAPHAMPLITUDE: number;
  4573. /**
  4574. * Gets or sets the position of the debug canvas
  4575. * @ignorenaming
  4576. */
  4577. DEBUGCANVASPOS: {
  4578. x: number;
  4579. y: number;
  4580. };
  4581. /**
  4582. * Gets or sets the debug canvas size
  4583. * @ignorenaming
  4584. */
  4585. DEBUGCANVASSIZE: {
  4586. width: number;
  4587. height: number;
  4588. };
  4589. private _byteFreqs;
  4590. private _byteTime;
  4591. private _floatFreqs;
  4592. private _webAudioAnalyser;
  4593. private _debugCanvas;
  4594. private _debugCanvasContext;
  4595. private _scene;
  4596. private _registerFunc;
  4597. private _audioEngine;
  4598. /**
  4599. * Creates a new analyser
  4600. * @param scene defines hosting scene
  4601. */
  4602. constructor(scene: Scene);
  4603. /**
  4604. * Get the number of data values you will have to play with for the visualization
  4605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4606. * @returns a number
  4607. */
  4608. getFrequencyBinCount(): number;
  4609. /**
  4610. * Gets the current frequency data as a byte array
  4611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4612. * @returns a Uint8Array
  4613. */
  4614. getByteFrequencyData(): Uint8Array;
  4615. /**
  4616. * Gets the current waveform as a byte array
  4617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4618. * @returns a Uint8Array
  4619. */
  4620. getByteTimeDomainData(): Uint8Array;
  4621. /**
  4622. * Gets the current frequency data as a float array
  4623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4624. * @returns a Float32Array
  4625. */
  4626. getFloatFrequencyData(): Float32Array;
  4627. /**
  4628. * Renders the debug canvas
  4629. */
  4630. drawDebugCanvas(): void;
  4631. /**
  4632. * Stops rendering the debug canvas and removes it
  4633. */
  4634. stopDebugCanvas(): void;
  4635. /**
  4636. * Connects two audio nodes
  4637. * @param inputAudioNode defines first node to connect
  4638. * @param outputAudioNode defines second node to connect
  4639. */
  4640. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4641. /**
  4642. * Releases all associated resources
  4643. */
  4644. dispose(): void;
  4645. }
  4646. }
  4647. declare module BABYLON {
  4648. class AudioEngine {
  4649. private _audioContext;
  4650. private _audioContextInitialized;
  4651. canUseWebAudio: boolean;
  4652. masterGain: GainNode;
  4653. private _connectedAnalyser;
  4654. WarnedWebAudioUnsupported: boolean;
  4655. unlocked: boolean;
  4656. onAudioUnlocked: () => any;
  4657. isMP3supported: boolean;
  4658. isOGGsupported: boolean;
  4659. readonly audioContext: Nullable<AudioContext>;
  4660. constructor();
  4661. private _unlockiOSaudio;
  4662. private _initializeAudioContext;
  4663. dispose(): void;
  4664. getGlobalVolume(): number;
  4665. setGlobalVolume(newVolume: number): void;
  4666. connectToAnalyser(analyser: Analyser): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. class Sound {
  4671. name: string;
  4672. autoplay: boolean;
  4673. loop: boolean;
  4674. useCustomAttenuation: boolean;
  4675. soundTrackId: number;
  4676. spatialSound: boolean;
  4677. refDistance: number;
  4678. rolloffFactor: number;
  4679. maxDistance: number;
  4680. distanceModel: string;
  4681. private _panningModel;
  4682. onended: () => any;
  4683. /**
  4684. * Observable event when the current playing sound finishes.
  4685. */
  4686. onEndedObservable: Observable<Sound>;
  4687. private _playbackRate;
  4688. private _streaming;
  4689. private _startTime;
  4690. private _startOffset;
  4691. private _position;
  4692. /** @hidden */
  4693. _positionInEmitterSpace: boolean;
  4694. private _localDirection;
  4695. private _volume;
  4696. private _isReadyToPlay;
  4697. isPlaying: boolean;
  4698. isPaused: boolean;
  4699. private _isDirectional;
  4700. private _readyToPlayCallback;
  4701. private _audioBuffer;
  4702. private _soundSource;
  4703. private _streamingSource;
  4704. private _soundPanner;
  4705. private _soundGain;
  4706. private _inputAudioNode;
  4707. private _outputAudioNode;
  4708. private _coneInnerAngle;
  4709. private _coneOuterAngle;
  4710. private _coneOuterGain;
  4711. private _scene;
  4712. private _connectedMesh;
  4713. private _customAttenuationFunction;
  4714. private _registerFunc;
  4715. private _isOutputConnected;
  4716. private _htmlAudioElement;
  4717. private _urlType;
  4718. /**
  4719. * Create a sound and attach it to a scene
  4720. * @param name Name of your sound
  4721. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4722. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4723. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4724. */
  4725. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4726. dispose(): void;
  4727. isReady(): boolean;
  4728. private _soundLoaded;
  4729. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4730. updateOptions(options: any): void;
  4731. private _createSpatialParameters;
  4732. private _updateSpatialParameters;
  4733. switchPanningModelToHRTF(): void;
  4734. switchPanningModelToEqualPower(): void;
  4735. private _switchPanningModel;
  4736. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4737. /**
  4738. * Transform this sound into a directional source
  4739. * @param coneInnerAngle Size of the inner cone in degree
  4740. * @param coneOuterAngle Size of the outer cone in degree
  4741. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4742. */
  4743. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4744. /**
  4745. * Gets or sets the inner angle for the directional cone.
  4746. */
  4747. /**
  4748. * Gets or sets the inner angle for the directional cone.
  4749. */
  4750. directionalConeInnerAngle: number;
  4751. /**
  4752. * Gets or sets the outer angle for the directional cone.
  4753. */
  4754. /**
  4755. * Gets or sets the outer angle for the directional cone.
  4756. */
  4757. directionalConeOuterAngle: number;
  4758. setPosition(newPosition: Vector3): void;
  4759. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4760. private _updateDirection;
  4761. updateDistanceFromListener(): void;
  4762. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4763. /**
  4764. * Play the sound
  4765. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4766. * @param offset (optional) Start the sound setting it at a specific time
  4767. */
  4768. play(time?: number, offset?: number): void;
  4769. private _onended;
  4770. /**
  4771. * Stop the sound
  4772. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4773. */
  4774. stop(time?: number): void;
  4775. pause(): void;
  4776. setVolume(newVolume: number, time?: number): void;
  4777. setPlaybackRate(newPlaybackRate: number): void;
  4778. getVolume(): number;
  4779. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4780. detachFromMesh(): void;
  4781. private _onRegisterAfterWorldMatrixUpdate;
  4782. clone(): Nullable<Sound>;
  4783. getAudioBuffer(): AudioBuffer | null;
  4784. serialize(): any;
  4785. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4786. }
  4787. }
  4788. declare module BABYLON {
  4789. class SoundTrack {
  4790. private _outputAudioNode;
  4791. private _scene;
  4792. id: number;
  4793. soundCollection: Array<Sound>;
  4794. private _isMainTrack;
  4795. private _connectedAnalyser;
  4796. private _options;
  4797. private _isInitialized;
  4798. constructor(scene: Scene, options?: any);
  4799. private _initializeSoundTrackAudioGraph;
  4800. dispose(): void;
  4801. AddSound(sound: Sound): void;
  4802. RemoveSound(sound: Sound): void;
  4803. setVolume(newVolume: number): void;
  4804. switchPanningModelToHRTF(): void;
  4805. switchPanningModelToEqualPower(): void;
  4806. connectToAnalyser(analyser: Analyser): void;
  4807. }
  4808. }
  4809. declare module BABYLON {
  4810. /**
  4811. * Wraps one or more Sound objects and selects one with random weight for playback.
  4812. */
  4813. class WeightedSound {
  4814. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4815. loop: boolean;
  4816. private _coneInnerAngle;
  4817. private _coneOuterAngle;
  4818. private _volume;
  4819. /** A Sound is currently playing. */
  4820. isPlaying: boolean;
  4821. /** A Sound is currently paused. */
  4822. isPaused: boolean;
  4823. private _sounds;
  4824. private _weights;
  4825. private _currentIndex?;
  4826. /**
  4827. * Creates a new WeightedSound from the list of sounds given.
  4828. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4829. * @param sounds Array of Sounds that will be selected from.
  4830. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4831. */
  4832. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4833. /**
  4834. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4835. */
  4836. /**
  4837. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4838. */
  4839. directionalConeInnerAngle: number;
  4840. /**
  4841. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4842. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4843. */
  4844. /**
  4845. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4846. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4847. */
  4848. directionalConeOuterAngle: number;
  4849. /**
  4850. * Playback volume.
  4851. */
  4852. /**
  4853. * Playback volume.
  4854. */
  4855. volume: number;
  4856. private _onended;
  4857. /**
  4858. * Suspend playback
  4859. */
  4860. pause(): void;
  4861. /**
  4862. * Stop playback
  4863. */
  4864. stop(): void;
  4865. /**
  4866. * Start playback.
  4867. * @param startOffset Position the clip head at a specific time in seconds.
  4868. */
  4869. play(startOffset?: number): void;
  4870. }
  4871. }
  4872. declare module BABYLON {
  4873. /**
  4874. * Interface used to define a behavior
  4875. */
  4876. interface Behavior<T> {
  4877. /** gets or sets behavior's name */
  4878. name: string;
  4879. /**
  4880. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4881. */
  4882. init(): void;
  4883. /**
  4884. * Called when the behavior is attached to a target
  4885. * @param target defines the target where the behavior is attached to
  4886. */
  4887. attach(target: T): void;
  4888. /**
  4889. * Called when the behavior is detached from its target
  4890. */
  4891. detach(): void;
  4892. }
  4893. /**
  4894. * Interface implemented by classes supporting behaviors
  4895. */
  4896. interface IBehaviorAware<T> {
  4897. /**
  4898. * Attach a behavior
  4899. * @param behavior defines the behavior to attach
  4900. * @returns the current host
  4901. */
  4902. addBehavior(behavior: Behavior<T>): T;
  4903. /**
  4904. * Remove a behavior from the current object
  4905. * @param behavior defines the behavior to detach
  4906. * @returns the current host
  4907. */
  4908. removeBehavior(behavior: Behavior<T>): T;
  4909. /**
  4910. * Gets a behavior using its name to search
  4911. * @param name defines the name to search
  4912. * @returns the behavior or null if not found
  4913. */
  4914. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4915. }
  4916. }
  4917. declare module BABYLON {
  4918. /**
  4919. * Class used to store bone information
  4920. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4921. */
  4922. class Bone extends Node {
  4923. /**
  4924. * defines the bone name
  4925. */
  4926. name: string;
  4927. private static _tmpVecs;
  4928. private static _tmpQuat;
  4929. private static _tmpMats;
  4930. /**
  4931. * Gets the list of child bones
  4932. */
  4933. children: Bone[];
  4934. /** Gets the animations associated with this bone */
  4935. animations: Animation[];
  4936. /**
  4937. * Gets or sets bone length
  4938. */
  4939. length: number;
  4940. /**
  4941. * @hidden Internal only
  4942. * Set this value to map this bone to a different index in the transform matrices
  4943. * Set this value to -1 to exclude the bone from the transform matrices
  4944. */
  4945. _index: Nullable<number>;
  4946. private _skeleton;
  4947. private _localMatrix;
  4948. private _restPose;
  4949. private _baseMatrix;
  4950. private _absoluteTransform;
  4951. private _invertedAbsoluteTransform;
  4952. private _parent;
  4953. private _scalingDeterminant;
  4954. private _worldTransform;
  4955. private _localScaling;
  4956. private _localRotation;
  4957. private _localPosition;
  4958. private _needToDecompose;
  4959. private _needToCompose;
  4960. /** @hidden */
  4961. /** @hidden */
  4962. _matrix: Matrix;
  4963. /**
  4964. * Create a new bone
  4965. * @param name defines the bone name
  4966. * @param skeleton defines the parent skeleton
  4967. * @param parentBone defines the parent (can be null if the bone is the root)
  4968. * @param localMatrix defines the local matrix
  4969. * @param restPose defines the rest pose matrix
  4970. * @param baseMatrix defines the base matrix
  4971. * @param index defines index of the bone in the hiearchy
  4972. */
  4973. constructor(
  4974. /**
  4975. * defines the bone name
  4976. */
  4977. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4978. /**
  4979. * Gets the parent skeleton
  4980. * @returns a skeleton
  4981. */
  4982. getSkeleton(): Skeleton;
  4983. /**
  4984. * Gets parent bone
  4985. * @returns a bone or null if the bone is the root of the bone hierarchy
  4986. */
  4987. getParent(): Nullable<Bone>;
  4988. /**
  4989. * Sets the parent bone
  4990. * @param parent defines the parent (can be null if the bone is the root)
  4991. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4992. */
  4993. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4994. /**
  4995. * Gets the local matrix
  4996. * @returns a matrix
  4997. */
  4998. getLocalMatrix(): Matrix;
  4999. /**
  5000. * Gets the base matrix (initial matrix which remains unchanged)
  5001. * @returns a matrix
  5002. */
  5003. getBaseMatrix(): Matrix;
  5004. /**
  5005. * Gets the rest pose matrix
  5006. * @returns a matrix
  5007. */
  5008. getRestPose(): Matrix;
  5009. /**
  5010. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5011. */
  5012. getWorldMatrix(): Matrix;
  5013. /**
  5014. * Sets the local matrix to rest pose matrix
  5015. */
  5016. returnToRest(): void;
  5017. /**
  5018. * Gets the inverse of the absolute transform matrix.
  5019. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5020. * @returns a matrix
  5021. */
  5022. getInvertedAbsoluteTransform(): Matrix;
  5023. /**
  5024. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5025. * @returns a matrix
  5026. */
  5027. getAbsoluteTransform(): Matrix;
  5028. /** Gets or sets current position (in local space) */
  5029. position: Vector3;
  5030. /** Gets or sets current rotation (in local space) */
  5031. rotation: Vector3;
  5032. /** Gets or sets current rotation quaternion (in local space) */
  5033. rotationQuaternion: Quaternion;
  5034. /** Gets or sets current scaling (in local space) */
  5035. scaling: Vector3;
  5036. /**
  5037. * Gets the animation properties override
  5038. */
  5039. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5040. private _decompose;
  5041. private _compose;
  5042. /**
  5043. * Update the base and local matrices
  5044. * @param matrix defines the new base or local matrix
  5045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5046. * @param updateLocalMatrix defines if the local matrix should be updated
  5047. */
  5048. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5049. /** @hidden */
  5050. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5051. /**
  5052. * Flag the bone as dirty (Forcing it to update everything)
  5053. */
  5054. markAsDirty(): void;
  5055. private _markAsDirtyAndCompose;
  5056. private _markAsDirtyAndDecompose;
  5057. /**
  5058. * Copy an animation range from another bone
  5059. * @param source defines the source bone
  5060. * @param rangeName defines the range name to copy
  5061. * @param frameOffset defines the frame offset
  5062. * @param rescaleAsRequired defines if rescaling must be applied if required
  5063. * @param skelDimensionsRatio defines the scaling ratio
  5064. * @returns true if operation was successful
  5065. */
  5066. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5067. /**
  5068. * Translate the bone in local or world space
  5069. * @param vec The amount to translate the bone
  5070. * @param space The space that the translation is in
  5071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5072. */
  5073. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5074. /**
  5075. * Set the postion of the bone in local or world space
  5076. * @param position The position to set the bone
  5077. * @param space The space that the position is in
  5078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5079. */
  5080. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5081. /**
  5082. * Set the absolute position of the bone (world space)
  5083. * @param position The position to set the bone
  5084. * @param mesh The mesh that this bone is attached to
  5085. */
  5086. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5087. /**
  5088. * Scale the bone on the x, y and z axes (in local space)
  5089. * @param x The amount to scale the bone on the x axis
  5090. * @param y The amount to scale the bone on the y axis
  5091. * @param z The amount to scale the bone on the z axis
  5092. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5093. */
  5094. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5095. /**
  5096. * Set the bone scaling in local space
  5097. * @param scale defines the scaling vector
  5098. */
  5099. setScale(scale: Vector3): void;
  5100. /**
  5101. * Gets the current scaling in local space
  5102. * @returns the current scaling vector
  5103. */
  5104. getScale(): Vector3;
  5105. /**
  5106. * Gets the current scaling in local space and stores it in a target vector
  5107. * @param result defines the target vector
  5108. */
  5109. getScaleToRef(result: Vector3): void;
  5110. /**
  5111. * Set the yaw, pitch, and roll of the bone in local or world space
  5112. * @param yaw The rotation of the bone on the y axis
  5113. * @param pitch The rotation of the bone on the x axis
  5114. * @param roll The rotation of the bone on the z axis
  5115. * @param space The space that the axes of rotation are in
  5116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5117. */
  5118. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5119. /**
  5120. * Add a rotation to the bone on an axis in local or world space
  5121. * @param axis The axis to rotate the bone on
  5122. * @param amount The amount to rotate the bone
  5123. * @param space The space that the axis is in
  5124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5125. */
  5126. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5127. /**
  5128. * Set the rotation of the bone to a particular axis angle in local or world space
  5129. * @param axis The axis to rotate the bone on
  5130. * @param angle The angle that the bone should be rotated to
  5131. * @param space The space that the axis is in
  5132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5133. */
  5134. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5135. /**
  5136. * Set the euler rotation of the bone in local of world space
  5137. * @param rotation The euler rotation that the bone should be set to
  5138. * @param space The space that the rotation is in
  5139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5140. */
  5141. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5142. /**
  5143. * Set the quaternion rotation of the bone in local of world space
  5144. * @param quat The quaternion rotation that the bone should be set to
  5145. * @param space The space that the rotation is in
  5146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5147. */
  5148. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5149. /**
  5150. * Set the rotation matrix of the bone in local of world space
  5151. * @param rotMat The rotation matrix that the bone should be set to
  5152. * @param space The space that the rotation is in
  5153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5154. */
  5155. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5156. private _rotateWithMatrix;
  5157. private _getNegativeRotationToRef;
  5158. /**
  5159. * Get the position of the bone in local or world space
  5160. * @param space The space that the returned position is in
  5161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5162. * @returns The position of the bone
  5163. */
  5164. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5165. /**
  5166. * Copy the position of the bone to a vector3 in local or world space
  5167. * @param space The space that the returned position is in
  5168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5169. * @param result The vector3 to copy the position to
  5170. */
  5171. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5172. /**
  5173. * Get the absolute position of the bone (world space)
  5174. * @param mesh The mesh that this bone is attached to
  5175. * @returns The absolute position of the bone
  5176. */
  5177. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5178. /**
  5179. * Copy the absolute position of the bone (world space) to the result param
  5180. * @param mesh The mesh that this bone is attached to
  5181. * @param result The vector3 to copy the absolute position to
  5182. */
  5183. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5184. /**
  5185. * Compute the absolute transforms of this bone and its children
  5186. */
  5187. computeAbsoluteTransforms(): void;
  5188. /**
  5189. * Get the world direction from an axis that is in the local space of the bone
  5190. * @param localAxis The local direction that is used to compute the world direction
  5191. * @param mesh The mesh that this bone is attached to
  5192. * @returns The world direction
  5193. */
  5194. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5195. /**
  5196. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5197. * @param localAxis The local direction that is used to compute the world direction
  5198. * @param mesh The mesh that this bone is attached to
  5199. * @param result The vector3 that the world direction will be copied to
  5200. */
  5201. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5202. /**
  5203. * Get the euler rotation of the bone in local or world space
  5204. * @param space The space that the rotation should be in
  5205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5206. * @returns The euler rotation
  5207. */
  5208. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5209. /**
  5210. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5211. * @param space The space that the rotation should be in
  5212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5213. * @param result The vector3 that the rotation should be copied to
  5214. */
  5215. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5216. /**
  5217. * Get the quaternion rotation of the bone in either local or world space
  5218. * @param space The space that the rotation should be in
  5219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5220. * @returns The quaternion rotation
  5221. */
  5222. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5223. /**
  5224. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5225. * @param space The space that the rotation should be in
  5226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5227. * @param result The quaternion that the rotation should be copied to
  5228. */
  5229. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5230. /**
  5231. * Get the rotation matrix of the bone in local or world space
  5232. * @param space The space that the rotation should be in
  5233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5234. * @returns The rotation matrix
  5235. */
  5236. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5237. /**
  5238. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5239. * @param space The space that the rotation should be in
  5240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5241. * @param result The quaternion that the rotation should be copied to
  5242. */
  5243. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5244. /**
  5245. * Get the world position of a point that is in the local space of the bone
  5246. * @param position The local position
  5247. * @param mesh The mesh that this bone is attached to
  5248. * @returns The world position
  5249. */
  5250. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5251. /**
  5252. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5253. * @param position The local position
  5254. * @param mesh The mesh that this bone is attached to
  5255. * @param result The vector3 that the world position should be copied to
  5256. */
  5257. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5258. /**
  5259. * Get the local position of a point that is in world space
  5260. * @param position The world position
  5261. * @param mesh The mesh that this bone is attached to
  5262. * @returns The local position
  5263. */
  5264. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5265. /**
  5266. * Get the local position of a point that is in world space and copy it to the result param
  5267. * @param position The world position
  5268. * @param mesh The mesh that this bone is attached to
  5269. * @param result The vector3 that the local position should be copied to
  5270. */
  5271. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5272. }
  5273. }
  5274. declare module BABYLON {
  5275. /**
  5276. * Class used to apply inverse kinematics to bones
  5277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5278. */
  5279. class BoneIKController {
  5280. private static _tmpVecs;
  5281. private static _tmpQuat;
  5282. private static _tmpMats;
  5283. /**
  5284. * Gets or sets the target mesh
  5285. */
  5286. targetMesh: AbstractMesh;
  5287. /** Gets or sets the mesh used as pole */
  5288. poleTargetMesh: AbstractMesh;
  5289. /**
  5290. * Gets or sets the bone used as pole
  5291. */
  5292. poleTargetBone: Nullable<Bone>;
  5293. /**
  5294. * Gets or sets the target position
  5295. */
  5296. targetPosition: Vector3;
  5297. /**
  5298. * Gets or sets the pole target position
  5299. */
  5300. poleTargetPosition: Vector3;
  5301. /**
  5302. * Gets or sets the pole target local offset
  5303. */
  5304. poleTargetLocalOffset: Vector3;
  5305. /**
  5306. * Gets or sets the pole angle
  5307. */
  5308. poleAngle: number;
  5309. /**
  5310. * Gets or sets the mesh associated with the controller
  5311. */
  5312. mesh: AbstractMesh;
  5313. /**
  5314. * 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)
  5315. */
  5316. slerpAmount: number;
  5317. private _bone1Quat;
  5318. private _bone1Mat;
  5319. private _bone2Ang;
  5320. private _bone1;
  5321. private _bone2;
  5322. private _bone1Length;
  5323. private _bone2Length;
  5324. private _maxAngle;
  5325. private _maxReach;
  5326. private _rightHandedSystem;
  5327. private _bendAxis;
  5328. private _slerping;
  5329. private _adjustRoll;
  5330. /**
  5331. * Gets or sets maximum allowed angle
  5332. */
  5333. maxAngle: number;
  5334. /**
  5335. * Creates a new BoneIKController
  5336. * @param mesh defines the mesh to control
  5337. * @param bone defines the bone to control
  5338. * @param options defines options to set up the controller
  5339. */
  5340. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5341. targetMesh?: AbstractMesh;
  5342. poleTargetMesh?: AbstractMesh;
  5343. poleTargetBone?: Bone;
  5344. poleTargetLocalOffset?: Vector3;
  5345. poleAngle?: number;
  5346. bendAxis?: Vector3;
  5347. maxAngle?: number;
  5348. slerpAmount?: number;
  5349. });
  5350. private _setMaxAngle;
  5351. /**
  5352. * Force the controller to update the bones
  5353. */
  5354. update(): void;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /**
  5359. * Class used to make a bone look toward a point in space
  5360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5361. */
  5362. class BoneLookController {
  5363. private static _tmpVecs;
  5364. private static _tmpQuat;
  5365. private static _tmpMats;
  5366. /**
  5367. * The target Vector3 that the bone will look at
  5368. */
  5369. target: Vector3;
  5370. /**
  5371. * The mesh that the bone is attached to
  5372. */
  5373. mesh: AbstractMesh;
  5374. /**
  5375. * The bone that will be looking to the target
  5376. */
  5377. bone: Bone;
  5378. /**
  5379. * The up axis of the coordinate system that is used when the bone is rotated
  5380. */
  5381. upAxis: Vector3;
  5382. /**
  5383. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5384. */
  5385. upAxisSpace: Space;
  5386. /**
  5387. * Used to make an adjustment to the yaw of the bone
  5388. */
  5389. adjustYaw: number;
  5390. /**
  5391. * Used to make an adjustment to the pitch of the bone
  5392. */
  5393. adjustPitch: number;
  5394. /**
  5395. * Used to make an adjustment to the roll of the bone
  5396. */
  5397. adjustRoll: number;
  5398. /**
  5399. * 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)
  5400. */
  5401. slerpAmount: number;
  5402. private _minYaw;
  5403. private _maxYaw;
  5404. private _minPitch;
  5405. private _maxPitch;
  5406. private _minYawSin;
  5407. private _minYawCos;
  5408. private _maxYawSin;
  5409. private _maxYawCos;
  5410. private _midYawConstraint;
  5411. private _minPitchTan;
  5412. private _maxPitchTan;
  5413. private _boneQuat;
  5414. private _slerping;
  5415. private _transformYawPitch;
  5416. private _transformYawPitchInv;
  5417. private _firstFrameSkipped;
  5418. private _yawRange;
  5419. private _fowardAxis;
  5420. /**
  5421. * Gets or sets the minimum yaw angle that the bone can look to
  5422. */
  5423. minYaw: number;
  5424. /**
  5425. * Gets or sets the maximum yaw angle that the bone can look to
  5426. */
  5427. maxYaw: number;
  5428. /**
  5429. * Gets or sets the minimum pitch angle that the bone can look to
  5430. */
  5431. minPitch: number;
  5432. /**
  5433. * Gets or sets the maximum pitch angle that the bone can look to
  5434. */
  5435. maxPitch: number;
  5436. /**
  5437. * Create a BoneLookController
  5438. * @param mesh the mesh that the bone belongs to
  5439. * @param bone the bone that will be looking to the target
  5440. * @param target the target Vector3 to look at
  5441. * @param settings optional settings:
  5442. * * maxYaw: the maximum angle the bone will yaw to
  5443. * * minYaw: the minimum angle the bone will yaw to
  5444. * * maxPitch: the maximum angle the bone will pitch to
  5445. * * minPitch: the minimum angle the bone will yaw to
  5446. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5447. * * upAxis: the up axis of the coordinate system
  5448. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5449. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5450. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5451. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5452. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5453. * * adjustRoll: used to make an adjustment to the roll of the bone
  5454. **/
  5455. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5456. maxYaw?: number;
  5457. minYaw?: number;
  5458. maxPitch?: number;
  5459. minPitch?: number;
  5460. slerpAmount?: number;
  5461. upAxis?: Vector3;
  5462. upAxisSpace?: Space;
  5463. yawAxis?: Vector3;
  5464. pitchAxis?: Vector3;
  5465. adjustYaw?: number;
  5466. adjustPitch?: number;
  5467. adjustRoll?: number;
  5468. });
  5469. /**
  5470. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5471. */
  5472. update(): void;
  5473. private _getAngleDiff;
  5474. private _getAngleBetween;
  5475. private _isAngleBetween;
  5476. }
  5477. }
  5478. declare module BABYLON {
  5479. /**
  5480. * Class used to handle skinning animations
  5481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5482. */
  5483. class Skeleton implements IAnimatable {
  5484. /** defines the skeleton name */
  5485. name: string;
  5486. /** defines the skeleton Id */
  5487. id: string;
  5488. /**
  5489. * Gets the list of child bones
  5490. */
  5491. bones: Bone[];
  5492. /**
  5493. * Gets an estimate of the dimension of the skeleton at rest
  5494. */
  5495. dimensionsAtRest: Vector3;
  5496. /**
  5497. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5498. */
  5499. needInitialSkinMatrix: boolean;
  5500. /**
  5501. * Gets the list of animations attached to this skeleton
  5502. */
  5503. animations: Array<Animation>;
  5504. private _scene;
  5505. private _isDirty;
  5506. private _transformMatrices;
  5507. private _meshesWithPoseMatrix;
  5508. private _animatables;
  5509. private _identity;
  5510. private _synchronizedWithMesh;
  5511. private _ranges;
  5512. private _lastAbsoluteTransformsUpdateId;
  5513. /**
  5514. * Specifies if the skeleton should be serialized
  5515. */
  5516. doNotSerialize: boolean;
  5517. private _animationPropertiesOverride;
  5518. /**
  5519. * Gets or sets the animation properties override
  5520. */
  5521. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5522. /**
  5523. * An observable triggered before computing the skeleton's matrices
  5524. */
  5525. onBeforeComputeObservable: Observable<Skeleton>;
  5526. /**
  5527. * Creates a new skeleton
  5528. * @param name defines the skeleton name
  5529. * @param id defines the skeleton Id
  5530. * @param scene defines the hosting scene
  5531. */
  5532. constructor(
  5533. /** defines the skeleton name */
  5534. name: string,
  5535. /** defines the skeleton Id */
  5536. id: string, scene: Scene);
  5537. /**
  5538. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5539. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5540. * @returns a Float32Array containing matrices data
  5541. */
  5542. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5543. /**
  5544. * Gets the current hosting scene
  5545. * @returns a scene object
  5546. */
  5547. getScene(): Scene;
  5548. /**
  5549. * Gets a string representing the current skeleton data
  5550. * @param fullDetails defines a boolean indicating if we want a verbose version
  5551. * @returns a string representing the current skeleton data
  5552. */
  5553. toString(fullDetails?: boolean): string;
  5554. /**
  5555. * Get bone's index searching by name
  5556. * @param name defines bone's name to search for
  5557. * @return the indice of the bone. Returns -1 if not found
  5558. */
  5559. getBoneIndexByName(name: string): number;
  5560. /**
  5561. * Creater a new animation range
  5562. * @param name defines the name of the range
  5563. * @param from defines the start key
  5564. * @param to defines the end key
  5565. */
  5566. createAnimationRange(name: string, from: number, to: number): void;
  5567. /**
  5568. * Delete a specific animation range
  5569. * @param name defines the name of the range
  5570. * @param deleteFrames defines if frames must be removed as well
  5571. */
  5572. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5573. /**
  5574. * Gets a specific animation range
  5575. * @param name defines the name of the range to look for
  5576. * @returns the requested animation range or null if not found
  5577. */
  5578. getAnimationRange(name: string): Nullable<AnimationRange>;
  5579. /**
  5580. * Gets the list of all animation ranges defined on this skeleton
  5581. * @returns an array
  5582. */
  5583. getAnimationRanges(): Nullable<AnimationRange>[];
  5584. /**
  5585. * Copy animation range from a source skeleton.
  5586. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5587. * @param source defines the source skeleton
  5588. * @param name defines the name of the range to copy
  5589. * @param rescaleAsRequired defines if rescaling must be applied if required
  5590. * @returns true if operation was successful
  5591. */
  5592. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5593. /**
  5594. * Forces the skeleton to go to rest pose
  5595. */
  5596. returnToRest(): void;
  5597. private _getHighestAnimationFrame;
  5598. /**
  5599. * Begin a specific animation range
  5600. * @param name defines the name of the range to start
  5601. * @param loop defines if looping must be turned on (false by default)
  5602. * @param speedRatio defines the speed ratio to apply (1 by default)
  5603. * @param onAnimationEnd defines a callback which will be called when animation will end
  5604. * @returns a new animatable
  5605. */
  5606. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5607. /** @hidden */
  5608. _markAsDirty(): void;
  5609. /** @hidden */
  5610. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5611. /** @hidden */
  5612. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5613. /** @hidden */
  5614. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5615. /**
  5616. * Build all resources required to render a skeleton
  5617. */
  5618. prepare(): void;
  5619. /**
  5620. * Gets the list of animatables currently running for this skeleton
  5621. * @returns an array of animatables
  5622. */
  5623. getAnimatables(): IAnimatable[];
  5624. /**
  5625. * Clone the current skeleton
  5626. * @param name defines the name of the new skeleton
  5627. * @param id defines the id of the enw skeleton
  5628. * @returns the new skeleton
  5629. */
  5630. clone(name: string, id: string): Skeleton;
  5631. /**
  5632. * Enable animation blending for this skeleton
  5633. * @param blendingSpeed defines the blending speed to apply
  5634. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5635. */
  5636. enableBlending(blendingSpeed?: number): void;
  5637. /**
  5638. * Releases all resources associated with the current skeleton
  5639. */
  5640. dispose(): void;
  5641. /**
  5642. * Serialize the skeleton in a JSON object
  5643. * @returns a JSON object
  5644. */
  5645. serialize(): any;
  5646. /**
  5647. * Creates a new skeleton from serialized data
  5648. * @param parsedSkeleton defines the serialized data
  5649. * @param scene defines the hosting scene
  5650. * @returns a new skeleton
  5651. */
  5652. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5653. /**
  5654. * Compute all node absolute transforms
  5655. * @param forceUpdate defines if computation must be done even if cache is up to date
  5656. */
  5657. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5658. /**
  5659. * Gets the root pose matrix
  5660. * @returns a matrix
  5661. */
  5662. getPoseMatrix(): Nullable<Matrix>;
  5663. /**
  5664. * Sorts bones per internal index
  5665. */
  5666. sortBones(): void;
  5667. private _sortBones;
  5668. }
  5669. }
  5670. declare module BABYLON {
  5671. class ArcRotateCamera extends TargetCamera {
  5672. alpha: number;
  5673. beta: number;
  5674. radius: number;
  5675. protected _target: Vector3;
  5676. protected _targetHost: Nullable<AbstractMesh>;
  5677. target: Vector3;
  5678. inertialAlphaOffset: number;
  5679. inertialBetaOffset: number;
  5680. inertialRadiusOffset: number;
  5681. lowerAlphaLimit: Nullable<number>;
  5682. upperAlphaLimit: Nullable<number>;
  5683. lowerBetaLimit: number;
  5684. upperBetaLimit: number;
  5685. lowerRadiusLimit: Nullable<number>;
  5686. upperRadiusLimit: Nullable<number>;
  5687. inertialPanningX: number;
  5688. inertialPanningY: number;
  5689. pinchToPanMaxDistance: number;
  5690. panningDistanceLimit: Nullable<number>;
  5691. panningOriginTarget: Vector3;
  5692. panningInertia: number;
  5693. angularSensibilityX: number;
  5694. angularSensibilityY: number;
  5695. pinchPrecision: number;
  5696. pinchDeltaPercentage: number;
  5697. panningSensibility: number;
  5698. keysUp: number[];
  5699. keysDown: number[];
  5700. keysLeft: number[];
  5701. keysRight: number[];
  5702. wheelPrecision: number;
  5703. wheelDeltaPercentage: number;
  5704. zoomOnFactor: number;
  5705. targetScreenOffset: Vector2;
  5706. allowUpsideDown: boolean;
  5707. /** @hidden */
  5708. _viewMatrix: Matrix;
  5709. /** @hidden */
  5710. _useCtrlForPanning: boolean;
  5711. /** @hidden */
  5712. _panningMouseButton: number;
  5713. inputs: ArcRotateCameraInputsManager;
  5714. /** @hidden */
  5715. _reset: () => void;
  5716. panningAxis: Vector3;
  5717. protected _localDirection: Vector3;
  5718. protected _transformedDirection: Vector3;
  5719. private _bouncingBehavior;
  5720. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5721. useBouncingBehavior: boolean;
  5722. private _framingBehavior;
  5723. readonly framingBehavior: Nullable<FramingBehavior>;
  5724. useFramingBehavior: boolean;
  5725. private _autoRotationBehavior;
  5726. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5727. useAutoRotationBehavior: boolean;
  5728. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5729. onCollide: (collidedMesh: AbstractMesh) => void;
  5730. checkCollisions: boolean;
  5731. collisionRadius: Vector3;
  5732. protected _collider: Collider;
  5733. protected _previousPosition: Vector3;
  5734. protected _collisionVelocity: Vector3;
  5735. protected _newPosition: Vector3;
  5736. protected _previousAlpha: number;
  5737. protected _previousBeta: number;
  5738. protected _previousRadius: number;
  5739. protected _collisionTriggered: boolean;
  5740. protected _targetBoundingCenter: Nullable<Vector3>;
  5741. private _computationVector;
  5742. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5743. /** @hidden */
  5744. _initCache(): void;
  5745. /** @hidden */
  5746. _updateCache(ignoreParentClass?: boolean): void;
  5747. protected _getTargetPosition(): Vector3;
  5748. /**
  5749. * Store current camera state (fov, position, etc..)
  5750. */
  5751. private _storedAlpha;
  5752. private _storedBeta;
  5753. private _storedRadius;
  5754. private _storedTarget;
  5755. storeState(): Camera;
  5756. /**
  5757. * @hidden
  5758. * Restored camera state. You must call storeState() first
  5759. */
  5760. _restoreStateValues(): boolean;
  5761. /** @hidden */
  5762. _isSynchronizedViewMatrix(): boolean;
  5763. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5764. detachControl(element: HTMLElement): void;
  5765. /** @hidden */
  5766. _checkInputs(): void;
  5767. protected _checkLimits(): void;
  5768. rebuildAnglesAndRadius(): void;
  5769. setPosition(position: Vector3): void;
  5770. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5771. /** @hidden */
  5772. _getViewMatrix(): Matrix;
  5773. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5774. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5775. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5776. min: Vector3;
  5777. max: Vector3;
  5778. distance: number;
  5779. }, doNotUpdateMaxZ?: boolean): void;
  5780. /**
  5781. * @override
  5782. * Override Camera.createRigCamera
  5783. */
  5784. createRigCamera(name: string, cameraIndex: number): Camera;
  5785. /**
  5786. * @hidden
  5787. * @override
  5788. * Override Camera._updateRigCameras
  5789. */
  5790. _updateRigCameras(): void;
  5791. dispose(): void;
  5792. getClassName(): string;
  5793. }
  5794. }
  5795. declare module BABYLON {
  5796. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5797. constructor(camera: ArcRotateCamera);
  5798. addMouseWheel(): ArcRotateCameraInputsManager;
  5799. addPointers(): ArcRotateCameraInputsManager;
  5800. addKeyboard(): ArcRotateCameraInputsManager;
  5801. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5802. }
  5803. }
  5804. declare module BABYLON {
  5805. class Camera extends Node {
  5806. inputs: CameraInputsManager<Camera>;
  5807. private static _PERSPECTIVE_CAMERA;
  5808. private static _ORTHOGRAPHIC_CAMERA;
  5809. private static _FOVMODE_VERTICAL_FIXED;
  5810. private static _FOVMODE_HORIZONTAL_FIXED;
  5811. private static _RIG_MODE_NONE;
  5812. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5813. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5814. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5815. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5816. private static _RIG_MODE_VR;
  5817. private static _RIG_MODE_WEBVR;
  5818. static readonly PERSPECTIVE_CAMERA: number;
  5819. static readonly ORTHOGRAPHIC_CAMERA: number;
  5820. /**
  5821. * This is the default FOV mode for perspective cameras.
  5822. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5823. *
  5824. */
  5825. static readonly FOVMODE_VERTICAL_FIXED: number;
  5826. /**
  5827. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5828. *
  5829. */
  5830. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5831. static readonly RIG_MODE_NONE: number;
  5832. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5833. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5834. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5835. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5836. static readonly RIG_MODE_VR: number;
  5837. static readonly RIG_MODE_WEBVR: number;
  5838. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5839. static UseAlternateWebVRRendering: boolean;
  5840. position: Vector3;
  5841. /**
  5842. * The vector the camera should consider as up.
  5843. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5844. */
  5845. upVector: Vector3;
  5846. orthoLeft: Nullable<number>;
  5847. orthoRight: Nullable<number>;
  5848. orthoBottom: Nullable<number>;
  5849. orthoTop: Nullable<number>;
  5850. /**
  5851. * FOV is set in Radians. (default is 0.8)
  5852. */
  5853. fov: number;
  5854. minZ: number;
  5855. maxZ: number;
  5856. inertia: number;
  5857. mode: number;
  5858. isIntermediate: boolean;
  5859. viewport: Viewport;
  5860. /**
  5861. * Restricts the camera to viewing objects with the same layerMask.
  5862. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5863. */
  5864. layerMask: number;
  5865. /**
  5866. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5867. */
  5868. fovMode: number;
  5869. cameraRigMode: number;
  5870. interaxialDistance: number;
  5871. isStereoscopicSideBySide: boolean;
  5872. /** @hidden */
  5873. _cameraRigParams: any;
  5874. /** @hidden */
  5875. _rigCameras: Camera[];
  5876. /** @hidden */
  5877. _rigPostProcess: Nullable<PostProcess>;
  5878. protected _webvrViewMatrix: Matrix;
  5879. /** @hidden */
  5880. _skipRendering: boolean;
  5881. /** @hidden */
  5882. _alternateCamera: Camera;
  5883. customRenderTargets: RenderTargetTexture[];
  5884. onViewMatrixChangedObservable: Observable<Camera>;
  5885. onProjectionMatrixChangedObservable: Observable<Camera>;
  5886. onAfterCheckInputsObservable: Observable<Camera>;
  5887. onRestoreStateObservable: Observable<Camera>;
  5888. private _computedViewMatrix;
  5889. _projectionMatrix: Matrix;
  5890. private _doNotComputeProjectionMatrix;
  5891. private _worldMatrix;
  5892. _postProcesses: Nullable<PostProcess>[];
  5893. private _transformMatrix;
  5894. _activeMeshes: SmartArray<AbstractMesh>;
  5895. protected _globalPosition: Vector3;
  5896. private _frustumPlanes;
  5897. private _refreshFrustumPlanes;
  5898. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5899. private _storedFov;
  5900. private _stateStored;
  5901. /**
  5902. * Store current camera state (fov, position, etc..)
  5903. */
  5904. storeState(): Camera;
  5905. /**
  5906. * Restores the camera state values if it has been stored. You must call storeState() first
  5907. */
  5908. protected _restoreStateValues(): boolean;
  5909. /**
  5910. * Restored camera state. You must call storeState() first
  5911. */
  5912. restoreState(): boolean;
  5913. getClassName(): string;
  5914. /**
  5915. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5916. */
  5917. toString(fullDetails?: boolean): string;
  5918. readonly globalPosition: Vector3;
  5919. getActiveMeshes(): SmartArray<AbstractMesh>;
  5920. isActiveMesh(mesh: Mesh): boolean;
  5921. /**
  5922. * Is this camera ready to be used/rendered
  5923. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5924. * @return true if the camera is ready
  5925. */
  5926. isReady(completeCheck?: boolean): boolean;
  5927. /** @hidden */
  5928. _initCache(): void;
  5929. /** @hidden */
  5930. _updateCache(ignoreParentClass?: boolean): void;
  5931. /** @hidden */
  5932. _isSynchronized(): boolean;
  5933. /** @hidden */
  5934. _isSynchronizedViewMatrix(): boolean;
  5935. /** @hidden */
  5936. _isSynchronizedProjectionMatrix(): boolean;
  5937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5938. detachControl(element: HTMLElement): void;
  5939. update(): void;
  5940. /** @hidden */
  5941. _checkInputs(): void;
  5942. readonly rigCameras: Camera[];
  5943. readonly rigPostProcess: Nullable<PostProcess>;
  5944. /**
  5945. * Internal, gets the first post proces.
  5946. * @returns the first post process to be run on this camera.
  5947. */
  5948. _getFirstPostProcess(): Nullable<PostProcess>;
  5949. private _cascadePostProcessesToRigCams;
  5950. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5951. detachPostProcess(postProcess: PostProcess): void;
  5952. getWorldMatrix(): Matrix;
  5953. /** @hidden */
  5954. _getViewMatrix(): Matrix;
  5955. getViewMatrix(force?: boolean): Matrix;
  5956. freezeProjectionMatrix(projection?: Matrix): void;
  5957. unfreezeProjectionMatrix(): void;
  5958. getProjectionMatrix(force?: boolean): Matrix;
  5959. /**
  5960. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5961. * @returns a Matrix
  5962. */
  5963. getTransformationMatrix(): Matrix;
  5964. private updateFrustumPlanes;
  5965. isInFrustum(target: ICullable): boolean;
  5966. isCompletelyInFrustum(target: ICullable): boolean;
  5967. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5968. /**
  5969. * Releases resources associated with this node.
  5970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5972. */
  5973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5974. readonly leftCamera: Nullable<FreeCamera>;
  5975. readonly rightCamera: Nullable<FreeCamera>;
  5976. getLeftTarget(): Nullable<Vector3>;
  5977. getRightTarget(): Nullable<Vector3>;
  5978. setCameraRigMode(mode: number, rigParams: any): void;
  5979. private _getVRProjectionMatrix;
  5980. protected _updateCameraRotationMatrix(): void;
  5981. protected _updateWebVRCameraRotationMatrix(): void;
  5982. /**
  5983. * This function MUST be overwritten by the different WebVR cameras available.
  5984. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5985. */
  5986. protected _getWebVRProjectionMatrix(): Matrix;
  5987. /**
  5988. * This function MUST be overwritten by the different WebVR cameras available.
  5989. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5990. */
  5991. protected _getWebVRViewMatrix(): Matrix;
  5992. setCameraRigParameter(name: string, value: any): void;
  5993. /**
  5994. * needs to be overridden by children so sub has required properties to be copied
  5995. */
  5996. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5997. /**
  5998. * May need to be overridden by children
  5999. * @hidden
  6000. */
  6001. _updateRigCameras(): void;
  6002. /** @hidden */
  6003. _setupInputs(): void;
  6004. serialize(): any;
  6005. clone(name: string): Camera;
  6006. getDirection(localAxis: Vector3): Vector3;
  6007. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6008. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6009. computeWorldMatrix(): Matrix;
  6010. static Parse(parsedCamera: any, scene: Scene): Camera;
  6011. }
  6012. }
  6013. declare module BABYLON {
  6014. var CameraInputTypes: {};
  6015. interface ICameraInput<TCamera extends Camera> {
  6016. camera: Nullable<TCamera>;
  6017. getClassName(): string;
  6018. getSimpleName(): string;
  6019. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6020. detachControl: (element: Nullable<HTMLElement>) => void;
  6021. checkInputs?: () => void;
  6022. }
  6023. interface CameraInputsMap<TCamera extends Camera> {
  6024. [name: string]: ICameraInput<TCamera>;
  6025. [idx: number]: ICameraInput<TCamera>;
  6026. }
  6027. class CameraInputsManager<TCamera extends Camera> {
  6028. attached: CameraInputsMap<TCamera>;
  6029. attachedElement: Nullable<HTMLElement>;
  6030. noPreventDefault: boolean;
  6031. camera: TCamera;
  6032. checkInputs: () => void;
  6033. constructor(camera: TCamera);
  6034. /**
  6035. * Add an input method to a camera
  6036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6037. * @param input camera input method
  6038. */
  6039. add(input: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input method from a camera
  6042. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6043. * @param inputToRemove camera input method
  6044. */
  6045. remove(inputToRemove: ICameraInput<TCamera>): void;
  6046. removeByType(inputType: string): void;
  6047. private _addCheckInputs;
  6048. attachInput(input: ICameraInput<TCamera>): void;
  6049. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6050. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6051. rebuildInputCheck(): void;
  6052. /**
  6053. * Remove all attached input methods from a camera
  6054. */
  6055. clear(): void;
  6056. serialize(serializedCamera: any): void;
  6057. parse(parsedCamera: any): void;
  6058. }
  6059. }
  6060. declare module BABYLON {
  6061. /**
  6062. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6063. * being tilted forward or back and left or right.
  6064. */
  6065. class DeviceOrientationCamera extends FreeCamera {
  6066. private _initialQuaternion;
  6067. private _quaternionCache;
  6068. /**
  6069. * Creates a new device orientation camera
  6070. * @param name The name of the camera
  6071. * @param position The start position camera
  6072. * @param scene The scene the camera belongs to
  6073. */
  6074. constructor(name: string, position: Vector3, scene: Scene);
  6075. /**
  6076. * Gets the current instance class name ("DeviceOrientationCamera").
  6077. * This helps avoiding instanceof at run time.
  6078. * @returns the class name
  6079. */
  6080. getClassName(): string;
  6081. /**
  6082. * @hidden
  6083. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6084. */
  6085. _checkInputs(): void;
  6086. /**
  6087. * Reset the camera to its default orientation on the specified axis only.
  6088. * @param axis The axis to reset
  6089. */
  6090. resetToCurrentRotation(axis?: Axis): void;
  6091. }
  6092. }
  6093. declare module BABYLON {
  6094. class FollowCamera extends TargetCamera {
  6095. radius: number;
  6096. rotationOffset: number;
  6097. heightOffset: number;
  6098. cameraAcceleration: number;
  6099. maxCameraSpeed: number;
  6100. lockedTarget: Nullable<AbstractMesh>;
  6101. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6102. private getRadians;
  6103. private follow;
  6104. /** @hidden */
  6105. _checkInputs(): void;
  6106. getClassName(): string;
  6107. }
  6108. class ArcFollowCamera extends TargetCamera {
  6109. alpha: number;
  6110. beta: number;
  6111. radius: number;
  6112. target: Nullable<AbstractMesh>;
  6113. private _cartesianCoordinates;
  6114. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6115. private follow;
  6116. /** @hidden */
  6117. _checkInputs(): void;
  6118. getClassName(): string;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. class FreeCamera extends TargetCamera {
  6123. ellipsoid: Vector3;
  6124. ellipsoidOffset: Vector3;
  6125. checkCollisions: boolean;
  6126. applyGravity: boolean;
  6127. inputs: FreeCameraInputsManager;
  6128. /**
  6129. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6130. * Higher values reduce sensitivity.
  6131. */
  6132. /**
  6133. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6134. * Higher values reduce sensitivity.
  6135. */
  6136. angularSensibility: number;
  6137. keysUp: number[];
  6138. keysDown: number[];
  6139. keysLeft: number[];
  6140. keysRight: number[];
  6141. onCollide: (collidedMesh: AbstractMesh) => void;
  6142. private _collider;
  6143. private _needMoveForGravity;
  6144. private _oldPosition;
  6145. private _diffPosition;
  6146. private _newPosition;
  6147. /** @hidden */
  6148. _localDirection: Vector3;
  6149. /** @hidden */
  6150. _transformedDirection: Vector3;
  6151. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6153. detachControl(element: HTMLElement): void;
  6154. private _collisionMask;
  6155. collisionMask: number;
  6156. /** @hidden */
  6157. _collideWithWorld(displacement: Vector3): void;
  6158. private _onCollisionPositionChange;
  6159. /** @hidden */
  6160. _checkInputs(): void;
  6161. /** @hidden */
  6162. _decideIfNeedsToMove(): boolean;
  6163. /** @hidden */
  6164. _updatePosition(): void;
  6165. dispose(): void;
  6166. getClassName(): string;
  6167. }
  6168. }
  6169. declare module BABYLON {
  6170. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6171. constructor(camera: FreeCamera);
  6172. addKeyboard(): FreeCameraInputsManager;
  6173. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6174. addDeviceOrientation(): FreeCameraInputsManager;
  6175. addTouch(): FreeCameraInputsManager;
  6176. addVirtualJoystick(): FreeCameraInputsManager;
  6177. }
  6178. }
  6179. declare module BABYLON {
  6180. class GamepadCamera extends UniversalCamera {
  6181. gamepadAngularSensibility: number;
  6182. gamepadMoveSensibility: number;
  6183. constructor(name: string, position: Vector3, scene: Scene);
  6184. getClassName(): string;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. class TargetCamera extends Camera {
  6189. cameraDirection: Vector3;
  6190. cameraRotation: Vector2;
  6191. rotation: Vector3;
  6192. rotationQuaternion: Quaternion;
  6193. speed: number;
  6194. noRotationConstraint: boolean;
  6195. lockedTarget: any;
  6196. /** @hidden */
  6197. _currentTarget: Vector3;
  6198. /** @hidden */
  6199. _viewMatrix: Matrix;
  6200. /** @hidden */
  6201. _camMatrix: Matrix;
  6202. /** @hidden */
  6203. _cameraTransformMatrix: Matrix;
  6204. /** @hidden */
  6205. _cameraRotationMatrix: Matrix;
  6206. private _rigCamTransformMatrix;
  6207. /** @hidden */
  6208. _referencePoint: Vector3;
  6209. /** @hidden */
  6210. _transformedReferencePoint: Vector3;
  6211. protected _globalCurrentTarget: Vector3;
  6212. protected _globalCurrentUpVector: Vector3;
  6213. /** @hidden */
  6214. _reset: () => void;
  6215. private _defaultUp;
  6216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6217. getFrontPosition(distance: number): Vector3;
  6218. /** @hidden */
  6219. _getLockedTargetPosition(): Nullable<Vector3>;
  6220. /**
  6221. * Store current camera state (fov, position, etc..)
  6222. */
  6223. private _storedPosition;
  6224. private _storedRotation;
  6225. private _storedRotationQuaternion;
  6226. storeState(): Camera;
  6227. /**
  6228. * Restored camera state. You must call storeState() first
  6229. * @returns whether it was successful or not
  6230. * @hidden
  6231. */
  6232. _restoreStateValues(): boolean;
  6233. /** @hidden */
  6234. _initCache(): void;
  6235. /** @hidden */
  6236. _updateCache(ignoreParentClass?: boolean): void;
  6237. /** @hidden */
  6238. _isSynchronizedViewMatrix(): boolean;
  6239. /** @hidden */
  6240. _computeLocalCameraSpeed(): number;
  6241. /** @hidden */
  6242. setTarget(target: Vector3): void;
  6243. /**
  6244. * Return the current target position of the camera. This value is expressed in local space.
  6245. */
  6246. getTarget(): Vector3;
  6247. /** @hidden */
  6248. _decideIfNeedsToMove(): boolean;
  6249. /** @hidden */
  6250. _updatePosition(): void;
  6251. /** @hidden */
  6252. _checkInputs(): void;
  6253. protected _updateCameraRotationMatrix(): void;
  6254. /**
  6255. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  6256. * @returns the current camera
  6257. */
  6258. private _rotateUpVectorWithCameraRotationMatrix;
  6259. private _cachedRotationZ;
  6260. /** @hidden */
  6261. _getViewMatrix(): Matrix;
  6262. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6263. /**
  6264. * @override
  6265. * Override Camera.createRigCamera
  6266. */
  6267. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6268. /**
  6269. * @hidden
  6270. * @override
  6271. * Override Camera._updateRigCameras
  6272. */
  6273. _updateRigCameras(): void;
  6274. private _getRigCamPosition;
  6275. getClassName(): string;
  6276. }
  6277. }
  6278. declare module BABYLON {
  6279. class TouchCamera extends FreeCamera {
  6280. touchAngularSensibility: number;
  6281. touchMoveSensibility: number;
  6282. constructor(name: string, position: Vector3, scene: Scene);
  6283. getClassName(): string;
  6284. /** @hidden */
  6285. _setupInputs(): void;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. class UniversalCamera extends TouchCamera {
  6290. gamepadAngularSensibility: number;
  6291. gamepadMoveSensibility: number;
  6292. constructor(name: string, position: Vector3, scene: Scene);
  6293. getClassName(): string;
  6294. }
  6295. }
  6296. declare module BABYLON {
  6297. class VirtualJoysticksCamera extends FreeCamera {
  6298. constructor(name: string, position: Vector3, scene: Scene);
  6299. getClassName(): string;
  6300. }
  6301. }
  6302. interface VRDisplay extends EventTarget {
  6303. /**
  6304. * Dictionary of capabilities describing the VRDisplay.
  6305. */
  6306. readonly capabilities: VRDisplayCapabilities;
  6307. /**
  6308. * z-depth defining the far plane of the eye view frustum
  6309. * enables mapping of values in the render target depth
  6310. * attachment to scene coordinates. Initially set to 10000.0.
  6311. */
  6312. depthFar: number;
  6313. /**
  6314. * z-depth defining the near plane of the eye view frustum
  6315. * enables mapping of values in the render target depth
  6316. * attachment to scene coordinates. Initially set to 0.01.
  6317. */
  6318. depthNear: number;
  6319. /**
  6320. * An identifier for this distinct VRDisplay. Used as an
  6321. * association point in the Gamepad API.
  6322. */
  6323. readonly displayId: number;
  6324. /**
  6325. * A display name, a user-readable name identifying it.
  6326. */
  6327. readonly displayName: string;
  6328. readonly isConnected: boolean;
  6329. readonly isPresenting: boolean;
  6330. /**
  6331. * If this VRDisplay supports room-scale experiences, the optional
  6332. * stage attribute contains details on the room-scale parameters.
  6333. */
  6334. readonly stageParameters: VRStageParameters | null;
  6335. /**
  6336. * Passing the value returned by `requestAnimationFrame` to
  6337. * `cancelAnimationFrame` will unregister the callback.
  6338. */
  6339. cancelAnimationFrame(handle: number): void;
  6340. /**
  6341. * Stops presenting to the VRDisplay.
  6342. */
  6343. exitPresent(): Promise<void>;
  6344. getEyeParameters(whichEye: string): VREyeParameters;
  6345. /**
  6346. * Populates the passed VRFrameData with the information required to render
  6347. * the current frame.
  6348. */
  6349. getFrameData(frameData: VRFrameData): boolean;
  6350. /**
  6351. * Get the layers currently being presented.
  6352. */
  6353. getLayers(): VRLayer[];
  6354. /**
  6355. * Return a VRPose containing the future predicted pose of the VRDisplay
  6356. * when the current frame will be presented. The value returned will not
  6357. * change until JavaScript has returned control to the browser.
  6358. *
  6359. * The VRPose will contain the position, orientation, velocity,
  6360. * and acceleration of each of these properties.
  6361. */
  6362. getPose(): VRPose;
  6363. /**
  6364. * Return the current instantaneous pose of the VRDisplay, with no
  6365. * prediction applied.
  6366. */
  6367. getImmediatePose(): VRPose;
  6368. /**
  6369. * The callback passed to `requestAnimationFrame` will be called
  6370. * any time a new frame should be rendered. When the VRDisplay is
  6371. * presenting the callback will be called at the native refresh
  6372. * rate of the HMD. When not presenting this function acts
  6373. * identically to how window.requestAnimationFrame acts. Content should
  6374. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6375. * asynchronously from other displays and at differing refresh rates.
  6376. */
  6377. requestAnimationFrame(callback: FrameRequestCallback): number;
  6378. /**
  6379. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6380. * Repeat calls while already presenting will update the VRLayers being displayed.
  6381. */
  6382. requestPresent(layers: VRLayer[]): Promise<void>;
  6383. /**
  6384. * Reset the pose for this display, treating its current position and
  6385. * orientation as the "origin/zero" values. VRPose.position,
  6386. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6387. * updated when calling resetPose(). This should be called in only
  6388. * sitting-space experiences.
  6389. */
  6390. resetPose(): void;
  6391. /**
  6392. * The VRLayer provided to the VRDisplay will be captured and presented
  6393. * in the HMD. Calling this function has the same effect on the source
  6394. * canvas as any other operation that uses its source image, and canvases
  6395. * created without preserveDrawingBuffer set to true will be cleared.
  6396. */
  6397. submitFrame(pose?: VRPose): void;
  6398. }
  6399. declare var VRDisplay: {
  6400. prototype: VRDisplay;
  6401. new (): VRDisplay;
  6402. };
  6403. interface VRLayer {
  6404. leftBounds?: number[] | Float32Array | null;
  6405. rightBounds?: number[] | Float32Array | null;
  6406. source?: HTMLCanvasElement | null;
  6407. }
  6408. interface VRDisplayCapabilities {
  6409. readonly canPresent: boolean;
  6410. readonly hasExternalDisplay: boolean;
  6411. readonly hasOrientation: boolean;
  6412. readonly hasPosition: boolean;
  6413. readonly maxLayers: number;
  6414. }
  6415. interface VREyeParameters {
  6416. /** @deprecated */
  6417. readonly fieldOfView: VRFieldOfView;
  6418. readonly offset: Float32Array;
  6419. readonly renderHeight: number;
  6420. readonly renderWidth: number;
  6421. }
  6422. interface VRFieldOfView {
  6423. readonly downDegrees: number;
  6424. readonly leftDegrees: number;
  6425. readonly rightDegrees: number;
  6426. readonly upDegrees: number;
  6427. }
  6428. interface VRFrameData {
  6429. readonly leftProjectionMatrix: Float32Array;
  6430. readonly leftViewMatrix: Float32Array;
  6431. readonly pose: VRPose;
  6432. readonly rightProjectionMatrix: Float32Array;
  6433. readonly rightViewMatrix: Float32Array;
  6434. readonly timestamp: number;
  6435. }
  6436. interface VRPose {
  6437. readonly angularAcceleration: Float32Array | null;
  6438. readonly angularVelocity: Float32Array | null;
  6439. readonly linearAcceleration: Float32Array | null;
  6440. readonly linearVelocity: Float32Array | null;
  6441. readonly orientation: Float32Array | null;
  6442. readonly position: Float32Array | null;
  6443. readonly timestamp: number;
  6444. }
  6445. interface VRStageParameters {
  6446. sittingToStandingTransform?: Float32Array;
  6447. sizeX?: number;
  6448. sizeY?: number;
  6449. }
  6450. interface Navigator {
  6451. getVRDisplays(): Promise<VRDisplay[]>;
  6452. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6453. }
  6454. interface Window {
  6455. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6456. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6457. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6458. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6459. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6460. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6461. }
  6462. interface Gamepad {
  6463. readonly displayId: number;
  6464. }
  6465. declare module BABYLON {
  6466. class Collider {
  6467. /** Define if a collision was found */
  6468. collisionFound: boolean;
  6469. /**
  6470. * Define last intersection point in local space
  6471. */
  6472. intersectionPoint: Vector3;
  6473. /**
  6474. * Define last collided mesh
  6475. */
  6476. collidedMesh: Nullable<AbstractMesh>;
  6477. private _collisionPoint;
  6478. private _planeIntersectionPoint;
  6479. private _tempVector;
  6480. private _tempVector2;
  6481. private _tempVector3;
  6482. private _tempVector4;
  6483. private _edge;
  6484. private _baseToVertex;
  6485. private _destinationPoint;
  6486. private _slidePlaneNormal;
  6487. private _displacementVector;
  6488. /** @hidden */
  6489. _radius: Vector3;
  6490. /** @hidden */
  6491. _retry: number;
  6492. private _velocity;
  6493. private _basePoint;
  6494. private _epsilon;
  6495. /** @hidden */
  6496. _velocityWorldLength: number;
  6497. /** @hidden */
  6498. _basePointWorld: Vector3;
  6499. private _velocityWorld;
  6500. private _normalizedVelocity;
  6501. /** @hidden */
  6502. _initialVelocity: Vector3;
  6503. /** @hidden */
  6504. _initialPosition: Vector3;
  6505. private _nearestDistance;
  6506. private _collisionMask;
  6507. collisionMask: number;
  6508. /**
  6509. * Gets the plane normal used to compute the sliding response (in local space)
  6510. */
  6511. readonly slidePlaneNormal: Vector3;
  6512. /** @hidden */
  6513. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6514. /** @hidden */
  6515. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6516. /** @hidden */
  6517. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6518. /** @hidden */
  6519. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6520. /** @hidden */
  6521. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6522. /** @hidden */
  6523. _getResponse(pos: Vector3, vel: Vector3): void;
  6524. }
  6525. }
  6526. declare module BABYLON {
  6527. var CollisionWorker: string;
  6528. interface ICollisionCoordinator {
  6529. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6530. init(scene: Scene): void;
  6531. destroy(): void;
  6532. onMeshAdded(mesh: AbstractMesh): void;
  6533. onMeshUpdated(mesh: AbstractMesh): void;
  6534. onMeshRemoved(mesh: AbstractMesh): void;
  6535. onGeometryAdded(geometry: Geometry): void;
  6536. onGeometryUpdated(geometry: Geometry): void;
  6537. onGeometryDeleted(geometry: Geometry): void;
  6538. }
  6539. interface SerializedMesh {
  6540. id: string;
  6541. name: string;
  6542. uniqueId: number;
  6543. geometryId: Nullable<string>;
  6544. sphereCenter: Array<number>;
  6545. sphereRadius: number;
  6546. boxMinimum: Array<number>;
  6547. boxMaximum: Array<number>;
  6548. worldMatrixFromCache: any;
  6549. subMeshes: Array<SerializedSubMesh>;
  6550. checkCollisions: boolean;
  6551. }
  6552. interface SerializedSubMesh {
  6553. position: number;
  6554. verticesStart: number;
  6555. verticesCount: number;
  6556. indexStart: number;
  6557. indexCount: number;
  6558. hasMaterial: boolean;
  6559. sphereCenter: Array<number>;
  6560. sphereRadius: number;
  6561. boxMinimum: Array<number>;
  6562. boxMaximum: Array<number>;
  6563. }
  6564. /**
  6565. * Interface describing the value associated with a geometry
  6566. */
  6567. interface SerializedGeometry {
  6568. /**
  6569. * Defines the unique ID of the geometry
  6570. */
  6571. id: string;
  6572. /**
  6573. * Defines the array containing the positions
  6574. */
  6575. positions: Float32Array;
  6576. /**
  6577. * Defines the array containing the indices
  6578. */
  6579. indices: Uint32Array;
  6580. /**
  6581. * Defines the array containing the normals
  6582. */
  6583. normals: Float32Array;
  6584. }
  6585. interface BabylonMessage {
  6586. taskType: WorkerTaskType;
  6587. payload: InitPayload | CollidePayload | UpdatePayload;
  6588. }
  6589. interface SerializedColliderToWorker {
  6590. position: Array<number>;
  6591. velocity: Array<number>;
  6592. radius: Array<number>;
  6593. }
  6594. /** Defines supported task for worker process */
  6595. enum WorkerTaskType {
  6596. /** Initialization */
  6597. INIT = 0,
  6598. /** Update of geometry */
  6599. UPDATE = 1,
  6600. /** Evaluate collision */
  6601. COLLIDE = 2
  6602. }
  6603. interface WorkerReply {
  6604. error: WorkerReplyType;
  6605. taskType: WorkerTaskType;
  6606. payload?: any;
  6607. }
  6608. interface CollisionReplyPayload {
  6609. newPosition: Array<number>;
  6610. collisionId: number;
  6611. collidedMeshUniqueId: number;
  6612. }
  6613. interface InitPayload {
  6614. }
  6615. interface CollidePayload {
  6616. collisionId: number;
  6617. collider: SerializedColliderToWorker;
  6618. maximumRetry: number;
  6619. excludedMeshUniqueId: Nullable<number>;
  6620. }
  6621. interface UpdatePayload {
  6622. updatedMeshes: {
  6623. [n: number]: SerializedMesh;
  6624. };
  6625. updatedGeometries: {
  6626. [s: string]: SerializedGeometry;
  6627. };
  6628. removedMeshes: Array<number>;
  6629. removedGeometries: Array<string>;
  6630. }
  6631. /** Defines kind of replies returned by worker */
  6632. enum WorkerReplyType {
  6633. /** Success */
  6634. SUCCESS = 0,
  6635. /** Unkown error */
  6636. UNKNOWN_ERROR = 1
  6637. }
  6638. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6639. private _scene;
  6640. private _scaledPosition;
  6641. private _scaledVelocity;
  6642. private _collisionsCallbackArray;
  6643. private _init;
  6644. private _runningUpdated;
  6645. private _worker;
  6646. private _addUpdateMeshesList;
  6647. private _addUpdateGeometriesList;
  6648. private _toRemoveMeshesArray;
  6649. private _toRemoveGeometryArray;
  6650. constructor();
  6651. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6652. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6653. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6654. init(scene: Scene): void;
  6655. destroy(): void;
  6656. onMeshAdded(mesh: AbstractMesh): void;
  6657. onMeshUpdated: (transformNode: TransformNode) => void;
  6658. onMeshRemoved(mesh: AbstractMesh): void;
  6659. onGeometryAdded(geometry: Geometry): void;
  6660. onGeometryUpdated: (geometry: Geometry) => void;
  6661. onGeometryDeleted(geometry: Geometry): void;
  6662. private _afterRender;
  6663. private _onMessageFromWorker;
  6664. }
  6665. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6666. private _scene;
  6667. private _scaledPosition;
  6668. private _scaledVelocity;
  6669. private _finalPosition;
  6670. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6671. init(scene: Scene): void;
  6672. destroy(): void;
  6673. onMeshAdded(mesh: AbstractMesh): void;
  6674. onMeshUpdated(mesh: AbstractMesh): void;
  6675. onMeshRemoved(mesh: AbstractMesh): void;
  6676. onGeometryAdded(geometry: Geometry): void;
  6677. onGeometryUpdated(geometry: Geometry): void;
  6678. onGeometryDeleted(geometry: Geometry): void;
  6679. private _collideWithWorld;
  6680. }
  6681. }
  6682. declare function importScripts(...urls: string[]): void;
  6683. declare const safePostMessage: any;
  6684. declare module BABYLON {
  6685. var WorkerIncluded: boolean;
  6686. class CollisionCache {
  6687. private _meshes;
  6688. private _geometries;
  6689. getMeshes(): {
  6690. [n: number]: SerializedMesh;
  6691. };
  6692. getGeometries(): {
  6693. [s: number]: SerializedGeometry;
  6694. };
  6695. getMesh(id: any): SerializedMesh;
  6696. addMesh(mesh: SerializedMesh): void;
  6697. removeMesh(uniqueId: number): void;
  6698. getGeometry(id: string): SerializedGeometry;
  6699. addGeometry(geometry: SerializedGeometry): void;
  6700. removeGeometry(id: string): void;
  6701. }
  6702. class CollideWorker {
  6703. collider: Collider;
  6704. private _collisionCache;
  6705. private finalPosition;
  6706. private collisionsScalingMatrix;
  6707. private collisionTranformationMatrix;
  6708. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6709. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6710. private checkCollision;
  6711. private processCollisionsForSubMeshes;
  6712. private collideForSubMesh;
  6713. private checkSubmeshCollision;
  6714. }
  6715. interface ICollisionDetector {
  6716. onInit(payload: InitPayload): void;
  6717. onUpdate(payload: UpdatePayload): void;
  6718. onCollision(payload: CollidePayload): void;
  6719. }
  6720. class CollisionDetectorTransferable implements ICollisionDetector {
  6721. private _collisionCache;
  6722. onInit(payload: InitPayload): void;
  6723. onUpdate(payload: UpdatePayload): void;
  6724. onCollision(payload: CollidePayload): void;
  6725. }
  6726. }
  6727. declare module BABYLON {
  6728. class IntersectionInfo {
  6729. bu: Nullable<number>;
  6730. bv: Nullable<number>;
  6731. distance: number;
  6732. faceId: number;
  6733. subMeshId: number;
  6734. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6735. }
  6736. /**
  6737. * Information about the result of picking within a scene
  6738. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6739. */
  6740. class PickingInfo {
  6741. /**
  6742. * If the pick collided with an object
  6743. */
  6744. hit: boolean;
  6745. /**
  6746. * Distance away where the pick collided
  6747. */
  6748. distance: number;
  6749. /**
  6750. * The location of pick collision
  6751. */
  6752. pickedPoint: Nullable<Vector3>;
  6753. /**
  6754. * The mesh corresponding the the pick collision
  6755. */
  6756. pickedMesh: Nullable<AbstractMesh>;
  6757. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6758. bu: number;
  6759. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6760. bv: number;
  6761. /** The id of the face on the mesh that was picked */
  6762. faceId: number;
  6763. /** Id of the the submesh that was picked */
  6764. subMeshId: number;
  6765. /** If a sprite was picked, this will be the sprite the pick collided with */
  6766. pickedSprite: Nullable<Sprite>;
  6767. /**
  6768. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6769. */
  6770. originMesh: Nullable<AbstractMesh>;
  6771. /**
  6772. * The ray that was used to perform the picking.
  6773. */
  6774. ray: Nullable<Ray>;
  6775. /**
  6776. * Gets the normal correspodning to the face the pick collided with
  6777. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6778. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6779. * @returns The normal correspodning to the face the pick collided with
  6780. */
  6781. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6782. /**
  6783. * Gets the texture coordinates of where the pick occured
  6784. * @returns the vector containing the coordnates of the texture
  6785. */
  6786. getTextureCoordinates(): Nullable<Vector2>;
  6787. }
  6788. }
  6789. declare module BABYLON {
  6790. class BoundingBox implements ICullable {
  6791. vectors: Vector3[];
  6792. center: Vector3;
  6793. centerWorld: Vector3;
  6794. extendSize: Vector3;
  6795. extendSizeWorld: Vector3;
  6796. directions: Vector3[];
  6797. vectorsWorld: Vector3[];
  6798. minimumWorld: Vector3;
  6799. maximumWorld: Vector3;
  6800. minimum: Vector3;
  6801. maximum: Vector3;
  6802. private _worldMatrix;
  6803. /**
  6804. * Creates a new bounding box
  6805. * @param min defines the minimum vector (in local space)
  6806. * @param max defines the maximum vector (in local space)
  6807. */
  6808. constructor(min: Vector3, max: Vector3);
  6809. /**
  6810. * Recreates the entire bounding box from scratch
  6811. * @param min defines the new minimum vector (in local space)
  6812. * @param max defines the new maximum vector (in local space)
  6813. */
  6814. reConstruct(min: Vector3, max: Vector3): void;
  6815. /**
  6816. * Scale the current bounding box by applying a scale factor
  6817. * @param factor defines the scale factor to apply
  6818. * @returns the current bounding box
  6819. */
  6820. scale(factor: number): BoundingBox;
  6821. getWorldMatrix(): Matrix;
  6822. setWorldMatrix(matrix: Matrix): BoundingBox;
  6823. /** @hidden */
  6824. _update(world: Matrix): void;
  6825. isInFrustum(frustumPlanes: Plane[]): boolean;
  6826. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6827. intersectsPoint(point: Vector3): boolean;
  6828. intersectsSphere(sphere: BoundingSphere): boolean;
  6829. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6830. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6831. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6832. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6833. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6834. }
  6835. }
  6836. declare module BABYLON {
  6837. interface ICullable {
  6838. isInFrustum(frustumPlanes: Plane[]): boolean;
  6839. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6840. }
  6841. class BoundingInfo implements ICullable {
  6842. minimum: Vector3;
  6843. maximum: Vector3;
  6844. boundingBox: BoundingBox;
  6845. boundingSphere: BoundingSphere;
  6846. private _isLocked;
  6847. constructor(minimum: Vector3, maximum: Vector3);
  6848. isLocked: boolean;
  6849. update(world: Matrix): void;
  6850. /**
  6851. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6852. * @param center New center of the bounding info
  6853. * @param extend New extend of the bounding info
  6854. */
  6855. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6856. /**
  6857. * Scale the current bounding info by applying a scale factor
  6858. * @param factor defines the scale factor to apply
  6859. * @returns the current bounding info
  6860. */
  6861. scale(factor: number): BoundingInfo;
  6862. /**
  6863. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6864. * @param frustumPlanes defines the frustum to test
  6865. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6866. * @returns true if the bounding info is in the frustum planes
  6867. */
  6868. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6869. /**
  6870. * Gets the world distance between the min and max points of the bounding box
  6871. */
  6872. readonly diagonalLength: number;
  6873. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6874. /** @hidden */
  6875. _checkCollision(collider: Collider): boolean;
  6876. intersectsPoint(point: Vector3): boolean;
  6877. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6878. }
  6879. }
  6880. declare module BABYLON {
  6881. class BoundingSphere {
  6882. center: Vector3;
  6883. radius: number;
  6884. centerWorld: Vector3;
  6885. radiusWorld: number;
  6886. minimum: Vector3;
  6887. maximum: Vector3;
  6888. private _tempRadiusVector;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. */
  6894. constructor(min: Vector3, max: Vector3);
  6895. /**
  6896. * Recreates the entire bounding sphere from scratch
  6897. * @param min defines the new minimum vector (in local space)
  6898. * @param max defines the new maximum vector (in local space)
  6899. */
  6900. reConstruct(min: Vector3, max: Vector3): void;
  6901. /**
  6902. * Scale the current bounding sphere by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingSphere;
  6907. /** @hidden */
  6908. _update(world: Matrix): void;
  6909. isInFrustum(frustumPlanes: Plane[]): boolean;
  6910. intersectsPoint(point: Vector3): boolean;
  6911. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6912. }
  6913. }
  6914. declare module BABYLON {
  6915. class Ray {
  6916. origin: Vector3;
  6917. direction: Vector3;
  6918. length: number;
  6919. private _edge1;
  6920. private _edge2;
  6921. private _pvec;
  6922. private _tvec;
  6923. private _qvec;
  6924. private _tmpRay;
  6925. constructor(origin: Vector3, direction: Vector3, length?: number);
  6926. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6927. intersectsBox(box: BoundingBox): boolean;
  6928. intersectsSphere(sphere: BoundingSphere): boolean;
  6929. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6930. intersectsPlane(plane: Plane): Nullable<number>;
  6931. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6932. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6933. private _comparePickingInfo;
  6934. private static smallnum;
  6935. private static rayl;
  6936. /**
  6937. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6938. * @param sega the first point of the segment to test the intersection against
  6939. * @param segb the second point of the segment to test the intersection against
  6940. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6941. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6942. */
  6943. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6944. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6945. static Zero(): Ray;
  6946. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6947. /**
  6948. * 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
  6949. * transformed to the given world matrix.
  6950. * @param origin The origin point
  6951. * @param end The end point
  6952. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6953. */
  6954. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6955. static Transform(ray: Ray, matrix: Matrix): Ray;
  6956. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6957. }
  6958. }
  6959. /**
  6960. * Module Debug contains the (visual) components to debug a scene correctly
  6961. */
  6962. declare module BABYLON.Debug {
  6963. /**
  6964. * The Axes viewer will show 3 axes in a specific point in space
  6965. */
  6966. class AxesViewer {
  6967. private _xline;
  6968. private _yline;
  6969. private _zline;
  6970. private _xmesh;
  6971. private _ymesh;
  6972. private _zmesh;
  6973. /**
  6974. * Gets the hosting scene
  6975. */
  6976. scene: Nullable<Scene>;
  6977. /**
  6978. * Gets or sets a number used to scale line length
  6979. */
  6980. scaleLines: number;
  6981. /**
  6982. * Creates a new AxesViewer
  6983. * @param scene defines the hosting scene
  6984. * @param scaleLines defines a number used to scale line length (1 by default)
  6985. */
  6986. constructor(scene: Scene, scaleLines?: number);
  6987. /**
  6988. * Force the viewer to update
  6989. * @param position defines the position of the viewer
  6990. * @param xaxis defines the x axis of the viewer
  6991. * @param yaxis defines the y axis of the viewer
  6992. * @param zaxis defines the z axis of the viewer
  6993. */
  6994. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6995. /** Releases resources */
  6996. dispose(): void;
  6997. }
  6998. }
  6999. declare module BABYLON.Debug {
  7000. /**
  7001. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  7002. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  7003. */
  7004. class BoneAxesViewer extends AxesViewer {
  7005. /**
  7006. * Gets or sets the target mesh where to display the axes viewer
  7007. */
  7008. mesh: Nullable<Mesh>;
  7009. /**
  7010. * Gets or sets the target bone where to display the axes viewer
  7011. */
  7012. bone: Nullable<Bone>;
  7013. /** Gets current position */
  7014. pos: Vector3;
  7015. /** Gets direction of X axis */
  7016. xaxis: Vector3;
  7017. /** Gets direction of Y axis */
  7018. yaxis: Vector3;
  7019. /** Gets direction of Z axis */
  7020. zaxis: Vector3;
  7021. /**
  7022. * Creates a new BoneAxesViewer
  7023. * @param scene defines the hosting scene
  7024. * @param bone defines the target bone
  7025. * @param mesh defines the target mesh
  7026. * @param scaleLines defines a scaling factor for line length (1 by default)
  7027. */
  7028. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7029. /**
  7030. * Force the viewer to update
  7031. */
  7032. update(): void;
  7033. /** Releases resources */
  7034. dispose(): void;
  7035. }
  7036. }
  7037. declare module BABYLON {
  7038. class DebugLayer {
  7039. private _scene;
  7040. static InspectorURL: string;
  7041. private _inspector;
  7042. private BJSINSPECTOR;
  7043. onPropertyChangedObservable: Observable<{
  7044. object: any;
  7045. property: string;
  7046. value: any;
  7047. initialValue: any;
  7048. }>;
  7049. constructor(scene: Scene);
  7050. /** Creates the inspector window. */
  7051. private _createInspector;
  7052. isVisible(): boolean;
  7053. hide(): void;
  7054. /**
  7055. *
  7056. * Launch the debugLayer.
  7057. *
  7058. * initialTab:
  7059. * | Value | Tab Name |
  7060. * | --- | --- |
  7061. * | 0 | Scene |
  7062. * | 1 | Console |
  7063. * | 2 | Stats |
  7064. * | 3 | Textures |
  7065. * | 4 | Mesh |
  7066. * | 5 | Light |
  7067. * | 6 | Material |
  7068. * | 7 | GLTF |
  7069. * | 8 | GUI |
  7070. * | 9 | Physics |
  7071. * | 10 | Camera |
  7072. * | 11 | Audio |
  7073. *
  7074. */
  7075. show(config?: {
  7076. popup?: boolean;
  7077. initialTab?: number;
  7078. parentElement?: HTMLElement;
  7079. newColors?: {
  7080. backgroundColor?: string;
  7081. backgroundColorLighter?: string;
  7082. backgroundColorLighter2?: string;
  7083. backgroundColorLighter3?: string;
  7084. color?: string;
  7085. colorTop?: string;
  7086. colorBot?: string;
  7087. };
  7088. }): void;
  7089. /**
  7090. * Gets the active tab
  7091. * @return the index of the active tab or -1 if the inspector is hidden
  7092. */
  7093. getActiveTab(): number;
  7094. }
  7095. }
  7096. declare module BABYLON.Debug {
  7097. /**
  7098. * Used to show the physics impostor around the specific mesh
  7099. */
  7100. class PhysicsViewer {
  7101. /** @hidden */
  7102. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7103. /** @hidden */
  7104. protected _meshes: Array<Nullable<AbstractMesh>>;
  7105. /** @hidden */
  7106. protected _scene: Nullable<Scene>;
  7107. /** @hidden */
  7108. protected _numMeshes: number;
  7109. /** @hidden */
  7110. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7111. private _renderFunction;
  7112. private _debugBoxMesh;
  7113. private _debugSphereMesh;
  7114. private _debugMaterial;
  7115. /**
  7116. * Creates a new PhysicsViewer
  7117. * @param scene defines the hosting scene
  7118. */
  7119. constructor(scene: Scene);
  7120. /** @hidden */
  7121. protected _updateDebugMeshes(): void;
  7122. /**
  7123. * Renders a specified physic impostor
  7124. * @param impostor defines the impostor to render
  7125. */
  7126. showImpostor(impostor: PhysicsImpostor): void;
  7127. /**
  7128. * Hides a specified physic impostor
  7129. * @param impostor defines the impostor to hide
  7130. */
  7131. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7132. private _getDebugMaterial;
  7133. private _getDebugBoxMesh;
  7134. private _getDebugSphereMesh;
  7135. private _getDebugMesh;
  7136. /** Releases all resources */
  7137. dispose(): void;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. class RayHelper {
  7142. ray: Nullable<Ray>;
  7143. private _renderPoints;
  7144. private _renderLine;
  7145. private _renderFunction;
  7146. private _scene;
  7147. private _updateToMeshFunction;
  7148. private _attachedToMesh;
  7149. private _meshSpaceDirection;
  7150. private _meshSpaceOrigin;
  7151. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7152. constructor(ray: Ray);
  7153. show(scene: Scene, color?: Color3): void;
  7154. hide(): void;
  7155. private _render;
  7156. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7157. detachFromMesh(): void;
  7158. private _updateToMesh;
  7159. dispose(): void;
  7160. }
  7161. }
  7162. declare module BABYLON.Debug {
  7163. /**
  7164. * Class used to render a debug view of a given skeleton
  7165. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7166. */
  7167. class SkeletonViewer {
  7168. /** defines the skeleton to render */
  7169. skeleton: Skeleton;
  7170. /** defines the mesh attached to the skeleton */
  7171. mesh: AbstractMesh;
  7172. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7173. autoUpdateBonesMatrices: boolean;
  7174. /** defines the rendering group id to use with the viewer */
  7175. renderingGroupId: number;
  7176. /** Gets or sets the color used to render the skeleton */
  7177. color: Color3;
  7178. private _scene;
  7179. private _debugLines;
  7180. private _debugMesh;
  7181. private _isEnabled;
  7182. private _renderFunction;
  7183. /**
  7184. * Creates a new SkeletonViewer
  7185. * @param skeleton defines the skeleton to render
  7186. * @param mesh defines the mesh attached to the skeleton
  7187. * @param scene defines the hosting scene
  7188. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7189. * @param renderingGroupId defines the rendering group id to use with the viewer
  7190. */
  7191. constructor(
  7192. /** defines the skeleton to render */
  7193. skeleton: Skeleton,
  7194. /** defines the mesh attached to the skeleton */
  7195. mesh: AbstractMesh, scene: Scene,
  7196. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7197. autoUpdateBonesMatrices?: boolean,
  7198. /** defines the rendering group id to use with the viewer */
  7199. renderingGroupId?: number);
  7200. /** Gets or sets a boolean indicating if the viewer is enabled */
  7201. isEnabled: boolean;
  7202. private _getBonePosition;
  7203. private _getLinesForBonesWithLength;
  7204. private _getLinesForBonesNoLength;
  7205. /** Update the viewer to sync with current skeleton state */
  7206. update(): void;
  7207. /** Release associated resources */
  7208. dispose(): void;
  7209. }
  7210. }
  7211. declare module BABYLON {
  7212. /**
  7213. * Interface for attribute information associated with buffer instanciation
  7214. */
  7215. class InstancingAttributeInfo {
  7216. /**
  7217. * Index/offset of the attribute in the vertex shader
  7218. */
  7219. index: number;
  7220. /**
  7221. * size of the attribute, 1, 2, 3 or 4
  7222. */
  7223. attributeSize: number;
  7224. /**
  7225. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7226. * default is FLOAT
  7227. */
  7228. attribyteType: number;
  7229. /**
  7230. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7231. */
  7232. normalized: boolean;
  7233. /**
  7234. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7235. */
  7236. offset: number;
  7237. /**
  7238. * Name of the GLSL attribute, for debugging purpose only
  7239. */
  7240. attributeName: string;
  7241. }
  7242. /**
  7243. * Define options used to create a render target texture
  7244. */
  7245. class RenderTargetCreationOptions {
  7246. /**
  7247. * Specifies is mipmaps must be generated
  7248. */
  7249. generateMipMaps?: boolean;
  7250. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7251. generateDepthBuffer?: boolean;
  7252. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7253. generateStencilBuffer?: boolean;
  7254. /** Defines texture type (int by default) */
  7255. type?: number;
  7256. /** Defines sampling mode (trilinear by default) */
  7257. samplingMode?: number;
  7258. /** Defines format (RGBA by default) */
  7259. format?: number;
  7260. }
  7261. /**
  7262. * Define options used to create a depth texture
  7263. */
  7264. class DepthTextureCreationOptions {
  7265. /** Specifies whether or not a stencil should be allocated in the texture */
  7266. generateStencil?: boolean;
  7267. /** Specifies whether or not bilinear filtering is enable on the texture */
  7268. bilinearFiltering?: boolean;
  7269. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7270. comparisonFunction?: number;
  7271. /** Specifies if the created texture is a cube texture */
  7272. isCube?: boolean;
  7273. }
  7274. /**
  7275. * Class used to describe the capabilities of the engine relatively to the current browser
  7276. */
  7277. class EngineCapabilities {
  7278. /** Maximum textures units per fragment shader */
  7279. maxTexturesImageUnits: number;
  7280. /** Maximum texture units per vertex shader */
  7281. maxVertexTextureImageUnits: number;
  7282. /** Maximum textures units in the entire pipeline */
  7283. maxCombinedTexturesImageUnits: number;
  7284. /** Maximum texture size */
  7285. maxTextureSize: number;
  7286. /** Maximum cube texture size */
  7287. maxCubemapTextureSize: number;
  7288. /** Maximum render texture size */
  7289. maxRenderTextureSize: number;
  7290. /** Maximum number of vertex attributes */
  7291. maxVertexAttribs: number;
  7292. /** Maximum number of varyings */
  7293. maxVaryingVectors: number;
  7294. /** Maximum number of uniforms per vertex shader */
  7295. maxVertexUniformVectors: number;
  7296. /** Maximum number of uniforms per fragment shader */
  7297. maxFragmentUniformVectors: number;
  7298. /** Defines if standard derivates (dx/dy) are supported */
  7299. standardDerivatives: boolean;
  7300. /** Defines if s3tc texture compression is supported */
  7301. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7302. /** Defines if pvrtc texture compression is supported */
  7303. pvrtc: any;
  7304. /** Defines if etc1 texture compression is supported */
  7305. etc1: any;
  7306. /** Defines if etc2 texture compression is supported */
  7307. etc2: any;
  7308. /** Defines if astc texture compression is supported */
  7309. astc: any;
  7310. /** Defines if float textures are supported */
  7311. textureFloat: boolean;
  7312. /** Defines if vertex array objects are supported */
  7313. vertexArrayObject: boolean;
  7314. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7315. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7316. /** Gets the maximum level of anisotropy supported */
  7317. maxAnisotropy: number;
  7318. /** Defines if instancing is supported */
  7319. instancedArrays: boolean;
  7320. /** Defines if 32 bits indices are supported */
  7321. uintIndices: boolean;
  7322. /** Defines if high precision shaders are supported */
  7323. highPrecisionShaderSupported: boolean;
  7324. /** Defines if depth reading in the fragment shader is supported */
  7325. fragmentDepthSupported: boolean;
  7326. /** Defines if float texture linear filtering is supported*/
  7327. textureFloatLinearFiltering: boolean;
  7328. /** Defines if rendering to float textures is supported */
  7329. textureFloatRender: boolean;
  7330. /** Defines if half float textures are supported*/
  7331. textureHalfFloat: boolean;
  7332. /** Defines if half float texture linear filtering is supported*/
  7333. textureHalfFloatLinearFiltering: boolean;
  7334. /** Defines if rendering to half float textures is supported */
  7335. textureHalfFloatRender: boolean;
  7336. /** Defines if textureLOD shader command is supported */
  7337. textureLOD: boolean;
  7338. /** Defines if draw buffers extension is supported */
  7339. drawBuffersExtension: boolean;
  7340. /** Defines if depth textures are supported */
  7341. depthTextureExtension: boolean;
  7342. /** Defines if float color buffer are supported */
  7343. colorBufferFloat: boolean;
  7344. /** Gets disjoint timer query extension (null if not supported) */
  7345. timerQuery: EXT_disjoint_timer_query;
  7346. /** Defines if timestamp can be used with timer query */
  7347. canUseTimestampForTimerQuery: boolean;
  7348. }
  7349. /** Interface defining initialization parameters for Engine class */
  7350. interface EngineOptions extends WebGLContextAttributes {
  7351. /**
  7352. * Defines if the engine should no exceed a specified device ratio
  7353. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7354. */
  7355. limitDeviceRatio?: number;
  7356. /**
  7357. * Defines if webvr should be enabled automatically
  7358. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7359. */
  7360. autoEnableWebVR?: boolean;
  7361. /**
  7362. * Defines if webgl2 should be turned off even if supported
  7363. * @see http://doc.babylonjs.com/features/webgl2
  7364. */
  7365. disableWebGL2Support?: boolean;
  7366. /**
  7367. * Defines if webaudio should be initialized as well
  7368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7369. */
  7370. audioEngine?: boolean;
  7371. /**
  7372. * Defines if animations should run using a deterministic lock step
  7373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7374. */
  7375. deterministicLockstep?: boolean;
  7376. /** Defines the maximum steps to use with deterministic lock step mode */
  7377. lockstepMaxSteps?: number;
  7378. /**
  7379. * Defines that engine should ignore context lost events
  7380. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7381. */
  7382. doNotHandleContextLost?: boolean;
  7383. }
  7384. /**
  7385. * Defines the interface used by display changed events
  7386. */
  7387. interface IDisplayChangedEventArgs {
  7388. /** Gets the vrDisplay object (if any) */
  7389. vrDisplay: Nullable<any>;
  7390. /** Gets a boolean indicating if webVR is supported */
  7391. vrSupported: boolean;
  7392. }
  7393. /**
  7394. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7395. */
  7396. class Engine {
  7397. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7398. static ExceptionList: ({
  7399. key: string;
  7400. capture: string;
  7401. captureConstraint: number;
  7402. targets: string[];
  7403. } | {
  7404. key: string;
  7405. capture: null;
  7406. captureConstraint: null;
  7407. targets: string[];
  7408. })[];
  7409. /** Gets the list of created engines */
  7410. static Instances: Engine[];
  7411. /**
  7412. * Gets the latest created engine
  7413. */
  7414. static readonly LastCreatedEngine: Nullable<Engine>;
  7415. /**
  7416. * Gets the latest created scene
  7417. */
  7418. static readonly LastCreatedScene: Nullable<Scene>;
  7419. /**
  7420. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7421. * @param flag defines which part of the materials must be marked as dirty
  7422. * @param predicate defines a predicate used to filter which materials should be affected
  7423. */
  7424. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7425. /**
  7426. * Hidden
  7427. */
  7428. static _TextureLoaders: IInternalTextureLoader[];
  7429. /** Defines that alpha blending is disabled */
  7430. static readonly ALPHA_DISABLE: number;
  7431. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7432. static readonly ALPHA_ADD: number;
  7433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7434. static readonly ALPHA_COMBINE: number;
  7435. /** Defines that alpha blending to DEST - SRC * DEST */
  7436. static readonly ALPHA_SUBTRACT: number;
  7437. /** Defines that alpha blending to SRC * DEST */
  7438. static readonly ALPHA_MULTIPLY: number;
  7439. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7440. static readonly ALPHA_MAXIMIZED: number;
  7441. /** Defines that alpha blending to SRC + DEST */
  7442. static readonly ALPHA_ONEONE: number;
  7443. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7444. static readonly ALPHA_PREMULTIPLIED: number;
  7445. /**
  7446. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7447. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7448. */
  7449. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7450. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7451. static readonly ALPHA_INTERPOLATE: number;
  7452. /**
  7453. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7454. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7455. */
  7456. static readonly ALPHA_SCREENMODE: number;
  7457. /** Defines that the ressource is not delayed*/
  7458. static readonly DELAYLOADSTATE_NONE: number;
  7459. /** Defines that the ressource was successfully delay loaded */
  7460. static readonly DELAYLOADSTATE_LOADED: number;
  7461. /** Defines that the ressource is currently delay loading */
  7462. static readonly DELAYLOADSTATE_LOADING: number;
  7463. /** Defines that the ressource is delayed and has not started loading */
  7464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7466. static readonly NEVER: number;
  7467. /** 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 */
  7468. static readonly ALWAYS: number;
  7469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7470. static readonly LESS: number;
  7471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7472. static readonly EQUAL: number;
  7473. /** 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 */
  7474. static readonly LEQUAL: number;
  7475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7476. static readonly GREATER: number;
  7477. /** 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 */
  7478. static readonly GEQUAL: number;
  7479. /** 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 */
  7480. static readonly NOTEQUAL: number;
  7481. /** Passed to stencilOperation to specify that stencil value must be kept */
  7482. static readonly KEEP: number;
  7483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7484. static readonly REPLACE: number;
  7485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7486. static readonly INCR: number;
  7487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7488. static readonly DECR: number;
  7489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7490. static readonly INVERT: number;
  7491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7492. static readonly INCR_WRAP: number;
  7493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7494. static readonly DECR_WRAP: number;
  7495. /** Texture is not repeating outside of 0..1 UVs */
  7496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7497. /** Texture is repeating outside of 0..1 UVs */
  7498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7499. /** Texture is repeating and mirrored */
  7500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7501. /** ALPHA */
  7502. static readonly TEXTUREFORMAT_ALPHA: number;
  7503. /** LUMINANCE */
  7504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7505. /** LUMINANCE_ALPHA */
  7506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7507. /** RGB */
  7508. static readonly TEXTUREFORMAT_RGB: number;
  7509. /** RGBA */
  7510. static readonly TEXTUREFORMAT_RGBA: number;
  7511. /** RED */
  7512. static readonly TEXTUREFORMAT_RED: number;
  7513. /** RED (2nd reference) */
  7514. static readonly TEXTUREFORMAT_R: number;
  7515. /** RG */
  7516. static readonly TEXTUREFORMAT_RG: number;
  7517. /** RED_INTEGER */
  7518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7519. /** RED_INTEGER (2nd reference) */
  7520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7521. /** RG_INTEGER */
  7522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7523. /** RGB_INTEGER */
  7524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7525. /** RGBA_INTEGER */
  7526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7527. /** UNSIGNED_BYTE */
  7528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7529. /** UNSIGNED_BYTE (2nd reference) */
  7530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7531. /** FLOAT */
  7532. static readonly TEXTURETYPE_FLOAT: number;
  7533. /** HALF_FLOAT */
  7534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7535. /** BYTE */
  7536. static readonly TEXTURETYPE_BYTE: number;
  7537. /** SHORT */
  7538. static readonly TEXTURETYPE_SHORT: number;
  7539. /** UNSIGNED_SHORT */
  7540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7541. /** INT */
  7542. static readonly TEXTURETYPE_INT: number;
  7543. /** UNSIGNED_INT */
  7544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7545. /** UNSIGNED_SHORT_4_4_4_4 */
  7546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7547. /** UNSIGNED_SHORT_5_5_5_1 */
  7548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7549. /** UNSIGNED_SHORT_5_6_5 */
  7550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7551. /** UNSIGNED_INT_2_10_10_10_REV */
  7552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7553. /** UNSIGNED_INT_24_8 */
  7554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7555. /** UNSIGNED_INT_10F_11F_11F_REV */
  7556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7557. /** UNSIGNED_INT_5_9_9_9_REV */
  7558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7561. /** nearest is mag = nearest and min = nearest and mip = linear */
  7562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7564. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7565. /** Trilinear is mag = linear and min = linear and mip = linear */
  7566. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7567. /** nearest is mag = nearest and min = nearest and mip = linear */
  7568. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7569. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7570. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7571. /** Trilinear is mag = linear and min = linear and mip = linear */
  7572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7573. /** mag = nearest and min = nearest and mip = nearest */
  7574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7575. /** mag = nearest and min = linear and mip = nearest */
  7576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7577. /** mag = nearest and min = linear and mip = linear */
  7578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7579. /** mag = nearest and min = linear and mip = none */
  7580. static readonly TEXTURE_NEAREST_LINEAR: number;
  7581. /** mag = nearest and min = nearest and mip = none */
  7582. static readonly TEXTURE_NEAREST_NEAREST: number;
  7583. /** mag = linear and min = nearest and mip = nearest */
  7584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7585. /** mag = linear and min = nearest and mip = linear */
  7586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7587. /** mag = linear and min = linear and mip = none */
  7588. static readonly TEXTURE_LINEAR_LINEAR: number;
  7589. /** mag = linear and min = nearest and mip = none */
  7590. static readonly TEXTURE_LINEAR_NEAREST: number;
  7591. /** Explicit coordinates mode */
  7592. static readonly TEXTURE_EXPLICIT_MODE: number;
  7593. /** Spherical coordinates mode */
  7594. static readonly TEXTURE_SPHERICAL_MODE: number;
  7595. /** Planar coordinates mode */
  7596. static readonly TEXTURE_PLANAR_MODE: number;
  7597. /** Cubic coordinates mode */
  7598. static readonly TEXTURE_CUBIC_MODE: number;
  7599. /** Projection coordinates mode */
  7600. static readonly TEXTURE_PROJECTION_MODE: number;
  7601. /** Skybox coordinates mode */
  7602. static readonly TEXTURE_SKYBOX_MODE: number;
  7603. /** Inverse Cubic coordinates mode */
  7604. static readonly TEXTURE_INVCUBIC_MODE: number;
  7605. /** Equirectangular coordinates mode */
  7606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7607. /** Equirectangular Fixed coordinates mode */
  7608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7609. /** Equirectangular Fixed Mirrored coordinates mode */
  7610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7611. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7612. static readonly SCALEMODE_FLOOR: number;
  7613. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7614. static readonly SCALEMODE_NEAREST: number;
  7615. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7616. static readonly SCALEMODE_CEILING: number;
  7617. /**
  7618. * Returns the current version of the framework
  7619. */
  7620. static readonly Version: string;
  7621. /**
  7622. * Gets or sets the epsilon value used by collision engine
  7623. */
  7624. static CollisionsEpsilon: number;
  7625. /**
  7626. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7627. */
  7628. static CodeRepository: string;
  7629. /**
  7630. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7631. */
  7632. static ShadersRepository: string;
  7633. /**
  7634. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7635. */
  7636. forcePOTTextures: boolean;
  7637. /**
  7638. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7639. */
  7640. isFullscreen: boolean;
  7641. /**
  7642. * Gets a boolean indicating if the pointer is currently locked
  7643. */
  7644. isPointerLock: boolean;
  7645. /**
  7646. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7647. */
  7648. cullBackFaces: boolean;
  7649. /**
  7650. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7651. */
  7652. renderEvenInBackground: boolean;
  7653. /**
  7654. * Gets or sets a boolean indicating that cache can be kept between frames
  7655. */
  7656. preventCacheWipeBetweenFrames: boolean;
  7657. /**
  7658. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7659. **/
  7660. enableOfflineSupport: boolean;
  7661. /**
  7662. * 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)
  7663. **/
  7664. disableManifestCheck: boolean;
  7665. /**
  7666. * Gets the list of created scenes
  7667. */
  7668. scenes: Scene[];
  7669. /**
  7670. * Gets the list of created postprocesses
  7671. */
  7672. postProcesses: PostProcess[];
  7673. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7674. validateShaderPrograms: boolean;
  7675. /**
  7676. * Observable event triggered each time the rendering canvas is resized
  7677. */
  7678. onResizeObservable: Observable<Engine>;
  7679. /**
  7680. * Observable event triggered each time the canvas loses focus
  7681. */
  7682. onCanvasBlurObservable: Observable<Engine>;
  7683. /**
  7684. * Observable event triggered each time the canvas gains focus
  7685. */
  7686. onCanvasFocusObservable: Observable<Engine>;
  7687. /**
  7688. * Observable event triggered each time the canvas receives pointerout event
  7689. */
  7690. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7691. /**
  7692. * Observable event triggered before each texture is initialized
  7693. */
  7694. onBeforeTextureInitObservable: Observable<Texture>;
  7695. private _vrDisplay;
  7696. private _vrSupported;
  7697. private _oldSize;
  7698. private _oldHardwareScaleFactor;
  7699. private _vrExclusivePointerMode;
  7700. private _webVRInitPromise;
  7701. /**
  7702. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7703. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7704. */
  7705. readonly isInVRExclusivePointerMode: boolean;
  7706. /**
  7707. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7708. */
  7709. disableUniformBuffers: boolean;
  7710. /** @hidden */
  7711. _uniformBuffers: UniformBuffer[];
  7712. /**
  7713. * Gets a boolean indicating that the engine supports uniform buffers
  7714. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7715. */
  7716. readonly supportsUniformBuffers: boolean;
  7717. /**
  7718. * Observable raised when the engine begins a new frame
  7719. */
  7720. onBeginFrameObservable: Observable<Engine>;
  7721. /**
  7722. * Observable raised when the engine ends the current frame
  7723. */
  7724. onEndFrameObservable: Observable<Engine>;
  7725. /**
  7726. * Observable raised when the engine is about to compile a shader
  7727. */
  7728. onBeforeShaderCompilationObservable: Observable<Engine>;
  7729. /**
  7730. * Observable raised when the engine has jsut compiled a shader
  7731. */
  7732. onAfterShaderCompilationObservable: Observable<Engine>;
  7733. /** @hidden */
  7734. _gl: WebGLRenderingContext;
  7735. private _renderingCanvas;
  7736. private _windowIsBackground;
  7737. private _webGLVersion;
  7738. /**
  7739. * Gets a boolean indicating that only power of 2 textures are supported
  7740. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7741. */
  7742. readonly needPOTTextures: boolean;
  7743. /** @hidden */
  7744. _badOS: boolean;
  7745. /** @hidden */
  7746. _badDesktopOS: boolean;
  7747. /**
  7748. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7749. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7750. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7751. */
  7752. disableTextureBindingOptimization: boolean;
  7753. /**
  7754. * Gets the audio engine
  7755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7756. * @ignorenaming
  7757. */
  7758. static audioEngine: AudioEngine;
  7759. private _onFocus;
  7760. private _onBlur;
  7761. private _onCanvasPointerOut;
  7762. private _onCanvasBlur;
  7763. private _onCanvasFocus;
  7764. private _onFullscreenChange;
  7765. private _onPointerLockChange;
  7766. private _onVRDisplayPointerRestricted;
  7767. private _onVRDisplayPointerUnrestricted;
  7768. private _onVrDisplayConnect;
  7769. private _onVrDisplayDisconnect;
  7770. private _onVrDisplayPresentChange;
  7771. /**
  7772. * Observable signaled when VR display mode changes
  7773. */
  7774. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7775. /**
  7776. * Observable signaled when VR request present is complete
  7777. */
  7778. onVRRequestPresentComplete: Observable<boolean>;
  7779. /**
  7780. * Observable signaled when VR request present starts
  7781. */
  7782. onVRRequestPresentStart: Observable<Engine>;
  7783. private _hardwareScalingLevel;
  7784. /** @hidden */
  7785. protected _caps: EngineCapabilities;
  7786. private _pointerLockRequested;
  7787. private _isStencilEnable;
  7788. private _colorWrite;
  7789. private _loadingScreen;
  7790. /** @hidden */
  7791. _drawCalls: PerfCounter;
  7792. /** @hidden */
  7793. _textureCollisions: PerfCounter;
  7794. private _glVersion;
  7795. private _glRenderer;
  7796. private _glVendor;
  7797. private _videoTextureSupported;
  7798. private _renderingQueueLaunched;
  7799. private _activeRenderLoops;
  7800. private _deterministicLockstep;
  7801. private _lockstepMaxSteps;
  7802. /**
  7803. * Observable signaled when a context lost event is raised
  7804. */
  7805. onContextLostObservable: Observable<Engine>;
  7806. /**
  7807. * Observable signaled when a context restored event is raised
  7808. */
  7809. onContextRestoredObservable: Observable<Engine>;
  7810. private _onContextLost;
  7811. private _onContextRestored;
  7812. private _contextWasLost;
  7813. private _doNotHandleContextLost;
  7814. /**
  7815. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7817. */
  7818. doNotHandleContextLost: boolean;
  7819. private _performanceMonitor;
  7820. private _fps;
  7821. private _deltaTime;
  7822. /**
  7823. * Turn this value on if you want to pause FPS computation when in background
  7824. */
  7825. disablePerformanceMonitorInBackground: boolean;
  7826. /**
  7827. * Gets the performance monitor attached to this engine
  7828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7829. */
  7830. readonly performanceMonitor: PerformanceMonitor;
  7831. /** @hidden */
  7832. protected _depthCullingState: _DepthCullingState;
  7833. /** @hidden */
  7834. protected _stencilState: _StencilState;
  7835. /** @hidden */
  7836. protected _alphaState: _AlphaState;
  7837. /** @hidden */
  7838. protected _alphaMode: number;
  7839. protected _internalTexturesCache: InternalTexture[];
  7840. /** @hidden */
  7841. protected _activeChannel: number;
  7842. private _currentTextureChannel;
  7843. /** @hidden */
  7844. protected _boundTexturesCache: {
  7845. [key: string]: Nullable<InternalTexture>;
  7846. };
  7847. /** @hidden */
  7848. protected _currentEffect: Nullable<Effect>;
  7849. /** @hidden */
  7850. protected _currentProgram: Nullable<WebGLProgram>;
  7851. private _compiledEffects;
  7852. private _vertexAttribArraysEnabled;
  7853. /** @hidden */
  7854. protected _cachedViewport: Nullable<Viewport>;
  7855. private _cachedVertexArrayObject;
  7856. /** @hidden */
  7857. protected _cachedVertexBuffers: any;
  7858. /** @hidden */
  7859. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7860. /** @hidden */
  7861. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7862. /** @hidden */
  7863. protected _currentRenderTarget: Nullable<InternalTexture>;
  7864. private _uintIndicesCurrentlySet;
  7865. private _currentBoundBuffer;
  7866. /** @hidden */
  7867. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7868. private _currentBufferPointers;
  7869. private _currentInstanceLocations;
  7870. private _currentInstanceBuffers;
  7871. private _textureUnits;
  7872. private _firstBoundInternalTextureTracker;
  7873. private _lastBoundInternalTextureTracker;
  7874. private _workingCanvas;
  7875. private _workingContext;
  7876. private _rescalePostProcess;
  7877. private _dummyFramebuffer;
  7878. private _externalData;
  7879. private _bindedRenderFunction;
  7880. private _vaoRecordInProgress;
  7881. private _mustWipeVertexAttributes;
  7882. private _emptyTexture;
  7883. private _emptyCubeTexture;
  7884. private _emptyTexture3D;
  7885. private _frameHandler;
  7886. private _nextFreeTextureSlots;
  7887. private _maxSimultaneousTextures;
  7888. private _activeRequests;
  7889. private _texturesSupported;
  7890. private _textureFormatInUse;
  7891. /**
  7892. * Gets the list of texture formats supported
  7893. */
  7894. readonly texturesSupported: Array<string>;
  7895. /**
  7896. * Gets the list of texture formats in use
  7897. */
  7898. readonly textureFormatInUse: Nullable<string>;
  7899. /**
  7900. * Gets the current viewport
  7901. */
  7902. readonly currentViewport: Nullable<Viewport>;
  7903. /**
  7904. * Gets the default empty texture
  7905. */
  7906. readonly emptyTexture: InternalTexture;
  7907. /**
  7908. * Gets the default empty 3D texture
  7909. */
  7910. readonly emptyTexture3D: InternalTexture;
  7911. /**
  7912. * Gets the default empty cube texture
  7913. */
  7914. readonly emptyCubeTexture: InternalTexture;
  7915. /**
  7916. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7917. */
  7918. readonly premultipliedAlpha: boolean;
  7919. /**
  7920. * Creates a new engine
  7921. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7922. * @param antialias defines enable antialiasing (default: false)
  7923. * @param options defines further options to be sent to the getContext() function
  7924. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7925. */
  7926. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7927. private _rebuildInternalTextures;
  7928. private _rebuildEffects;
  7929. private _rebuildBuffers;
  7930. private _initGLContext;
  7931. /**
  7932. * Gets version of the current webGL context
  7933. */
  7934. readonly webGLVersion: number;
  7935. /**
  7936. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7937. */
  7938. readonly isStencilEnable: boolean;
  7939. private _prepareWorkingCanvas;
  7940. /**
  7941. * Reset the texture cache to empty state
  7942. */
  7943. resetTextureCache(): void;
  7944. /**
  7945. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7947. * @returns true if engine is in deterministic lock step mode
  7948. */
  7949. isDeterministicLockStep(): boolean;
  7950. /**
  7951. * Gets the max steps when engine is running in deterministic lock step
  7952. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7953. * @returns the max steps
  7954. */
  7955. getLockstepMaxSteps(): number;
  7956. /**
  7957. * Gets an object containing information about the current webGL context
  7958. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7959. */
  7960. getGlInfo(): {
  7961. vendor: string;
  7962. renderer: string;
  7963. version: string;
  7964. };
  7965. /**
  7966. * Gets current aspect ratio
  7967. * @param camera defines the camera to use to get the aspect ratio
  7968. * @param useScreen defines if screen size must be used (or the current render target if any)
  7969. * @returns a number defining the aspect ratio
  7970. */
  7971. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7972. /**
  7973. * Gets current screen aspect ratio
  7974. * @returns a number defining the aspect ratio
  7975. */
  7976. getScreenAspectRatio(): number;
  7977. /**
  7978. * Gets the current render width
  7979. * @param useScreen defines if screen size must be used (or the current render target if any)
  7980. * @returns a number defining the current render width
  7981. */
  7982. getRenderWidth(useScreen?: boolean): number;
  7983. /**
  7984. * Gets the current render height
  7985. * @param useScreen defines if screen size must be used (or the current render target if any)
  7986. * @returns a number defining the current render height
  7987. */
  7988. getRenderHeight(useScreen?: boolean): number;
  7989. /**
  7990. * Gets the HTML canvas attached with the current webGL context
  7991. * @returns a HTML canvas
  7992. */
  7993. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7994. /**
  7995. * Gets the client rect of the HTML canvas attached with the current webGL context
  7996. * @returns a client rectanglee
  7997. */
  7998. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7999. /**
  8000. * Defines the hardware scaling level.
  8001. * By default the hardware scaling level is computed from the window device ratio.
  8002. * 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.
  8003. * @param level defines the level to use
  8004. */
  8005. setHardwareScalingLevel(level: number): void;
  8006. /**
  8007. * Gets the current hardware scaling level.
  8008. * By default the hardware scaling level is computed from the window device ratio.
  8009. * 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.
  8010. * @returns a number indicating the current hardware scaling level
  8011. */
  8012. getHardwareScalingLevel(): number;
  8013. /**
  8014. * Gets the list of loaded textures
  8015. * @returns an array containing all loaded textures
  8016. */
  8017. getLoadedTexturesCache(): InternalTexture[];
  8018. /**
  8019. * Gets the object containing all engine capabilities
  8020. * @returns the EngineCapabilities object
  8021. */
  8022. getCaps(): EngineCapabilities;
  8023. /** @hidden */
  8024. readonly drawCalls: number;
  8025. /** @hidden */
  8026. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  8027. /**
  8028. * Gets the current depth function
  8029. * @returns a number defining the depth function
  8030. */
  8031. getDepthFunction(): Nullable<number>;
  8032. /**
  8033. * Sets the current depth function
  8034. * @param depthFunc defines the function to use
  8035. */
  8036. setDepthFunction(depthFunc: number): void;
  8037. /**
  8038. * Sets the current depth function to GREATER
  8039. */
  8040. setDepthFunctionToGreater(): void;
  8041. /**
  8042. * Sets the current depth function to GEQUAL
  8043. */
  8044. setDepthFunctionToGreaterOrEqual(): void;
  8045. /**
  8046. * Sets the current depth function to LESS
  8047. */
  8048. setDepthFunctionToLess(): void;
  8049. /**
  8050. * Sets the current depth function to LEQUAL
  8051. */
  8052. setDepthFunctionToLessOrEqual(): void;
  8053. /**
  8054. * Gets a boolean indicating if stencil buffer is enabled
  8055. * @returns the current stencil buffer state
  8056. */
  8057. getStencilBuffer(): boolean;
  8058. /**
  8059. * Enable or disable the stencil buffer
  8060. * @param enable defines if the stencil buffer must be enabled or disabled
  8061. */
  8062. setStencilBuffer(enable: boolean): void;
  8063. /**
  8064. * Gets the current stencil mask
  8065. * @returns a number defining the new stencil mask to use
  8066. */
  8067. getStencilMask(): number;
  8068. /**
  8069. * Sets the current stencil mask
  8070. * @param mask defines the new stencil mask to use
  8071. */
  8072. setStencilMask(mask: number): void;
  8073. /**
  8074. * Gets the current stencil function
  8075. * @returns a number defining the stencil function to use
  8076. */
  8077. getStencilFunction(): number;
  8078. /**
  8079. * Gets the current stencil reference value
  8080. * @returns a number defining the stencil reference value to use
  8081. */
  8082. getStencilFunctionReference(): number;
  8083. /**
  8084. * Gets the current stencil mask
  8085. * @returns a number defining the stencil mask to use
  8086. */
  8087. getStencilFunctionMask(): number;
  8088. /**
  8089. * Sets the current stencil function
  8090. * @param stencilFunc defines the new stencil function to use
  8091. */
  8092. setStencilFunction(stencilFunc: number): void;
  8093. /**
  8094. * Sets the current stencil reference
  8095. * @param reference defines the new stencil reference to use
  8096. */
  8097. setStencilFunctionReference(reference: number): void;
  8098. /**
  8099. * Sets the current stencil mask
  8100. * @param mask defines the new stencil mask to use
  8101. */
  8102. setStencilFunctionMask(mask: number): void;
  8103. /**
  8104. * Gets the current stencil operation when stencil fails
  8105. * @returns a number defining stencil operation to use when stencil fails
  8106. */
  8107. getStencilOperationFail(): number;
  8108. /**
  8109. * Gets the current stencil operation when depth fails
  8110. * @returns a number defining stencil operation to use when depth fails
  8111. */
  8112. getStencilOperationDepthFail(): number;
  8113. /**
  8114. * Gets the current stencil operation when stencil passes
  8115. * @returns a number defining stencil operation to use when stencil passes
  8116. */
  8117. getStencilOperationPass(): number;
  8118. /**
  8119. * Sets the stencil operation to use when stencil fails
  8120. * @param operation defines the stencil operation to use when stencil fails
  8121. */
  8122. setStencilOperationFail(operation: number): void;
  8123. /**
  8124. * Sets the stencil operation to use when depth fails
  8125. * @param operation defines the stencil operation to use when depth fails
  8126. */
  8127. setStencilOperationDepthFail(operation: number): void;
  8128. /**
  8129. * Sets the stencil operation to use when stencil passes
  8130. * @param operation defines the stencil operation to use when stencil passes
  8131. */
  8132. setStencilOperationPass(operation: number): void;
  8133. /**
  8134. * Sets a boolean indicating if the dithering state is enabled or disabled
  8135. * @param value defines the dithering state
  8136. */
  8137. setDitheringState(value: boolean): void;
  8138. /**
  8139. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8140. * @param value defines the rasterizer state
  8141. */
  8142. setRasterizerState(value: boolean): void;
  8143. /**
  8144. * stop executing a render loop function and remove it from the execution array
  8145. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8146. */
  8147. stopRenderLoop(renderFunction?: () => void): void;
  8148. /** @hidden */
  8149. _renderLoop(): void;
  8150. /**
  8151. * Register and execute a render loop. The engine can have more than one render function
  8152. * @param renderFunction defines the function to continuously execute
  8153. */
  8154. runRenderLoop(renderFunction: () => void): void;
  8155. /**
  8156. * Toggle full screen mode
  8157. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8158. * @param options defines an option object to be sent to the requestFullscreen function
  8159. */
  8160. switchFullscreen(requestPointerLock: boolean): void;
  8161. /**
  8162. * Clear the current render buffer or the current render target (if any is set up)
  8163. * @param color defines the color to use
  8164. * @param backBuffer defines if the back buffer must be cleared
  8165. * @param depth defines if the depth buffer must be cleared
  8166. * @param stencil defines if the stencil buffer must be cleared
  8167. */
  8168. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8169. /**
  8170. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8171. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8172. * @param y defines the y-coordinate of the corner of the clear rectangle
  8173. * @param width defines the width of the clear rectangle
  8174. * @param height defines the height of the clear rectangle
  8175. * @param clearColor defines the clear color
  8176. */
  8177. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8178. private _viewportCached;
  8179. /** @hidden */
  8180. _viewport(x: number, y: number, width: number, height: number): void;
  8181. /**
  8182. * Set the WebGL's viewport
  8183. * @param viewport defines the viewport element to be used
  8184. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8185. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8186. */
  8187. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8188. /**
  8189. * Directly set the WebGL Viewport
  8190. * @param x defines the x coordinate of the viewport (in screen space)
  8191. * @param y defines the y coordinate of the viewport (in screen space)
  8192. * @param width defines the width of the viewport (in screen space)
  8193. * @param height defines the height of the viewport (in screen space)
  8194. * @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
  8195. */
  8196. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8197. /**
  8198. * Begin a new frame
  8199. */
  8200. beginFrame(): void;
  8201. /**
  8202. * Enf the current frame
  8203. */
  8204. endFrame(): void;
  8205. /**
  8206. * Resize the view according to the canvas' size
  8207. */
  8208. resize(): void;
  8209. /**
  8210. * Force a specific size of the canvas
  8211. * @param width defines the new canvas' width
  8212. * @param height defines the new canvas' height
  8213. */
  8214. setSize(width: number, height: number): void;
  8215. /**
  8216. * Gets a boolean indicating if a webVR device was detected
  8217. * @returns true if a webVR device was detected
  8218. */
  8219. isVRDevicePresent(): boolean;
  8220. /**
  8221. * Gets the current webVR device
  8222. * @returns the current webVR device (or null)
  8223. */
  8224. getVRDevice(): any;
  8225. /**
  8226. * Initializes a webVR display and starts listening to display change events
  8227. * The onVRDisplayChangedObservable will be notified upon these changes
  8228. * @returns The onVRDisplayChangedObservable
  8229. */
  8230. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8231. /**
  8232. * Initializes a webVR display and starts listening to display change events
  8233. * The onVRDisplayChangedObservable will be notified upon these changes
  8234. * @returns A promise containing a VRDisplay and if vr is supported
  8235. */
  8236. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8237. /**
  8238. * Call this function to switch to webVR mode
  8239. * Will do nothing if webVR is not supported or if there is no webVR device
  8240. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8241. */
  8242. enableVR(): void;
  8243. /**
  8244. * Call this function to leave webVR mode
  8245. * Will do nothing if webVR is not supported or if there is no webVR device
  8246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8247. */
  8248. disableVR(): void;
  8249. private _onVRFullScreenTriggered;
  8250. private _getVRDisplaysAsync;
  8251. /**
  8252. * Binds the frame buffer to the specified texture.
  8253. * @param texture The texture to render to or null for the default canvas
  8254. * @param faceIndex The face of the texture to render to in case of cube texture
  8255. * @param requiredWidth The width of the target to render to
  8256. * @param requiredHeight The height of the target to render to
  8257. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8258. * @param depthStencilTexture The depth stencil texture to use to render
  8259. * @param lodLevel defines le lod level to bind to the frame buffer
  8260. */
  8261. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8262. private bindUnboundFramebuffer;
  8263. /**
  8264. * Unbind the current render target texture from the webGL context
  8265. * @param texture defines the render target texture to unbind
  8266. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8267. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8268. */
  8269. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8270. /**
  8271. * Unbind a list of render target textures from the webGL context
  8272. * This is used only when drawBuffer extension or webGL2 are active
  8273. * @param textures defines the render target textures to unbind
  8274. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8275. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8276. */
  8277. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8278. /**
  8279. * Force the mipmap generation for the given render target texture
  8280. * @param texture defines the render target texture to use
  8281. */
  8282. generateMipMapsForCubemap(texture: InternalTexture): void;
  8283. /**
  8284. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8285. */
  8286. flushFramebuffer(): void;
  8287. /**
  8288. * Unbind the current render target and bind the default framebuffer
  8289. */
  8290. restoreDefaultFramebuffer(): void;
  8291. /**
  8292. * Create an uniform buffer
  8293. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8294. * @param elements defines the content of the uniform buffer
  8295. * @returns the webGL uniform buffer
  8296. */
  8297. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8298. /**
  8299. * Create a dynamic uniform buffer
  8300. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8301. * @param elements defines the content of the uniform buffer
  8302. * @returns the webGL uniform buffer
  8303. */
  8304. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8305. /**
  8306. * Update an existing uniform buffer
  8307. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8308. * @param uniformBuffer defines the target uniform buffer
  8309. * @param elements defines the content to update
  8310. * @param offset defines the offset in the uniform buffer where update should start
  8311. * @param count defines the size of the data to update
  8312. */
  8313. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8314. private _resetVertexBufferBinding;
  8315. /**
  8316. * Creates a vertex buffer
  8317. * @param data the data for the vertex buffer
  8318. * @returns the new WebGL static buffer
  8319. */
  8320. createVertexBuffer(data: DataArray): WebGLBuffer;
  8321. /**
  8322. * Creates a dynamic vertex buffer
  8323. * @param data the data for the dynamic vertex buffer
  8324. * @returns the new WebGL dynamic buffer
  8325. */
  8326. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8327. /**
  8328. * Update a dynamic index buffer
  8329. * @param indexBuffer defines the target index buffer
  8330. * @param indices defines the data to update
  8331. * @param offset defines the offset in the target index buffer where update should start
  8332. */
  8333. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8334. /**
  8335. * Updates a dynamic vertex buffer.
  8336. * @param vertexBuffer the vertex buffer to update
  8337. * @param data the data used to update the vertex buffer
  8338. * @param byteOffset the byte offset of the data
  8339. * @param byteLength the byte length of the data
  8340. */
  8341. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8342. private _resetIndexBufferBinding;
  8343. /**
  8344. * Creates a new index buffer
  8345. * @param indices defines the content of the index buffer
  8346. * @param updatable defines if the index buffer must be updatable
  8347. * @returns a new webGL buffer
  8348. */
  8349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8350. /**
  8351. * Bind a webGL buffer to the webGL context
  8352. * @param buffer defines the buffer to bind
  8353. */
  8354. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8355. /**
  8356. * Bind an uniform buffer to the current webGL context
  8357. * @param buffer defines the buffer to bind
  8358. */
  8359. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8360. /**
  8361. * Bind a buffer to the current webGL context at a given location
  8362. * @param buffer defines the buffer to bind
  8363. * @param location defines the index where to bind the buffer
  8364. */
  8365. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8366. /**
  8367. * Bind a specific block at a given index in a specific shader program
  8368. * @param shaderProgram defines the shader program
  8369. * @param blockName defines the block name
  8370. * @param index defines the index where to bind the block
  8371. */
  8372. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8373. private bindIndexBuffer;
  8374. private bindBuffer;
  8375. /**
  8376. * update the bound buffer with the given data
  8377. * @param data defines the data to update
  8378. */
  8379. updateArrayBuffer(data: Float32Array): void;
  8380. private _vertexAttribPointer;
  8381. private _bindIndexBufferWithCache;
  8382. private _bindVertexBuffersAttributes;
  8383. /**
  8384. * Records a vertex array object
  8385. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8386. * @param vertexBuffers defines the list of vertex buffers to store
  8387. * @param indexBuffer defines the index buffer to store
  8388. * @param effect defines the effect to store
  8389. * @returns the new vertex array object
  8390. */
  8391. recordVertexArrayObject(vertexBuffers: {
  8392. [key: string]: VertexBuffer;
  8393. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8394. /**
  8395. * Bind a specific vertex array object
  8396. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8397. * @param vertexArrayObject defines the vertex array object to bind
  8398. * @param indexBuffer defines the index buffer to bind
  8399. */
  8400. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8401. /**
  8402. * Bind webGl buffers directly to the webGL context
  8403. * @param vertexBuffer defines the vertex buffer to bind
  8404. * @param indexBuffer defines the index buffer to bind
  8405. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8406. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8407. * @param effect defines the effect associated with the vertex buffer
  8408. */
  8409. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8410. private _unbindVertexArrayObject;
  8411. /**
  8412. * Bind a list of vertex buffers to the webGL context
  8413. * @param vertexBuffers defines the list of vertex buffers to bind
  8414. * @param indexBuffer defines the index buffer to bind
  8415. * @param effect defines the effect associated with the vertex buffers
  8416. */
  8417. bindBuffers(vertexBuffers: {
  8418. [key: string]: Nullable<VertexBuffer>;
  8419. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8420. /**
  8421. * Unbind all instance attributes
  8422. */
  8423. unbindInstanceAttributes(): void;
  8424. /**
  8425. * Release and free the memory of a vertex array object
  8426. * @param vao defines the vertex array object to delete
  8427. */
  8428. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8429. /** @hidden */
  8430. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8431. /**
  8432. * Creates a webGL buffer to use with instanciation
  8433. * @param capacity defines the size of the buffer
  8434. * @returns the webGL buffer
  8435. */
  8436. createInstancesBuffer(capacity: number): WebGLBuffer;
  8437. /**
  8438. * Delete a webGL buffer used with instanciation
  8439. * @param buffer defines the webGL buffer to delete
  8440. */
  8441. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8442. /**
  8443. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8444. * @param instancesBuffer defines the webGL buffer to update and bind
  8445. * @param data defines the data to store in the buffer
  8446. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8447. */
  8448. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8449. /**
  8450. * Apply all cached states (depth, culling, stencil and alpha)
  8451. */
  8452. applyStates(): void;
  8453. /**
  8454. * Send a draw order
  8455. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8456. * @param indexStart defines the starting index
  8457. * @param indexCount defines the number of index to draw
  8458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8459. */
  8460. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8461. /**
  8462. * Draw a list of points
  8463. * @param verticesStart defines the index of first vertex to draw
  8464. * @param verticesCount defines the count of vertices to draw
  8465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8466. */
  8467. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8468. /**
  8469. * Draw a list of unindexed primitives
  8470. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8471. * @param verticesStart defines the index of first vertex to draw
  8472. * @param verticesCount defines the count of vertices to draw
  8473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8474. */
  8475. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8476. /**
  8477. * Draw a list of indexed primitives
  8478. * @param fillMode defines the primitive to use
  8479. * @param indexStart defines the starting index
  8480. * @param indexCount defines the number of index to draw
  8481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8482. */
  8483. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8484. /**
  8485. * Draw a list of unindexed primitives
  8486. * @param fillMode defines the primitive to use
  8487. * @param verticesStart defines the index of first vertex to draw
  8488. * @param verticesCount defines the count of vertices to draw
  8489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8490. */
  8491. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8492. private _drawMode;
  8493. /** @hidden */
  8494. _releaseEffect(effect: Effect): void;
  8495. /** @hidden */
  8496. _deleteProgram(program: WebGLProgram): void;
  8497. /**
  8498. * Create a new effect (used to store vertex/fragment shaders)
  8499. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8500. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8501. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8502. * @param samplers defines an array of string used to represent textures
  8503. * @param defines defines the string containing the defines to use to compile the shaders
  8504. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8505. * @param onCompiled defines a function to call when the effect creation is successful
  8506. * @param onError defines a function to call when the effect creation has failed
  8507. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8508. * @returns the new Effect
  8509. */
  8510. 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;
  8511. private _compileShader;
  8512. private _compileRawShader;
  8513. /**
  8514. * Directly creates a webGL program
  8515. * @param vertexCode defines the vertex shader code to use
  8516. * @param fragmentCode defines the fragment shader code to use
  8517. * @param context defines the webGL context to use (if not set, the current one will be used)
  8518. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8519. * @returns the new webGL program
  8520. */
  8521. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8522. /**
  8523. * Creates a webGL program
  8524. * @param vertexCode defines the vertex shader code to use
  8525. * @param fragmentCode defines the fragment shader code to use
  8526. * @param defines defines the string containing the defines to use to compile the shaders
  8527. * @param context defines the webGL context to use (if not set, the current one will be used)
  8528. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8529. * @returns the new webGL program
  8530. */
  8531. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8532. private _createShaderProgram;
  8533. /**
  8534. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8535. * @param shaderProgram defines the webGL program to use
  8536. * @param uniformsNames defines the list of uniform names
  8537. * @returns an array of webGL uniform locations
  8538. */
  8539. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8540. /**
  8541. * Gets the lsit of active attributes for a given webGL program
  8542. * @param shaderProgram defines the webGL program to use
  8543. * @param attributesNames defines the list of attribute names to get
  8544. * @returns an array of indices indicating the offset of each attribute
  8545. */
  8546. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8547. /**
  8548. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8549. * @param effect defines the effect to activate
  8550. */
  8551. enableEffect(effect: Nullable<Effect>): void;
  8552. /**
  8553. * Set the value of an uniform to an array of int32
  8554. * @param uniform defines the webGL uniform location where to store the value
  8555. * @param array defines the array of int32 to store
  8556. */
  8557. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8558. /**
  8559. * Set the value of an uniform to an array of int32 (stored as vec2)
  8560. * @param uniform defines the webGL uniform location where to store the value
  8561. * @param array defines the array of int32 to store
  8562. */
  8563. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8564. /**
  8565. * Set the value of an uniform to an array of int32 (stored as vec3)
  8566. * @param uniform defines the webGL uniform location where to store the value
  8567. * @param array defines the array of int32 to store
  8568. */
  8569. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8570. /**
  8571. * Set the value of an uniform to an array of int32 (stored as vec4)
  8572. * @param uniform defines the webGL uniform location where to store the value
  8573. * @param array defines the array of int32 to store
  8574. */
  8575. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8576. /**
  8577. * Set the value of an uniform to an array of float32
  8578. * @param uniform defines the webGL uniform location where to store the value
  8579. * @param array defines the array of float32 to store
  8580. */
  8581. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8582. /**
  8583. * Set the value of an uniform to an array of float32 (stored as vec2)
  8584. * @param uniform defines the webGL uniform location where to store the value
  8585. * @param array defines the array of float32 to store
  8586. */
  8587. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8588. /**
  8589. * Set the value of an uniform to an array of float32 (stored as vec3)
  8590. * @param uniform defines the webGL uniform location where to store the value
  8591. * @param array defines the array of float32 to store
  8592. */
  8593. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8594. /**
  8595. * Set the value of an uniform to an array of float32 (stored as vec4)
  8596. * @param uniform defines the webGL uniform location where to store the value
  8597. * @param array defines the array of float32 to store
  8598. */
  8599. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8600. /**
  8601. * Set the value of an uniform to an array of number
  8602. * @param uniform defines the webGL uniform location where to store the value
  8603. * @param array defines the array of number to store
  8604. */
  8605. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8606. /**
  8607. * Set the value of an uniform to an array of number (stored as vec2)
  8608. * @param uniform defines the webGL uniform location where to store the value
  8609. * @param array defines the array of number to store
  8610. */
  8611. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8612. /**
  8613. * Set the value of an uniform to an array of number (stored as vec3)
  8614. * @param uniform defines the webGL uniform location where to store the value
  8615. * @param array defines the array of number to store
  8616. */
  8617. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8618. /**
  8619. * Set the value of an uniform to an array of number (stored as vec4)
  8620. * @param uniform defines the webGL uniform location where to store the value
  8621. * @param array defines the array of number to store
  8622. */
  8623. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8624. /**
  8625. * Set the value of an uniform to an array of float32 (stored as matrices)
  8626. * @param uniform defines the webGL uniform location where to store the value
  8627. * @param matrices defines the array of float32 to store
  8628. */
  8629. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8630. /**
  8631. * Set the value of an uniform to a matrix
  8632. * @param uniform defines the webGL uniform location where to store the value
  8633. * @param matrix defines the matrix to store
  8634. */
  8635. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8636. /**
  8637. * Set the value of an uniform to a matrix (3x3)
  8638. * @param uniform defines the webGL uniform location where to store the value
  8639. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8640. */
  8641. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8642. /**
  8643. * Set the value of an uniform to a matrix (2x2)
  8644. * @param uniform defines the webGL uniform location where to store the value
  8645. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8646. */
  8647. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8648. /**
  8649. * Set the value of an uniform to a number (int)
  8650. * @param uniform defines the webGL uniform location where to store the value
  8651. * @param value defines the int number to store
  8652. */
  8653. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8654. /**
  8655. * Set the value of an uniform to a number (float)
  8656. * @param uniform defines the webGL uniform location where to store the value
  8657. * @param value defines the float number to store
  8658. */
  8659. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8660. /**
  8661. * Set the value of an uniform to a vec2
  8662. * @param uniform defines the webGL uniform location where to store the value
  8663. * @param x defines the 1st component of the value
  8664. * @param y defines the 2nd component of the value
  8665. */
  8666. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8667. /**
  8668. * Set the value of an uniform to a vec3
  8669. * @param uniform defines the webGL uniform location where to store the value
  8670. * @param x defines the 1st component of the value
  8671. * @param y defines the 2nd component of the value
  8672. * @param z defines the 3rd component of the value
  8673. */
  8674. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8675. /**
  8676. * Set the value of an uniform to a boolean
  8677. * @param uniform defines the webGL uniform location where to store the value
  8678. * @param bool defines the boolean to store
  8679. */
  8680. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8681. /**
  8682. * Set the value of an uniform to a vec4
  8683. * @param uniform defines the webGL uniform location where to store the value
  8684. * @param x defines the 1st component of the value
  8685. * @param y defines the 2nd component of the value
  8686. * @param z defines the 3rd component of the value
  8687. * @param w defines the 4th component of the value
  8688. */
  8689. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8690. /**
  8691. * Set the value of an uniform to a Color3
  8692. * @param uniform defines the webGL uniform location where to store the value
  8693. * @param color3 defines the color to store
  8694. */
  8695. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8696. /**
  8697. * Set the value of an uniform to a Color3 and an alpha value
  8698. * @param uniform defines the webGL uniform location where to store the value
  8699. * @param color3 defines the color to store
  8700. * @param alpha defines the alpha component to store
  8701. */
  8702. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8703. /**
  8704. * Sets a Color4 on a uniform variable
  8705. * @param uniform defines the uniform location
  8706. * @param color4 defines the value to be set
  8707. */
  8708. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8709. /**
  8710. * Set various states to the webGL context
  8711. * @param culling defines backface culling state
  8712. * @param zOffset defines the value to apply to zOffset (0 by default)
  8713. * @param force defines if states must be applied even if cache is up to date
  8714. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8715. */
  8716. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8717. /**
  8718. * Set the z offset to apply to current rendering
  8719. * @param value defines the offset to apply
  8720. */
  8721. setZOffset(value: number): void;
  8722. /**
  8723. * Gets the current value of the zOffset
  8724. * @returns the current zOffset state
  8725. */
  8726. getZOffset(): number;
  8727. /**
  8728. * Enable or disable depth buffering
  8729. * @param enable defines the state to set
  8730. */
  8731. setDepthBuffer(enable: boolean): void;
  8732. /**
  8733. * Gets a boolean indicating if depth writing is enabled
  8734. * @returns the current depth writing state
  8735. */
  8736. getDepthWrite(): boolean;
  8737. /**
  8738. * Enable or disable depth writing
  8739. * @param enable defines the state to set
  8740. */
  8741. setDepthWrite(enable: boolean): void;
  8742. /**
  8743. * Enable or disable color writing
  8744. * @param enable defines the state to set
  8745. */
  8746. setColorWrite(enable: boolean): void;
  8747. /**
  8748. * Gets a boolean indicating if color writing is enabled
  8749. * @returns the current color writing state
  8750. */
  8751. getColorWrite(): boolean;
  8752. /**
  8753. * Sets alpha constants used by some alpha blending modes
  8754. * @param r defines the red component
  8755. * @param g defines the green component
  8756. * @param b defines the blue component
  8757. * @param a defines the alpha component
  8758. */
  8759. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8760. /**
  8761. * Sets the current alpha mode
  8762. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8765. */
  8766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8767. /**
  8768. * Gets the current alpha mode
  8769. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8770. * @returns the current alpha mode
  8771. */
  8772. getAlphaMode(): number;
  8773. /**
  8774. * Clears the list of texture accessible through engine.
  8775. * This can help preventing texture load conflict due to name collision.
  8776. */
  8777. clearInternalTexturesCache(): void;
  8778. /**
  8779. * Force the entire cache to be cleared
  8780. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8781. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8782. */
  8783. wipeCaches(bruteForce?: boolean): void;
  8784. /**
  8785. * Set the compressed texture format to use, based on the formats you have, and the formats
  8786. * supported by the hardware / browser.
  8787. *
  8788. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8789. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8790. * to API arguments needed to compressed textures. This puts the burden on the container
  8791. * generator to house the arcane code for determining these for current & future formats.
  8792. *
  8793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8795. *
  8796. * Note: The result of this call is not taken into account when a texture is base64.
  8797. *
  8798. * @param formatsAvailable defines the list of those format families you have created
  8799. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8800. *
  8801. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8802. * @returns The extension selected.
  8803. */
  8804. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8805. private _getSamplingParameters;
  8806. private _partialLoadImg;
  8807. private _cascadeLoadImgs;
  8808. /** @hidden */
  8809. _createTexture(): WebGLTexture;
  8810. /**
  8811. * Usually called from BABYLON.Texture.ts.
  8812. * Passed information to create a WebGLTexture
  8813. * @param urlArg defines a value which contains one of the following:
  8814. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8815. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8816. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8818. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8819. * @param scene needed for loading to the correct scene
  8820. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8821. * @param onLoad optional callback to be called upon successful completion
  8822. * @param onError optional callback to be called upon failure
  8823. * @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
  8824. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8825. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8826. * @param forcedExtension defines the extension to use to pick the right loader
  8827. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8828. */
  8829. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  8830. private _rescaleTexture;
  8831. /**
  8832. * Update a raw texture
  8833. * @param texture defines the texture to update
  8834. * @param data defines the data to store in the texture
  8835. * @param format defines the format of the data
  8836. * @param invertY defines if data must be stored with Y axis inverted
  8837. * @param compression defines the compression used (null by default)
  8838. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8839. */
  8840. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8841. /**
  8842. * Creates a raw texture
  8843. * @param data defines the data to store in the texture
  8844. * @param width defines the width of the texture
  8845. * @param height defines the height of the texture
  8846. * @param format defines the format of the data
  8847. * @param generateMipMaps defines if the engine should generate the mip levels
  8848. * @param invertY defines if data must be stored with Y axis inverted
  8849. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8850. * @param compression defines the compression used (null by default)
  8851. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8852. * @returns the raw texture inside an InternalTexture
  8853. */
  8854. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8855. private _unpackFlipYCached;
  8856. /** @hidden */
  8857. _unpackFlipY(value: boolean): void;
  8858. /** @hidden */
  8859. _getUnpackAlignement(): number;
  8860. /**
  8861. * Creates a dynamic texture
  8862. * @param width defines the width of the texture
  8863. * @param height defines the height of the texture
  8864. * @param generateMipMaps defines if the engine should generate the mip levels
  8865. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8866. * @returns the dynamic texture inside an InternalTexture
  8867. */
  8868. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8869. /**
  8870. * Update the sampling mode of a given texture
  8871. * @param samplingMode defines the required sampling mode
  8872. * @param texture defines the texture to update
  8873. */
  8874. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8875. /**
  8876. * Update the content of a dynamic texture
  8877. * @param texture defines the texture to update
  8878. * @param canvas defines the canvas containing the source
  8879. * @param invertY defines if data must be stored with Y axis inverted
  8880. * @param premulAlpha defines if alpha is stored as premultiplied
  8881. * @param format defines the format of the data
  8882. */
  8883. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8884. /**
  8885. * Update a video texture
  8886. * @param texture defines the texture to update
  8887. * @param video defines the video element to use
  8888. * @param invertY defines if data must be stored with Y axis inverted
  8889. */
  8890. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8891. /**
  8892. * Updates a depth texture Comparison Mode and Function.
  8893. * If the comparison Function is equal to 0, the mode will be set to none.
  8894. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8895. * @param texture The texture to set the comparison function for
  8896. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8897. */
  8898. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8899. private _setupDepthStencilTexture;
  8900. /**
  8901. * Creates a depth stencil texture.
  8902. * This is only available in WebGL 2 or with the depth texture extension available.
  8903. * @param size The size of face edge in the texture.
  8904. * @param options The options defining the texture.
  8905. * @returns The texture
  8906. */
  8907. createDepthStencilTexture(size: number | {
  8908. width: number;
  8909. height: number;
  8910. }, options: DepthTextureCreationOptions): InternalTexture;
  8911. /**
  8912. * Creates a depth stencil texture.
  8913. * This is only available in WebGL 2 or with the depth texture extension available.
  8914. * @param size The size of face edge in the texture.
  8915. * @param options The options defining the texture.
  8916. * @returns The texture
  8917. */
  8918. private _createDepthStencilTexture;
  8919. /**
  8920. * Creates a depth stencil cube texture.
  8921. * This is only available in WebGL 2.
  8922. * @param size The size of face edge in the cube texture.
  8923. * @param options The options defining the cube texture.
  8924. * @returns The cube texture
  8925. */
  8926. private _createDepthStencilCubeTexture;
  8927. /**
  8928. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8929. * @param renderTarget The render target to set the frame buffer for
  8930. */
  8931. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8932. /**
  8933. * Creates a new render target texture
  8934. * @param size defines the size of the texture
  8935. * @param options defines the options used to create the texture
  8936. * @returns a new render target texture stored in an InternalTexture
  8937. */
  8938. createRenderTargetTexture(size: number | {
  8939. width: number;
  8940. height: number;
  8941. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8942. /**
  8943. * Create a multi render target texture
  8944. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8945. * @param size defines the size of the texture
  8946. * @param options defines the creation options
  8947. * @returns the cube texture as an InternalTexture
  8948. */
  8949. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8950. private _setupFramebufferDepthAttachments;
  8951. /**
  8952. * Updates the sample count of a render target texture
  8953. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8954. * @param texture defines the texture to update
  8955. * @param samples defines the sample count to set
  8956. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8957. */
  8958. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8959. /**
  8960. * Update the sample count for a given multiple render target texture
  8961. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8962. * @param textures defines the textures to update
  8963. * @param samples defines the sample count to set
  8964. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8965. */
  8966. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8967. /** @hidden */
  8968. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8969. /** @hidden */
  8970. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8971. /** @hidden */
  8972. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8973. /** @hidden */
  8974. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8975. /**
  8976. * Creates a new render target cube texture
  8977. * @param size defines the size of the texture
  8978. * @param options defines the options used to create the texture
  8979. * @returns a new render target cube texture stored in an InternalTexture
  8980. */
  8981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8982. /**
  8983. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8984. * @param rootUrl defines the url where the file to load is located
  8985. * @param scene defines the current scene
  8986. * @param lodScale defines scale to apply to the mip map selection
  8987. * @param lodOffset defines offset to apply to the mip map selection
  8988. * @param onLoad defines an optional callback raised when the texture is loaded
  8989. * @param onError defines an optional callback raised if there is an issue to load the texture
  8990. * @param format defines the format of the data
  8991. * @param forcedExtension defines the extension to use to pick the right loader
  8992. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8993. * @returns the cube texture as an InternalTexture
  8994. */
  8995. 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;
  8996. /**
  8997. * Creates a cube texture
  8998. * @param rootUrl defines the url where the files to load is located
  8999. * @param scene defines the current scene
  9000. * @param files defines the list of files to load (1 per face)
  9001. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  9002. * @param onLoad defines an optional callback raised when the texture is loaded
  9003. * @param onError defines an optional callback raised if there is an issue to load the texture
  9004. * @param format defines the format of the data
  9005. * @param forcedExtension defines the extension to use to pick the right loader
  9006. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  9007. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  9008. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  9009. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  9010. * @returns the cube texture as an InternalTexture
  9011. */
  9012. 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;
  9013. /**
  9014. * @hidden
  9015. */
  9016. _setCubeMapTextureParams(loadMipmap: boolean): void;
  9017. /**
  9018. * Update a raw cube texture
  9019. * @param texture defines the texture to udpdate
  9020. * @param data defines the data to store
  9021. * @param format defines the data format
  9022. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9023. * @param invertY defines if data must be stored with Y axis inverted
  9024. * @param compression defines the compression used (null by default)
  9025. * @param level defines which level of the texture to update
  9026. */
  9027. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  9028. /**
  9029. * Creates a new raw cube texture
  9030. * @param data defines the array of data to use to create each face
  9031. * @param size defines the size of the textures
  9032. * @param format defines the format of the data
  9033. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9034. * @param generateMipMaps defines if the engine should generate the mip levels
  9035. * @param invertY defines if data must be stored with Y axis inverted
  9036. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9037. * @param compression defines the compression used (null by default)
  9038. * @returns the cube texture as an InternalTexture
  9039. */
  9040. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  9041. /**
  9042. * Creates a new raw cube texture from a specified url
  9043. * @param url defines the url where the data is located
  9044. * @param scene defines the current scene
  9045. * @param size defines the size of the textures
  9046. * @param format defines the format of the data
  9047. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9048. * @param noMipmap defines if the engine should avoid generating the mip levels
  9049. * @param callback defines a callback used to extract texture data from loaded data
  9050. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9051. * @param onLoad defines a callback called when texture is loaded
  9052. * @param onError defines a callback called if there is an error
  9053. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9054. * @param invertY defines if data must be stored with Y axis inverted
  9055. * @returns the cube texture as an InternalTexture
  9056. */
  9057. 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;
  9058. /**
  9059. * Update a raw 3D texture
  9060. * @param texture defines the texture to update
  9061. * @param data defines the data to store
  9062. * @param format defines the data format
  9063. * @param invertY defines if data must be stored with Y axis inverted
  9064. * @param compression defines the used compression (can be null)
  9065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9066. */
  9067. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9068. /**
  9069. * Creates a new raw 3D texture
  9070. * @param data defines the data used to create the texture
  9071. * @param width defines the width of the texture
  9072. * @param height defines the height of the texture
  9073. * @param depth defines the depth of the texture
  9074. * @param format defines the format of the texture
  9075. * @param generateMipMaps defines if the engine must generate mip levels
  9076. * @param invertY defines if data must be stored with Y axis inverted
  9077. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9078. * @param compression defines the compressed used (can be null)
  9079. * @param textureType defines the compressed used (can be null)
  9080. * @returns a new raw 3D texture (stored in an InternalTexture)
  9081. */
  9082. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9083. private _prepareWebGLTextureContinuation;
  9084. private _prepareWebGLTexture;
  9085. private _convertRGBtoRGBATextureData;
  9086. /** @hidden */
  9087. _releaseFramebufferObjects(texture: InternalTexture): void;
  9088. /** @hidden */
  9089. _releaseTexture(texture: InternalTexture): void;
  9090. private setProgram;
  9091. private _boundUniforms;
  9092. /**
  9093. * Binds an effect to the webGL context
  9094. * @param effect defines the effect to bind
  9095. */
  9096. bindSamplers(effect: Effect): void;
  9097. private _moveBoundTextureOnTop;
  9098. private _getCorrectTextureChannel;
  9099. private _linkTrackers;
  9100. private _removeDesignatedSlot;
  9101. private _activateCurrentTexture;
  9102. /** @hidden */
  9103. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9104. /** @hidden */
  9105. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9106. /**
  9107. * Sets a texture to the webGL context from a postprocess
  9108. * @param channel defines the channel to use
  9109. * @param postProcess defines the source postprocess
  9110. */
  9111. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9112. /**
  9113. * Binds the output of the passed in post process to the texture channel specified
  9114. * @param channel The channel the texture should be bound to
  9115. * @param postProcess The post process which's output should be bound
  9116. */
  9117. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9118. /**
  9119. * Unbind all textures from the webGL context
  9120. */
  9121. unbindAllTextures(): void;
  9122. /**
  9123. * Sets a texture to the according uniform.
  9124. * @param channel The texture channel
  9125. * @param uniform The uniform to set
  9126. * @param texture The texture to apply
  9127. */
  9128. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9129. /**
  9130. * Sets a depth stencil texture from a render target to the according uniform.
  9131. * @param channel The texture channel
  9132. * @param uniform The uniform to set
  9133. * @param texture The render target texture containing the depth stencil texture to apply
  9134. */
  9135. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9136. private _bindSamplerUniformToChannel;
  9137. private _getTextureWrapMode;
  9138. private _setTexture;
  9139. /**
  9140. * Sets an array of texture to the webGL context
  9141. * @param channel defines the channel where the texture array must be set
  9142. * @param uniform defines the associated uniform location
  9143. * @param textures defines the array of textures to bind
  9144. */
  9145. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9146. /** @hidden */
  9147. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9148. private _setTextureParameterFloat;
  9149. private _setTextureParameterInteger;
  9150. /**
  9151. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9152. * @param x defines the x coordinate of the rectangle where pixels must be read
  9153. * @param y defines the y coordinate of the rectangle where pixels must be read
  9154. * @param width defines the width of the rectangle where pixels must be read
  9155. * @param height defines the height of the rectangle where pixels must be read
  9156. * @returns a Uint8Array containing RGBA colors
  9157. */
  9158. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9159. /**
  9160. * Add an externaly attached data from its key.
  9161. * This method call will fail and return false, if such key already exists.
  9162. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9163. * @param key the unique key that identifies the data
  9164. * @param data the data object to associate to the key for this Engine instance
  9165. * @return true if no such key were already present and the data was added successfully, false otherwise
  9166. */
  9167. addExternalData<T>(key: string, data: T): boolean;
  9168. /**
  9169. * Get an externaly attached data from its key
  9170. * @param key the unique key that identifies the data
  9171. * @return the associated data, if present (can be null), or undefined if not present
  9172. */
  9173. getExternalData<T>(key: string): T;
  9174. /**
  9175. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9176. * @param key the unique key that identifies the data
  9177. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9178. * @return the associated data, can be null if the factory returned null.
  9179. */
  9180. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9181. /**
  9182. * Remove an externaly attached data from the Engine instance
  9183. * @param key the unique key that identifies the data
  9184. * @return true if the data was successfully removed, false if it doesn't exist
  9185. */
  9186. removeExternalData(key: string): boolean;
  9187. /**
  9188. * Unbind all vertex attributes from the webGL context
  9189. */
  9190. unbindAllAttributes(): void;
  9191. /**
  9192. * 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
  9193. */
  9194. releaseEffects(): void;
  9195. /**
  9196. * Dispose and release all associated resources
  9197. */
  9198. dispose(): void;
  9199. /**
  9200. * Display the loading screen
  9201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9202. */
  9203. displayLoadingUI(): void;
  9204. /**
  9205. * Hide the loading screen
  9206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9207. */
  9208. hideLoadingUI(): void;
  9209. /**
  9210. * Gets the current loading screen object
  9211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9212. */
  9213. /**
  9214. * Sets the current loading screen object
  9215. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9216. */
  9217. loadingScreen: ILoadingScreen;
  9218. /**
  9219. * Sets the current loading screen text
  9220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9221. */
  9222. loadingUIText: string;
  9223. /**
  9224. * Sets the current loading screen background color
  9225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9226. */
  9227. loadingUIBackgroundColor: string;
  9228. /**
  9229. * Attach a new callback raised when context lost event is fired
  9230. * @param callback defines the callback to call
  9231. */
  9232. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9233. /**
  9234. * Attach a new callback raised when context restored event is fired
  9235. * @param callback defines the callback to call
  9236. */
  9237. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9238. /**
  9239. * Gets the source code of the vertex shader associated with a specific webGL program
  9240. * @param program defines the program to use
  9241. * @returns a string containing the source code of the vertex shader associated with the program
  9242. */
  9243. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9244. /**
  9245. * Gets the source code of the fragment shader associated with a specific webGL program
  9246. * @param program defines the program to use
  9247. * @returns a string containing the source code of the fragment shader associated with the program
  9248. */
  9249. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9250. /**
  9251. * Get the current error code of the webGL context
  9252. * @returns the error code
  9253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9254. */
  9255. getError(): number;
  9256. /**
  9257. * Gets the current framerate
  9258. * @returns a number representing the framerate
  9259. */
  9260. getFps(): number;
  9261. /**
  9262. * Gets the time spent between current and previous frame
  9263. * @returns a number representing the delta time in ms
  9264. */
  9265. getDeltaTime(): number;
  9266. private _measureFps;
  9267. /** @hidden */
  9268. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9269. private _canRenderToFloatFramebuffer;
  9270. private _canRenderToHalfFloatFramebuffer;
  9271. private _canRenderToFramebuffer;
  9272. /** @hidden */
  9273. _getWebGLTextureType(type: number): number;
  9274. private _getInternalFormat;
  9275. /** @hidden */
  9276. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9277. /** @hidden */
  9278. _getRGBAMultiSampleBufferFormat(type: number): number;
  9279. /** @hidden */
  9280. _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;
  9281. /** @hidden */
  9282. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9283. private _partialLoadFile;
  9284. private _cascadeLoadFiles;
  9285. /**
  9286. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9287. * @returns true if the engine can be created
  9288. * @ignorenaming
  9289. */
  9290. static isSupported(): boolean;
  9291. }
  9292. }
  9293. declare module BABYLON {
  9294. class NullEngineOptions {
  9295. renderWidth: number;
  9296. renderHeight: number;
  9297. textureSize: number;
  9298. deterministicLockstep: boolean;
  9299. lockstepMaxSteps: number;
  9300. }
  9301. /**
  9302. * The null engine class provides support for headless version of babylon.js.
  9303. * This can be used in server side scenario or for testing purposes
  9304. */
  9305. class NullEngine extends Engine {
  9306. private _options;
  9307. isDeterministicLockStep(): boolean;
  9308. getLockstepMaxSteps(): number;
  9309. getHardwareScalingLevel(): number;
  9310. constructor(options?: NullEngineOptions);
  9311. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9312. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9313. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9314. getRenderWidth(useScreen?: boolean): number;
  9315. getRenderHeight(useScreen?: boolean): number;
  9316. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9317. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9318. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9319. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9320. bindSamplers(effect: Effect): void;
  9321. enableEffect(effect: Effect): void;
  9322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9323. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9324. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9325. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9326. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9327. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9328. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9329. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9330. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9331. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9332. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9333. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9334. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9335. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9336. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9337. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9338. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9339. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9340. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9342. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9343. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9344. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9345. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9346. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9347. bindBuffers(vertexBuffers: {
  9348. [key: string]: VertexBuffer;
  9349. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9350. wipeCaches(bruteForce?: boolean): void;
  9351. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9352. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9353. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9354. /** @hidden */
  9355. _createTexture(): WebGLTexture;
  9356. /** @hidden */
  9357. _releaseTexture(texture: InternalTexture): void;
  9358. 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;
  9359. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9360. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9361. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9362. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9363. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9364. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9365. /**
  9366. * @hidden
  9367. * Get the current error code of the webGL context
  9368. * @returns the error code
  9369. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9370. */
  9371. getError(): number;
  9372. /** @hidden */
  9373. _getUnpackAlignement(): number;
  9374. /** @hidden */
  9375. _unpackFlipY(value: boolean): void;
  9376. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9377. /**
  9378. * Updates a dynamic vertex buffer.
  9379. * @param vertexBuffer the vertex buffer to update
  9380. * @param data the data used to update the vertex buffer
  9381. * @param byteOffset the byte offset of the data (optional)
  9382. * @param byteLength the byte length of the data (optional)
  9383. */
  9384. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9385. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9386. /** @hidden */
  9387. _bindTexture(channel: number, texture: InternalTexture): void;
  9388. /** @hidden */
  9389. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9390. releaseEffects(): void;
  9391. displayLoadingUI(): void;
  9392. hideLoadingUI(): void;
  9393. /** @hidden */
  9394. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9395. /** @hidden */
  9396. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9397. /** @hidden */
  9398. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9399. /** @hidden */
  9400. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9401. }
  9402. }
  9403. interface WebGLRenderingContext {
  9404. readonly RASTERIZER_DISCARD: number;
  9405. readonly DEPTH_COMPONENT24: number;
  9406. readonly TEXTURE_3D: number;
  9407. readonly TEXTURE_2D_ARRAY: number;
  9408. readonly TEXTURE_COMPARE_FUNC: number;
  9409. readonly TEXTURE_COMPARE_MODE: number;
  9410. readonly COMPARE_REF_TO_TEXTURE: number;
  9411. readonly TEXTURE_WRAP_R: number;
  9412. readonly HALF_FLOAT: number;
  9413. readonly RGB8: number;
  9414. readonly RED_INTEGER: number;
  9415. readonly RG_INTEGER: number;
  9416. readonly RGB_INTEGER: number;
  9417. readonly RGBA_INTEGER: number;
  9418. readonly R8_SNORM: number;
  9419. readonly RG8_SNORM: number;
  9420. readonly RGB8_SNORM: number;
  9421. readonly RGBA8_SNORM: number;
  9422. readonly R8I: number;
  9423. readonly RG8I: number;
  9424. readonly RGB8I: number;
  9425. readonly RGBA8I: number;
  9426. readonly R8UI: number;
  9427. readonly RG8UI: number;
  9428. readonly RGB8UI: number;
  9429. readonly RGBA8UI: number;
  9430. readonly R16I: number;
  9431. readonly RG16I: number;
  9432. readonly RGB16I: number;
  9433. readonly RGBA16I: number;
  9434. readonly R16UI: number;
  9435. readonly RG16UI: number;
  9436. readonly RGB16UI: number;
  9437. readonly RGBA16UI: number;
  9438. readonly R32I: number;
  9439. readonly RG32I: number;
  9440. readonly RGB32I: number;
  9441. readonly RGBA32I: number;
  9442. readonly R32UI: number;
  9443. readonly RG32UI: number;
  9444. readonly RGB32UI: number;
  9445. readonly RGBA32UI: number;
  9446. readonly RGB10_A2UI: number;
  9447. readonly R11F_G11F_B10F: number;
  9448. readonly RGB9_E5: number;
  9449. readonly RGB10_A2: number;
  9450. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9451. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9452. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9453. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9454. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9455. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9456. 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;
  9457. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9458. readonly TRANSFORM_FEEDBACK: number;
  9459. readonly INTERLEAVED_ATTRIBS: number;
  9460. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9461. createTransformFeedback(): WebGLTransformFeedback;
  9462. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9463. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9464. beginTransformFeedback(primitiveMode: number): void;
  9465. endTransformFeedback(): void;
  9466. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9467. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9468. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9469. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9470. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9471. }
  9472. interface ImageBitmap {
  9473. readonly width: number;
  9474. readonly height: number;
  9475. close(): void;
  9476. }
  9477. interface WebGLQuery extends WebGLObject {
  9478. }
  9479. declare var WebGLQuery: {
  9480. prototype: WebGLQuery;
  9481. new (): WebGLQuery;
  9482. };
  9483. interface WebGLSampler extends WebGLObject {
  9484. }
  9485. declare var WebGLSampler: {
  9486. prototype: WebGLSampler;
  9487. new (): WebGLSampler;
  9488. };
  9489. interface WebGLSync extends WebGLObject {
  9490. }
  9491. declare var WebGLSync: {
  9492. prototype: WebGLSync;
  9493. new (): WebGLSync;
  9494. };
  9495. interface WebGLTransformFeedback extends WebGLObject {
  9496. }
  9497. declare var WebGLTransformFeedback: {
  9498. prototype: WebGLTransformFeedback;
  9499. new (): WebGLTransformFeedback;
  9500. };
  9501. interface WebGLVertexArrayObject extends WebGLObject {
  9502. }
  9503. declare var WebGLVertexArrayObject: {
  9504. prototype: WebGLVertexArrayObject;
  9505. new (): WebGLVertexArrayObject;
  9506. };
  9507. declare module BABYLON {
  9508. class KeyboardEventTypes {
  9509. static _KEYDOWN: number;
  9510. static _KEYUP: number;
  9511. static readonly KEYDOWN: number;
  9512. static readonly KEYUP: number;
  9513. }
  9514. class KeyboardInfo {
  9515. type: number;
  9516. event: KeyboardEvent;
  9517. constructor(type: number, event: KeyboardEvent);
  9518. }
  9519. /**
  9520. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9521. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9522. */
  9523. class KeyboardInfoPre extends KeyboardInfo {
  9524. constructor(type: number, event: KeyboardEvent);
  9525. skipOnPointerObservable: boolean;
  9526. }
  9527. }
  9528. declare module BABYLON {
  9529. class PointerEventTypes {
  9530. static _POINTERDOWN: number;
  9531. static _POINTERUP: number;
  9532. static _POINTERMOVE: number;
  9533. static _POINTERWHEEL: number;
  9534. static _POINTERPICK: number;
  9535. static _POINTERTAP: number;
  9536. static _POINTERDOUBLETAP: number;
  9537. static readonly POINTERDOWN: number;
  9538. static readonly POINTERUP: number;
  9539. static readonly POINTERMOVE: number;
  9540. static readonly POINTERWHEEL: number;
  9541. static readonly POINTERPICK: number;
  9542. static readonly POINTERTAP: number;
  9543. static readonly POINTERDOUBLETAP: number;
  9544. }
  9545. class PointerInfoBase {
  9546. type: number;
  9547. event: PointerEvent | MouseWheelEvent;
  9548. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9549. }
  9550. /**
  9551. * This class is used to store pointer related info for the onPrePointerObservable event.
  9552. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9553. */
  9554. class PointerInfoPre extends PointerInfoBase {
  9555. /**
  9556. * Ray from a pointer if availible (eg. 6dof controller)
  9557. */
  9558. ray: Nullable<Ray>;
  9559. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9560. localPosition: Vector2;
  9561. skipOnPointerObservable: boolean;
  9562. }
  9563. /**
  9564. * This type contains all the data related to a pointer event in Babylon.js.
  9565. * 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.
  9566. */
  9567. class PointerInfo extends PointerInfoBase {
  9568. pickInfo: Nullable<PickingInfo>;
  9569. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9570. }
  9571. }
  9572. declare module BABYLON {
  9573. class StickValues {
  9574. x: number;
  9575. y: number;
  9576. constructor(x: number, y: number);
  9577. }
  9578. interface GamepadButtonChanges {
  9579. changed: boolean;
  9580. pressChanged: boolean;
  9581. touchChanged: boolean;
  9582. valueChanged: boolean;
  9583. }
  9584. class Gamepad {
  9585. id: string;
  9586. index: number;
  9587. browserGamepad: any;
  9588. type: number;
  9589. private _leftStick;
  9590. private _rightStick;
  9591. /** @hidden */
  9592. _isConnected: boolean;
  9593. private _leftStickAxisX;
  9594. private _leftStickAxisY;
  9595. private _rightStickAxisX;
  9596. private _rightStickAxisY;
  9597. private _onleftstickchanged;
  9598. private _onrightstickchanged;
  9599. static GAMEPAD: number;
  9600. static GENERIC: number;
  9601. static XBOX: number;
  9602. static POSE_ENABLED: number;
  9603. protected _invertLeftStickY: boolean;
  9604. readonly isConnected: boolean;
  9605. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9606. onleftstickchanged(callback: (values: StickValues) => void): void;
  9607. onrightstickchanged(callback: (values: StickValues) => void): void;
  9608. leftStick: StickValues;
  9609. rightStick: StickValues;
  9610. update(): void;
  9611. dispose(): void;
  9612. }
  9613. class GenericPad extends Gamepad {
  9614. private _buttons;
  9615. private _onbuttondown;
  9616. private _onbuttonup;
  9617. onButtonDownObservable: Observable<number>;
  9618. onButtonUpObservable: Observable<number>;
  9619. onbuttondown(callback: (buttonPressed: number) => void): void;
  9620. onbuttonup(callback: (buttonReleased: number) => void): void;
  9621. constructor(id: string, index: number, browserGamepad: any);
  9622. private _setButtonValue;
  9623. update(): void;
  9624. dispose(): void;
  9625. }
  9626. }
  9627. declare module BABYLON {
  9628. class GamepadManager {
  9629. private _scene?;
  9630. private _babylonGamepads;
  9631. private _oneGamepadConnected;
  9632. /** @hidden */
  9633. _isMonitoring: boolean;
  9634. private _gamepadEventSupported;
  9635. private _gamepadSupport;
  9636. onGamepadConnectedObservable: Observable<Gamepad>;
  9637. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9638. private _onGamepadConnectedEvent;
  9639. private _onGamepadDisconnectedEvent;
  9640. constructor(_scene?: Scene | undefined);
  9641. readonly gamepads: Gamepad[];
  9642. getGamepadByType(type?: number): Nullable<Gamepad>;
  9643. dispose(): void;
  9644. private _addNewGamepad;
  9645. private _startMonitoringGamepads;
  9646. private _stopMonitoringGamepads;
  9647. /** @hidden */
  9648. _checkGamepadsStatus(): void;
  9649. private _updateGamepadObjects;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. interface Scene {
  9654. /** @hidden */
  9655. _gamepadManager: Nullable<GamepadManager>;
  9656. /**
  9657. * Gets the gamepad manager associated with the scene
  9658. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9659. */
  9660. gamepadManager: GamepadManager;
  9661. }
  9662. interface FreeCameraInputsManager {
  9663. addGamepad(): FreeCameraInputsManager;
  9664. }
  9665. interface ArcRotateCameraInputsManager {
  9666. addGamepad(): ArcRotateCameraInputsManager;
  9667. }
  9668. /**
  9669. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9670. */
  9671. class GamepadSystemSceneComponent implements ISceneComponent {
  9672. /**
  9673. * The component name helpfull to identify the component in the list of scene components.
  9674. */
  9675. readonly name: string;
  9676. /**
  9677. * The scene the component belongs to.
  9678. */
  9679. scene: Scene;
  9680. /**
  9681. * Creates a new instance of the component for the given scene
  9682. * @param scene Defines the scene to register the component in
  9683. */
  9684. constructor(scene: Scene);
  9685. /**
  9686. * Registers the component in a given scene
  9687. */
  9688. register(): void;
  9689. /**
  9690. * Rebuilds the elements related to this component in case of
  9691. * context lost for instance.
  9692. */
  9693. rebuild(): void;
  9694. /**
  9695. * Disposes the component and the associated ressources
  9696. */
  9697. dispose(): void;
  9698. private _beforeCameraUpdate;
  9699. }
  9700. }
  9701. declare module BABYLON {
  9702. /**
  9703. * Defines supported buttons for XBox360 compatible gamepads
  9704. */
  9705. enum Xbox360Button {
  9706. /** A */
  9707. A = 0,
  9708. /** B */
  9709. B = 1,
  9710. /** X */
  9711. X = 2,
  9712. /** Y */
  9713. Y = 3,
  9714. /** Start */
  9715. Start = 4,
  9716. /** Back */
  9717. Back = 5,
  9718. /** Left button */
  9719. LB = 6,
  9720. /** Right button */
  9721. RB = 7,
  9722. /** Left stick */
  9723. LeftStick = 8,
  9724. /** Right stick */
  9725. RightStick = 9
  9726. }
  9727. /** Defines values for XBox360 DPad */
  9728. enum Xbox360Dpad {
  9729. /** Up */
  9730. Up = 0,
  9731. /** Down */
  9732. Down = 1,
  9733. /** Left */
  9734. Left = 2,
  9735. /** Right */
  9736. Right = 3
  9737. }
  9738. /**
  9739. * Defines a XBox360 gamepad
  9740. */
  9741. class Xbox360Pad extends Gamepad {
  9742. private _leftTrigger;
  9743. private _rightTrigger;
  9744. private _onlefttriggerchanged;
  9745. private _onrighttriggerchanged;
  9746. private _onbuttondown;
  9747. private _onbuttonup;
  9748. private _ondpaddown;
  9749. private _ondpadup;
  9750. /** Observable raised when a button is pressed */
  9751. onButtonDownObservable: Observable<Xbox360Button>;
  9752. /** Observable raised when a button is released */
  9753. onButtonUpObservable: Observable<Xbox360Button>;
  9754. /** Observable raised when a pad is pressed */
  9755. onPadDownObservable: Observable<Xbox360Dpad>;
  9756. /** Observable raised when a pad is released */
  9757. onPadUpObservable: Observable<Xbox360Dpad>;
  9758. private _buttonA;
  9759. private _buttonB;
  9760. private _buttonX;
  9761. private _buttonY;
  9762. private _buttonBack;
  9763. private _buttonStart;
  9764. private _buttonLB;
  9765. private _buttonRB;
  9766. private _buttonLeftStick;
  9767. private _buttonRightStick;
  9768. private _dPadUp;
  9769. private _dPadDown;
  9770. private _dPadLeft;
  9771. private _dPadRight;
  9772. private _isXboxOnePad;
  9773. /**
  9774. * Creates a new XBox360 gamepad object
  9775. * @param id defines the id of this gamepad
  9776. * @param index defines its index
  9777. * @param gamepad defines the internal HTML gamepad object
  9778. * @param xboxOne defines if it is a XBox One gamepad
  9779. */
  9780. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9781. /**
  9782. * Defines the callback to call when left trigger is pressed
  9783. * @param callback defines the callback to use
  9784. */
  9785. onlefttriggerchanged(callback: (value: number) => void): void;
  9786. /**
  9787. * Defines the callback to call when right trigger is pressed
  9788. * @param callback defines the callback to use
  9789. */
  9790. onrighttriggerchanged(callback: (value: number) => void): void;
  9791. /**
  9792. * Gets or sets left trigger value
  9793. */
  9794. leftTrigger: number;
  9795. /**
  9796. * Gets or sets right trigger value
  9797. */
  9798. rightTrigger: number;
  9799. /**
  9800. * Defines the callback to call when a button is pressed
  9801. * @param callback defines the callback to use
  9802. */
  9803. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9804. /**
  9805. * Defines the callback to call when a button is released
  9806. * @param callback defines the callback to use
  9807. */
  9808. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9809. /**
  9810. * Defines the callback to call when a pad is pressed
  9811. * @param callback defines the callback to use
  9812. */
  9813. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9814. /**
  9815. * Defines the callback to call when a pad is released
  9816. * @param callback defines the callback to use
  9817. */
  9818. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9819. private _setButtonValue;
  9820. private _setDPadValue;
  9821. /** Gets or sets value of A button */
  9822. buttonA: number;
  9823. /** Gets or sets value of B button */
  9824. buttonB: number;
  9825. /** Gets or sets value of X button */
  9826. buttonX: number;
  9827. /** Gets or sets value of Y button */
  9828. buttonY: number;
  9829. /** Gets or sets value of Start button */
  9830. buttonStart: number;
  9831. /** Gets or sets value of Back button */
  9832. buttonBack: number;
  9833. /** Gets or sets value of Left button */
  9834. buttonLB: number;
  9835. /** Gets or sets value of Right button */
  9836. buttonRB: number;
  9837. /** Gets or sets value of left stick */
  9838. buttonLeftStick: number;
  9839. /** Gets or sets value of right stick */
  9840. buttonRightStick: number;
  9841. /** Gets or sets value of DPad up */
  9842. dPadUp: number;
  9843. /** Gets or sets value of DPad down */
  9844. dPadDown: number;
  9845. /** Gets or sets value of DPad left */
  9846. dPadLeft: number;
  9847. /** Gets or sets value of DPad right */
  9848. dPadRight: number;
  9849. /**
  9850. * Force the gamepad to synchronize with device values
  9851. */
  9852. update(): void;
  9853. dispose(): void;
  9854. }
  9855. }
  9856. declare module BABYLON {
  9857. /**
  9858. * Single axis drag gizmo
  9859. */
  9860. class AxisDragGizmo extends Gizmo {
  9861. /**
  9862. * Drag behavior responsible for the gizmos dragging interactions
  9863. */
  9864. dragBehavior: PointerDragBehavior;
  9865. private _pointerObserver;
  9866. /**
  9867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9868. */
  9869. snapDistance: number;
  9870. /**
  9871. * Event that fires each time the gizmo snaps to a new location.
  9872. * * snapDistance is the the change in distance
  9873. */
  9874. onSnapObservable: Observable<{
  9875. snapDistance: number;
  9876. }>;
  9877. /**
  9878. * Creates an AxisDragGizmo
  9879. * @param gizmoLayer The utility layer the gizmo will be added to
  9880. * @param dragAxis The axis which the gizmo will be able to drag on
  9881. * @param color The color of the gizmo
  9882. */
  9883. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9884. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9885. /**
  9886. * Disposes of the gizmo
  9887. */
  9888. dispose(): void;
  9889. }
  9890. }
  9891. declare module BABYLON {
  9892. /**
  9893. * Single axis scale gizmo
  9894. */
  9895. class AxisScaleGizmo extends Gizmo {
  9896. private _coloredMaterial;
  9897. /**
  9898. * Drag behavior responsible for the gizmos dragging interactions
  9899. */
  9900. dragBehavior: PointerDragBehavior;
  9901. private _pointerObserver;
  9902. /**
  9903. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9904. */
  9905. snapDistance: number;
  9906. /**
  9907. * Event that fires each time the gizmo snaps to a new location.
  9908. * * snapDistance is the the change in distance
  9909. */
  9910. onSnapObservable: Observable<{
  9911. snapDistance: number;
  9912. }>;
  9913. /**
  9914. * If the scaling operation should be done on all axis (default: false)
  9915. */
  9916. uniformScaling: boolean;
  9917. /**
  9918. * Creates an AxisScaleGizmo
  9919. * @param gizmoLayer The utility layer the gizmo will be added to
  9920. * @param dragAxis The axis which the gizmo will be able to scale on
  9921. * @param color The color of the gizmo
  9922. */
  9923. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9924. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9925. /**
  9926. * Disposes of the gizmo
  9927. */
  9928. dispose(): void;
  9929. /**
  9930. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9931. * @param mesh The mesh to replace the default mesh of the gizmo
  9932. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9933. */
  9934. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9935. }
  9936. }
  9937. declare module BABYLON {
  9938. /**
  9939. * Bounding box gizmo
  9940. */
  9941. class BoundingBoxGizmo extends Gizmo {
  9942. private _lineBoundingBox;
  9943. private _rotateSpheresParent;
  9944. private _scaleBoxesParent;
  9945. private _boundingDimensions;
  9946. private _renderObserver;
  9947. private _pointerObserver;
  9948. private _scaleDragSpeed;
  9949. private _tmpQuaternion;
  9950. private _tmpVector;
  9951. /**
  9952. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  9953. */
  9954. ignoreChildren: boolean;
  9955. /**
  9956. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9957. */
  9958. rotationSphereSize: number;
  9959. /**
  9960. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9961. */
  9962. scaleBoxSize: number;
  9963. /**
  9964. * 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)
  9965. */
  9966. fixedDragMeshScreenSize: boolean;
  9967. /**
  9968. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9969. */
  9970. fixedDragMeshScreenSizeDistanceFactor: number;
  9971. /**
  9972. * Fired when a rotation sphere or scale box is dragged
  9973. */
  9974. onDragStartObservable: Observable<{}>;
  9975. /**
  9976. * Fired when a scale box is dragged
  9977. */
  9978. onScaleBoxDragObservable: Observable<{}>;
  9979. /**
  9980. * Fired when a scale box drag is ended
  9981. */
  9982. onScaleBoxDragEndObservable: Observable<{}>;
  9983. /**
  9984. * Fired when a rotation sphere is dragged
  9985. */
  9986. onRotationSphereDragObservable: Observable<{}>;
  9987. /**
  9988. * Fired when a rotation sphere drag is ended
  9989. */
  9990. onRotationSphereDragEndObservable: Observable<{}>;
  9991. private _anchorMesh;
  9992. private _existingMeshScale;
  9993. /**
  9994. * Creates an BoundingBoxGizmo
  9995. * @param gizmoLayer The utility layer the gizmo will be added to
  9996. * @param color The color of the gizmo
  9997. */
  9998. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10000. private _selectNode;
  10001. private _recurseComputeWorld;
  10002. /**
  10003. * Updates the bounding box information for the Gizmo
  10004. */
  10005. updateBoundingBox(): void;
  10006. /**
  10007. * Enables rotation on the specified axis and disables rotation on the others
  10008. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10009. */
  10010. setEnabledRotationAxis(axis: string): void;
  10011. /**
  10012. * Disposes of the gizmo
  10013. */
  10014. dispose(): void;
  10015. /**
  10016. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  10017. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10018. * @returns the bounding box mesh with the passed in mesh as a child
  10019. */
  10020. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10021. /**
  10022. * CustomMeshes are not supported by this gizmo
  10023. * @param mesh The mesh to replace the default mesh of the gizmo
  10024. */
  10025. setCustomMesh(mesh: Mesh): void;
  10026. }
  10027. }
  10028. declare module BABYLON {
  10029. /**
  10030. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10031. */
  10032. class Gizmo implements IDisposable {
  10033. /** The utility layer the gizmo will be added to */
  10034. gizmoLayer: UtilityLayerRenderer;
  10035. /**
  10036. * The root mesh of the gizmo
  10037. */
  10038. protected _rootMesh: Mesh;
  10039. private _attachedMesh;
  10040. /**
  10041. * Ratio for the scale of the gizmo (Default: 1)
  10042. */
  10043. scaleRatio: number;
  10044. private _tmpMatrix;
  10045. /**
  10046. * If a custom mesh has been set (Default: false)
  10047. */
  10048. protected _customMeshSet: boolean;
  10049. /**
  10050. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10051. * * When set, interactions will be enabled
  10052. */
  10053. attachedMesh: Nullable<AbstractMesh>;
  10054. /**
  10055. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10056. * @param mesh The mesh to replace the default mesh of the gizmo
  10057. */
  10058. setCustomMesh(mesh: Mesh): void;
  10059. /**
  10060. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10061. */
  10062. updateGizmoRotationToMatchAttachedMesh: boolean;
  10063. /**
  10064. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10065. */
  10066. updateGizmoPositionToMatchAttachedMesh: boolean;
  10067. /**
  10068. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10069. */
  10070. protected _updateScale: boolean;
  10071. protected _interactionsEnabled: boolean;
  10072. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10073. private _beforeRenderObserver;
  10074. /**
  10075. * Creates a gizmo
  10076. * @param gizmoLayer The utility layer the gizmo will be added to
  10077. */
  10078. constructor(
  10079. /** The utility layer the gizmo will be added to */
  10080. gizmoLayer?: UtilityLayerRenderer);
  10081. private _tempVector;
  10082. /**
  10083. * @hidden
  10084. * Updates the gizmo to match the attached mesh's position/rotation
  10085. */
  10086. protected _update(): void;
  10087. /**
  10088. * Disposes of the gizmo
  10089. */
  10090. dispose(): void;
  10091. }
  10092. }
  10093. declare module BABYLON {
  10094. /**
  10095. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10096. */
  10097. class GizmoManager implements IDisposable {
  10098. private scene;
  10099. /**
  10100. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10101. */
  10102. gizmos: {
  10103. positionGizmo: Nullable<PositionGizmo>;
  10104. rotationGizmo: Nullable<RotationGizmo>;
  10105. scaleGizmo: Nullable<ScaleGizmo>;
  10106. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10107. };
  10108. private _gizmosEnabled;
  10109. private _pointerObserver;
  10110. private _attachedMesh;
  10111. private _boundingBoxColor;
  10112. private _dragBehavior;
  10113. /**
  10114. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10115. */
  10116. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10117. /**
  10118. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10119. */
  10120. usePointerToAttachGizmos: boolean;
  10121. /**
  10122. * Instatiates a gizmo manager
  10123. * @param scene the scene to overlay the gizmos on top of
  10124. */
  10125. constructor(scene: Scene);
  10126. /**
  10127. * Attaches a set of gizmos to the specified mesh
  10128. * @param mesh The mesh the gizmo's should be attached to
  10129. */
  10130. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10131. /**
  10132. * If the position gizmo is enabled
  10133. */
  10134. positionGizmoEnabled: boolean;
  10135. /**
  10136. * If the rotation gizmo is enabled
  10137. */
  10138. rotationGizmoEnabled: boolean;
  10139. /**
  10140. * If the scale gizmo is enabled
  10141. */
  10142. scaleGizmoEnabled: boolean;
  10143. /**
  10144. * If the boundingBox gizmo is enabled
  10145. */
  10146. boundingBoxGizmoEnabled: boolean;
  10147. /**
  10148. * Disposes of the gizmo manager
  10149. */
  10150. dispose(): void;
  10151. }
  10152. }
  10153. declare module BABYLON {
  10154. /**
  10155. * Single plane rotation gizmo
  10156. */
  10157. class PlaneRotationGizmo extends Gizmo {
  10158. /**
  10159. * Drag behavior responsible for the gizmos dragging interactions
  10160. */
  10161. dragBehavior: PointerDragBehavior;
  10162. private _pointerObserver;
  10163. /**
  10164. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10165. */
  10166. snapDistance: number;
  10167. /**
  10168. * Event that fires each time the gizmo snaps to a new location.
  10169. * * snapDistance is the the change in distance
  10170. */
  10171. onSnapObservable: Observable<{
  10172. snapDistance: number;
  10173. }>;
  10174. /**
  10175. * Creates a PlaneRotationGizmo
  10176. * @param gizmoLayer The utility layer the gizmo will be added to
  10177. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10178. * @param color The color of the gizmo
  10179. */
  10180. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10181. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10182. /**
  10183. * Disposes of the gizmo
  10184. */
  10185. dispose(): void;
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * Gizmo that enables dragging a mesh along 3 axis
  10191. */
  10192. class PositionGizmo extends Gizmo {
  10193. /**
  10194. * Internal gizmo used for interactions on the x axis
  10195. */
  10196. xGizmo: AxisDragGizmo;
  10197. /**
  10198. * Internal gizmo used for interactions on the y axis
  10199. */
  10200. yGizmo: AxisDragGizmo;
  10201. /**
  10202. * Internal gizmo used for interactions on the z axis
  10203. */
  10204. zGizmo: AxisDragGizmo;
  10205. attachedMesh: Nullable<AbstractMesh>;
  10206. /**
  10207. * Creates a PositionGizmo
  10208. * @param gizmoLayer The utility layer the gizmo will be added to
  10209. */
  10210. constructor(gizmoLayer?: UtilityLayerRenderer);
  10211. updateGizmoRotationToMatchAttachedMesh: boolean;
  10212. /**
  10213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10214. */
  10215. snapDistance: number;
  10216. /**
  10217. * Ratio for the scale of the gizmo (Default: 1)
  10218. */
  10219. scaleRatio: number;
  10220. /**
  10221. * Disposes of the gizmo
  10222. */
  10223. dispose(): void;
  10224. /**
  10225. * CustomMeshes are not supported by this gizmo
  10226. * @param mesh The mesh to replace the default mesh of the gizmo
  10227. */
  10228. setCustomMesh(mesh: Mesh): void;
  10229. }
  10230. }
  10231. declare module BABYLON {
  10232. /**
  10233. * Gizmo that enables rotating a mesh along 3 axis
  10234. */
  10235. class RotationGizmo extends Gizmo {
  10236. /**
  10237. * Internal gizmo used for interactions on the x axis
  10238. */
  10239. xGizmo: PlaneRotationGizmo;
  10240. /**
  10241. * Internal gizmo used for interactions on the y axis
  10242. */
  10243. yGizmo: PlaneRotationGizmo;
  10244. /**
  10245. * Internal gizmo used for interactions on the z axis
  10246. */
  10247. zGizmo: PlaneRotationGizmo;
  10248. attachedMesh: Nullable<AbstractMesh>;
  10249. /**
  10250. * Creates a RotationGizmo
  10251. * @param gizmoLayer The utility layer the gizmo will be added to
  10252. */
  10253. constructor(gizmoLayer?: UtilityLayerRenderer);
  10254. updateGizmoRotationToMatchAttachedMesh: boolean;
  10255. /**
  10256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10257. */
  10258. snapDistance: number;
  10259. /**
  10260. * Ratio for the scale of the gizmo (Default: 1)
  10261. */
  10262. scaleRatio: number;
  10263. /**
  10264. * Disposes of the gizmo
  10265. */
  10266. dispose(): void;
  10267. /**
  10268. * CustomMeshes are not supported by this gizmo
  10269. * @param mesh The mesh to replace the default mesh of the gizmo
  10270. */
  10271. setCustomMesh(mesh: Mesh): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Gizmo that enables scaling a mesh along 3 axis
  10277. */
  10278. class ScaleGizmo extends Gizmo {
  10279. /**
  10280. * Internal gizmo used for interactions on the x axis
  10281. */
  10282. xGizmo: AxisScaleGizmo;
  10283. /**
  10284. * Internal gizmo used for interactions on the y axis
  10285. */
  10286. yGizmo: AxisScaleGizmo;
  10287. /**
  10288. * Internal gizmo used for interactions on the z axis
  10289. */
  10290. zGizmo: AxisScaleGizmo;
  10291. /**
  10292. * @hidden
  10293. * Internal gizmo used to scale all axis equally
  10294. */
  10295. private _uniformGizmo;
  10296. attachedMesh: Nullable<AbstractMesh>;
  10297. /**
  10298. * Creates a ScaleGizmo
  10299. * @param gizmoLayer The utility layer the gizmo will be added to
  10300. */
  10301. constructor(gizmoLayer?: UtilityLayerRenderer);
  10302. updateGizmoRotationToMatchAttachedMesh: boolean;
  10303. /**
  10304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10305. */
  10306. snapDistance: number;
  10307. /**
  10308. * Ratio for the scale of the gizmo (Default: 1)
  10309. */
  10310. scaleRatio: number;
  10311. /**
  10312. * Disposes of the gizmo
  10313. */
  10314. dispose(): void;
  10315. }
  10316. }
  10317. declare module BABYLON {
  10318. /**
  10319. * Represents the different options available during the creation of
  10320. * a Environment helper.
  10321. *
  10322. * This can control the default ground, skybox and image processing setup of your scene.
  10323. */
  10324. interface IEnvironmentHelperOptions {
  10325. /**
  10326. * Specifies wether or not to create a ground.
  10327. * True by default.
  10328. */
  10329. createGround: boolean;
  10330. /**
  10331. * Specifies the ground size.
  10332. * 15 by default.
  10333. */
  10334. groundSize: number;
  10335. /**
  10336. * The texture used on the ground for the main color.
  10337. * Comes from the BabylonJS CDN by default.
  10338. *
  10339. * Remarks: Can be either a texture or a url.
  10340. */
  10341. groundTexture: string | BaseTexture;
  10342. /**
  10343. * The color mixed in the ground texture by default.
  10344. * BabylonJS clearColor by default.
  10345. */
  10346. groundColor: Color3;
  10347. /**
  10348. * Specifies the ground opacity.
  10349. * 1 by default.
  10350. */
  10351. groundOpacity: number;
  10352. /**
  10353. * Enables the ground to receive shadows.
  10354. * True by default.
  10355. */
  10356. enableGroundShadow: boolean;
  10357. /**
  10358. * Helps preventing the shadow to be fully black on the ground.
  10359. * 0.5 by default.
  10360. */
  10361. groundShadowLevel: number;
  10362. /**
  10363. * Creates a mirror texture attach to the ground.
  10364. * false by default.
  10365. */
  10366. enableGroundMirror: boolean;
  10367. /**
  10368. * Specifies the ground mirror size ratio.
  10369. * 0.3 by default as the default kernel is 64.
  10370. */
  10371. groundMirrorSizeRatio: number;
  10372. /**
  10373. * Specifies the ground mirror blur kernel size.
  10374. * 64 by default.
  10375. */
  10376. groundMirrorBlurKernel: number;
  10377. /**
  10378. * Specifies the ground mirror visibility amount.
  10379. * 1 by default
  10380. */
  10381. groundMirrorAmount: number;
  10382. /**
  10383. * Specifies the ground mirror reflectance weight.
  10384. * This uses the standard weight of the background material to setup the fresnel effect
  10385. * of the mirror.
  10386. * 1 by default.
  10387. */
  10388. groundMirrorFresnelWeight: number;
  10389. /**
  10390. * Specifies the ground mirror Falloff distance.
  10391. * This can helps reducing the size of the reflection.
  10392. * 0 by Default.
  10393. */
  10394. groundMirrorFallOffDistance: number;
  10395. /**
  10396. * Specifies the ground mirror texture type.
  10397. * Unsigned Int by Default.
  10398. */
  10399. groundMirrorTextureType: number;
  10400. /**
  10401. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10402. * the shown objects.
  10403. */
  10404. groundYBias: number;
  10405. /**
  10406. * Specifies wether or not to create a skybox.
  10407. * True by default.
  10408. */
  10409. createSkybox: boolean;
  10410. /**
  10411. * Specifies the skybox size.
  10412. * 20 by default.
  10413. */
  10414. skyboxSize: number;
  10415. /**
  10416. * The texture used on the skybox for the main color.
  10417. * Comes from the BabylonJS CDN by default.
  10418. *
  10419. * Remarks: Can be either a texture or a url.
  10420. */
  10421. skyboxTexture: string | BaseTexture;
  10422. /**
  10423. * The color mixed in the skybox texture by default.
  10424. * BabylonJS clearColor by default.
  10425. */
  10426. skyboxColor: Color3;
  10427. /**
  10428. * The background rotation around the Y axis of the scene.
  10429. * This helps aligning the key lights of your scene with the background.
  10430. * 0 by default.
  10431. */
  10432. backgroundYRotation: number;
  10433. /**
  10434. * Compute automatically the size of the elements to best fit with the scene.
  10435. */
  10436. sizeAuto: boolean;
  10437. /**
  10438. * Default position of the rootMesh if autoSize is not true.
  10439. */
  10440. rootPosition: Vector3;
  10441. /**
  10442. * Sets up the image processing in the scene.
  10443. * true by default.
  10444. */
  10445. setupImageProcessing: boolean;
  10446. /**
  10447. * The texture used as your environment texture in the scene.
  10448. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10449. *
  10450. * Remarks: Can be either a texture or a url.
  10451. */
  10452. environmentTexture: string | BaseTexture;
  10453. /**
  10454. * The value of the exposure to apply to the scene.
  10455. * 0.6 by default if setupImageProcessing is true.
  10456. */
  10457. cameraExposure: number;
  10458. /**
  10459. * The value of the contrast to apply to the scene.
  10460. * 1.6 by default if setupImageProcessing is true.
  10461. */
  10462. cameraContrast: number;
  10463. /**
  10464. * Specifies wether or not tonemapping should be enabled in the scene.
  10465. * true by default if setupImageProcessing is true.
  10466. */
  10467. toneMappingEnabled: boolean;
  10468. }
  10469. /**
  10470. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10471. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10472. * It also helps with the default setup of your imageProcessing configuration.
  10473. */
  10474. class EnvironmentHelper {
  10475. /**
  10476. * Default ground texture URL.
  10477. */
  10478. private static _groundTextureCDNUrl;
  10479. /**
  10480. * Default skybox texture URL.
  10481. */
  10482. private static _skyboxTextureCDNUrl;
  10483. /**
  10484. * Default environment texture URL.
  10485. */
  10486. private static _environmentTextureCDNUrl;
  10487. /**
  10488. * Creates the default options for the helper.
  10489. */
  10490. private static _getDefaultOptions;
  10491. private _rootMesh;
  10492. /**
  10493. * Gets the root mesh created by the helper.
  10494. */
  10495. readonly rootMesh: Mesh;
  10496. private _skybox;
  10497. /**
  10498. * Gets the skybox created by the helper.
  10499. */
  10500. readonly skybox: Nullable<Mesh>;
  10501. private _skyboxTexture;
  10502. /**
  10503. * Gets the skybox texture created by the helper.
  10504. */
  10505. readonly skyboxTexture: Nullable<BaseTexture>;
  10506. private _skyboxMaterial;
  10507. /**
  10508. * Gets the skybox material created by the helper.
  10509. */
  10510. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10511. private _ground;
  10512. /**
  10513. * Gets the ground mesh created by the helper.
  10514. */
  10515. readonly ground: Nullable<Mesh>;
  10516. private _groundTexture;
  10517. /**
  10518. * Gets the ground texture created by the helper.
  10519. */
  10520. readonly groundTexture: Nullable<BaseTexture>;
  10521. private _groundMirror;
  10522. /**
  10523. * Gets the ground mirror created by the helper.
  10524. */
  10525. readonly groundMirror: Nullable<MirrorTexture>;
  10526. /**
  10527. * Gets the ground mirror render list to helps pushing the meshes
  10528. * you wish in the ground reflection.
  10529. */
  10530. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10531. private _groundMaterial;
  10532. /**
  10533. * Gets the ground material created by the helper.
  10534. */
  10535. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10536. /**
  10537. * Stores the creation options.
  10538. */
  10539. private readonly _scene;
  10540. private _options;
  10541. /**
  10542. * This observable will be notified with any error during the creation of the environment,
  10543. * mainly texture creation errors.
  10544. */
  10545. onErrorObservable: Observable<{
  10546. message?: string;
  10547. exception?: any;
  10548. }>;
  10549. /**
  10550. * constructor
  10551. * @param options
  10552. * @param scene The scene to add the material to
  10553. */
  10554. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10555. /**
  10556. * Updates the background according to the new options
  10557. * @param options
  10558. */
  10559. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10560. /**
  10561. * Sets the primary color of all the available elements.
  10562. * @param color the main color to affect to the ground and the background
  10563. */
  10564. setMainColor(color: Color3): void;
  10565. /**
  10566. * Setup the image processing according to the specified options.
  10567. */
  10568. private _setupImageProcessing;
  10569. /**
  10570. * Setup the environment texture according to the specified options.
  10571. */
  10572. private _setupEnvironmentTexture;
  10573. /**
  10574. * Setup the background according to the specified options.
  10575. */
  10576. private _setupBackground;
  10577. /**
  10578. * Get the scene sizes according to the setup.
  10579. */
  10580. private _getSceneSize;
  10581. /**
  10582. * Setup the ground according to the specified options.
  10583. */
  10584. private _setupGround;
  10585. /**
  10586. * Setup the ground material according to the specified options.
  10587. */
  10588. private _setupGroundMaterial;
  10589. /**
  10590. * Setup the ground diffuse texture according to the specified options.
  10591. */
  10592. private _setupGroundDiffuseTexture;
  10593. /**
  10594. * Setup the ground mirror texture according to the specified options.
  10595. */
  10596. private _setupGroundMirrorTexture;
  10597. /**
  10598. * Setup the ground to receive the mirror texture.
  10599. */
  10600. private _setupMirrorInGroundMaterial;
  10601. /**
  10602. * Setup the skybox according to the specified options.
  10603. */
  10604. private _setupSkybox;
  10605. /**
  10606. * Setup the skybox material according to the specified options.
  10607. */
  10608. private _setupSkyboxMaterial;
  10609. /**
  10610. * Setup the skybox reflection texture according to the specified options.
  10611. */
  10612. private _setupSkyboxReflectionTexture;
  10613. private _errorHandler;
  10614. /**
  10615. * Dispose all the elements created by the Helper.
  10616. */
  10617. dispose(): void;
  10618. }
  10619. }
  10620. declare module BABYLON {
  10621. /**
  10622. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10623. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10624. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10625. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10626. */
  10627. class PhotoDome extends TransformNode {
  10628. private _useDirectMapping;
  10629. /**
  10630. * The texture being displayed on the sphere
  10631. */
  10632. protected _photoTexture: Texture;
  10633. /**
  10634. * Gets or sets the texture being displayed on the sphere
  10635. */
  10636. photoTexture: Texture;
  10637. /**
  10638. * Observable raised when an error occured while loading the 360 image
  10639. */
  10640. onLoadErrorObservable: Observable<string>;
  10641. /**
  10642. * The skybox material
  10643. */
  10644. protected _material: BackgroundMaterial;
  10645. /**
  10646. * The surface used for the skybox
  10647. */
  10648. protected _mesh: Mesh;
  10649. /**
  10650. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10651. * Also see the options.resolution property.
  10652. */
  10653. fovMultiplier: number;
  10654. /**
  10655. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10656. * @param name Element's name, child elements will append suffixes for their own names.
  10657. * @param urlsOfPhoto defines the url of the photo to display
  10658. * @param options defines an object containing optional or exposed sub element properties
  10659. * @param onError defines a callback called when an error occured while loading the texture
  10660. */
  10661. constructor(name: string, urlOfPhoto: string, options: {
  10662. resolution?: number;
  10663. size?: number;
  10664. useDirectMapping?: boolean;
  10665. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10666. /**
  10667. * Releases resources associated with this node.
  10668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10670. */
  10671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10672. }
  10673. }
  10674. declare module BABYLON {
  10675. /**
  10676. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10677. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10678. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10679. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10680. */
  10681. class VideoDome extends TransformNode {
  10682. private _useDirectMapping;
  10683. /**
  10684. * The video texture being displayed on the sphere
  10685. */
  10686. protected _videoTexture: VideoTexture;
  10687. /**
  10688. * Gets the video texture being displayed on the sphere
  10689. */
  10690. readonly videoTexture: VideoTexture;
  10691. /**
  10692. * The skybox material
  10693. */
  10694. protected _material: BackgroundMaterial;
  10695. /**
  10696. * The surface used for the skybox
  10697. */
  10698. protected _mesh: Mesh;
  10699. /**
  10700. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10701. * Also see the options.resolution property.
  10702. */
  10703. fovMultiplier: number;
  10704. /**
  10705. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10706. * @param name Element's name, child elements will append suffixes for their own names.
  10707. * @param urlsOrVideo defines the url(s) or the video element to use
  10708. * @param options An object containing optional or exposed sub element properties
  10709. */
  10710. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10711. resolution?: number;
  10712. clickToPlay?: boolean;
  10713. autoPlay?: boolean;
  10714. loop?: boolean;
  10715. size?: number;
  10716. poster?: string;
  10717. useDirectMapping?: boolean;
  10718. }, scene: Scene);
  10719. /**
  10720. * Releases resources associated with this node.
  10721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10723. */
  10724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10725. }
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * This class can be used to get instrumentation data from a Babylon engine
  10730. */
  10731. class EngineInstrumentation implements IDisposable {
  10732. engine: Engine;
  10733. private _captureGPUFrameTime;
  10734. private _gpuFrameTimeToken;
  10735. private _gpuFrameTime;
  10736. private _captureShaderCompilationTime;
  10737. private _shaderCompilationTime;
  10738. private _onBeginFrameObserver;
  10739. private _onEndFrameObserver;
  10740. private _onBeforeShaderCompilationObserver;
  10741. private _onAfterShaderCompilationObserver;
  10742. /**
  10743. * Gets the perf counter used for GPU frame time
  10744. */
  10745. readonly gpuFrameTimeCounter: PerfCounter;
  10746. /**
  10747. * Gets the GPU frame time capture status
  10748. */
  10749. /**
  10750. * Enable or disable the GPU frame time capture
  10751. */
  10752. captureGPUFrameTime: boolean;
  10753. /**
  10754. * Gets the perf counter used for shader compilation time
  10755. */
  10756. readonly shaderCompilationTimeCounter: PerfCounter;
  10757. /**
  10758. * Gets the shader compilation time capture status
  10759. */
  10760. /**
  10761. * Enable or disable the shader compilation time capture
  10762. */
  10763. captureShaderCompilationTime: boolean;
  10764. constructor(engine: Engine);
  10765. dispose(): void;
  10766. }
  10767. }
  10768. declare module BABYLON {
  10769. /**
  10770. * This class can be used to get instrumentation data from a Babylon engine
  10771. */
  10772. class SceneInstrumentation implements IDisposable {
  10773. scene: Scene;
  10774. private _captureActiveMeshesEvaluationTime;
  10775. private _activeMeshesEvaluationTime;
  10776. private _captureRenderTargetsRenderTime;
  10777. private _renderTargetsRenderTime;
  10778. private _captureFrameTime;
  10779. private _frameTime;
  10780. private _captureRenderTime;
  10781. private _renderTime;
  10782. private _captureInterFrameTime;
  10783. private _interFrameTime;
  10784. private _captureParticlesRenderTime;
  10785. private _particlesRenderTime;
  10786. private _captureSpritesRenderTime;
  10787. private _spritesRenderTime;
  10788. private _capturePhysicsTime;
  10789. private _physicsTime;
  10790. private _captureAnimationsTime;
  10791. private _animationsTime;
  10792. private _captureCameraRenderTime;
  10793. private _cameraRenderTime;
  10794. private _onBeforeActiveMeshesEvaluationObserver;
  10795. private _onAfterActiveMeshesEvaluationObserver;
  10796. private _onBeforeRenderTargetsRenderObserver;
  10797. private _onAfterRenderTargetsRenderObserver;
  10798. private _onAfterRenderObserver;
  10799. private _onBeforeDrawPhaseObserver;
  10800. private _onAfterDrawPhaseObserver;
  10801. private _onBeforeAnimationsObserver;
  10802. private _onBeforeParticlesRenderingObserver;
  10803. private _onAfterParticlesRenderingObserver;
  10804. private _onBeforeSpritesRenderingObserver;
  10805. private _onAfterSpritesRenderingObserver;
  10806. private _onBeforePhysicsObserver;
  10807. private _onAfterPhysicsObserver;
  10808. private _onAfterAnimationsObserver;
  10809. private _onBeforeCameraRenderObserver;
  10810. private _onAfterCameraRenderObserver;
  10811. /**
  10812. * Gets the perf counter used for active meshes evaluation time
  10813. */
  10814. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10815. /**
  10816. * Gets the active meshes evaluation time capture status
  10817. */
  10818. /**
  10819. * Enable or disable the active meshes evaluation time capture
  10820. */
  10821. captureActiveMeshesEvaluationTime: boolean;
  10822. /**
  10823. * Gets the perf counter used for render targets render time
  10824. */
  10825. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10826. /**
  10827. * Gets the render targets render time capture status
  10828. */
  10829. /**
  10830. * Enable or disable the render targets render time capture
  10831. */
  10832. captureRenderTargetsRenderTime: boolean;
  10833. /**
  10834. * Gets the perf counter used for particles render time
  10835. */
  10836. readonly particlesRenderTimeCounter: PerfCounter;
  10837. /**
  10838. * Gets the particles render time capture status
  10839. */
  10840. /**
  10841. * Enable or disable the particles render time capture
  10842. */
  10843. captureParticlesRenderTime: boolean;
  10844. /**
  10845. * Gets the perf counter used for sprites render time
  10846. */
  10847. readonly spritesRenderTimeCounter: PerfCounter;
  10848. /**
  10849. * Gets the sprites render time capture status
  10850. */
  10851. /**
  10852. * Enable or disable the sprites render time capture
  10853. */
  10854. captureSpritesRenderTime: boolean;
  10855. /**
  10856. * Gets the perf counter used for physics time
  10857. */
  10858. readonly physicsTimeCounter: PerfCounter;
  10859. /**
  10860. * Gets the physics time capture status
  10861. */
  10862. /**
  10863. * Enable or disable the physics time capture
  10864. */
  10865. capturePhysicsTime: boolean;
  10866. /**
  10867. * Gets the perf counter used for animations time
  10868. */
  10869. readonly animationsTimeCounter: PerfCounter;
  10870. /**
  10871. * Gets the animations time capture status
  10872. */
  10873. /**
  10874. * Enable or disable the animations time capture
  10875. */
  10876. captureAnimationsTime: boolean;
  10877. /**
  10878. * Gets the perf counter used for frame time capture
  10879. */
  10880. readonly frameTimeCounter: PerfCounter;
  10881. /**
  10882. * Gets the frame time capture status
  10883. */
  10884. /**
  10885. * Enable or disable the frame time capture
  10886. */
  10887. captureFrameTime: boolean;
  10888. /**
  10889. * Gets the perf counter used for inter-frames time capture
  10890. */
  10891. readonly interFrameTimeCounter: PerfCounter;
  10892. /**
  10893. * Gets the inter-frames time capture status
  10894. */
  10895. /**
  10896. * Enable or disable the inter-frames time capture
  10897. */
  10898. captureInterFrameTime: boolean;
  10899. /**
  10900. * Gets the perf counter used for render time capture
  10901. */
  10902. readonly renderTimeCounter: PerfCounter;
  10903. /**
  10904. * Gets the render time capture status
  10905. */
  10906. /**
  10907. * Enable or disable the render time capture
  10908. */
  10909. captureRenderTime: boolean;
  10910. /**
  10911. * Gets the perf counter used for camera render time capture
  10912. */
  10913. readonly cameraRenderTimeCounter: PerfCounter;
  10914. /**
  10915. * Gets the camera render time capture status
  10916. */
  10917. /**
  10918. * Enable or disable the camera render time capture
  10919. */
  10920. captureCameraRenderTime: boolean;
  10921. /**
  10922. * Gets the perf counter used for draw calls
  10923. */
  10924. readonly drawCallsCounter: PerfCounter;
  10925. /**
  10926. * Gets the perf counter used for texture collisions
  10927. */
  10928. readonly textureCollisionsCounter: PerfCounter;
  10929. constructor(scene: Scene);
  10930. dispose(): void;
  10931. }
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * @hidden
  10936. **/
  10937. class _TimeToken {
  10938. _startTimeQuery: Nullable<WebGLQuery>;
  10939. _endTimeQuery: Nullable<WebGLQuery>;
  10940. _timeElapsedQuery: Nullable<WebGLQuery>;
  10941. _timeElapsedQueryEnded: boolean;
  10942. }
  10943. }
  10944. declare module BABYLON {
  10945. /**
  10946. * Effect layer options. This helps customizing the behaviour
  10947. * of the effect layer.
  10948. */
  10949. interface IEffectLayerOptions {
  10950. /**
  10951. * Multiplication factor apply to the canvas size to compute the render target size
  10952. * used to generated the objects (the smaller the faster).
  10953. */
  10954. mainTextureRatio: number;
  10955. /**
  10956. * Enforces a fixed size texture to ensure effect stability across devices.
  10957. */
  10958. mainTextureFixedSize?: number;
  10959. /**
  10960. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10961. */
  10962. alphaBlendingMode: number;
  10963. /**
  10964. * The camera attached to the layer.
  10965. */
  10966. camera: Nullable<Camera>;
  10967. /**
  10968. * The rendering group to draw the layer in.
  10969. */
  10970. renderingGroupId: number;
  10971. }
  10972. /**
  10973. * The effect layer Helps adding post process effect blended with the main pass.
  10974. *
  10975. * This can be for instance use to generate glow or higlight effects on the scene.
  10976. *
  10977. * The effect layer class can not be used directly and is intented to inherited from to be
  10978. * customized per effects.
  10979. */
  10980. abstract class EffectLayer {
  10981. private _vertexBuffers;
  10982. private _indexBuffer;
  10983. private _cachedDefines;
  10984. private _effectLayerMapGenerationEffect;
  10985. private _effectLayerOptions;
  10986. private _mergeEffect;
  10987. protected _scene: Scene;
  10988. protected _engine: Engine;
  10989. protected _maxSize: number;
  10990. protected _mainTextureDesiredSize: ISize;
  10991. protected _mainTexture: RenderTargetTexture;
  10992. protected _shouldRender: boolean;
  10993. protected _postProcesses: PostProcess[];
  10994. protected _textures: BaseTexture[];
  10995. protected _emissiveTextureAndColor: {
  10996. texture: Nullable<BaseTexture>;
  10997. color: Color4;
  10998. };
  10999. /**
  11000. * The name of the layer
  11001. */
  11002. name: string;
  11003. /**
  11004. * The clear color of the texture used to generate the glow map.
  11005. */
  11006. neutralColor: Color4;
  11007. /**
  11008. * Specifies wether the highlight layer is enabled or not.
  11009. */
  11010. isEnabled: boolean;
  11011. /**
  11012. * Gets the camera attached to the layer.
  11013. */
  11014. readonly camera: Nullable<Camera>;
  11015. /**
  11016. * Gets the rendering group id the layer should render in.
  11017. */
  11018. readonly renderingGroupId: number;
  11019. /**
  11020. * An event triggered when the effect layer has been disposed.
  11021. */
  11022. onDisposeObservable: Observable<EffectLayer>;
  11023. /**
  11024. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11025. */
  11026. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11027. /**
  11028. * An event triggered when the generated texture is being merged in the scene.
  11029. */
  11030. onBeforeComposeObservable: Observable<EffectLayer>;
  11031. /**
  11032. * An event triggered when the generated texture has been merged in the scene.
  11033. */
  11034. onAfterComposeObservable: Observable<EffectLayer>;
  11035. /**
  11036. * An event triggered when the efffect layer changes its size.
  11037. */
  11038. onSizeChangedObservable: Observable<EffectLayer>;
  11039. /**
  11040. * Instantiates a new effect Layer and references it in the scene.
  11041. * @param name The name of the layer
  11042. * @param scene The scene to use the layer in
  11043. */
  11044. constructor(
  11045. /** The Friendly of the effect in the scene */
  11046. name: string, scene: Scene);
  11047. /**
  11048. * Get the effect name of the layer.
  11049. * @return The effect name
  11050. */
  11051. abstract getEffectName(): string;
  11052. /**
  11053. * Checks for the readiness of the element composing the layer.
  11054. * @param subMesh the mesh to check for
  11055. * @param useInstances specify wether or not to use instances to render the mesh
  11056. * @return true if ready otherwise, false
  11057. */
  11058. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11059. /**
  11060. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11061. * @returns true if the effect requires stencil during the main canvas render pass.
  11062. */
  11063. abstract needStencil(): boolean;
  11064. /**
  11065. * Create the merge effect. This is the shader use to blit the information back
  11066. * to the main canvas at the end of the scene rendering.
  11067. * @returns The effect containing the shader used to merge the effect on the main canvas
  11068. */
  11069. protected abstract _createMergeEffect(): Effect;
  11070. /**
  11071. * Creates the render target textures and post processes used in the effect layer.
  11072. */
  11073. protected abstract _createTextureAndPostProcesses(): void;
  11074. /**
  11075. * Implementation specific of rendering the generating effect on the main canvas.
  11076. * @param effect The effect used to render through
  11077. */
  11078. protected abstract _internalRender(effect: Effect): void;
  11079. /**
  11080. * Sets the required values for both the emissive texture and and the main color.
  11081. */
  11082. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11083. /**
  11084. * Free any resources and references associated to a mesh.
  11085. * Internal use
  11086. * @param mesh The mesh to free.
  11087. */
  11088. abstract _disposeMesh(mesh: Mesh): void;
  11089. /**
  11090. * Serializes this layer (Glow or Highlight for example)
  11091. * @returns a serialized layer object
  11092. */
  11093. abstract serialize?(): any;
  11094. /**
  11095. * Initializes the effect layer with the required options.
  11096. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11097. */
  11098. protected _init(options: Partial<IEffectLayerOptions>): void;
  11099. /**
  11100. * Generates the index buffer of the full screen quad blending to the main canvas.
  11101. */
  11102. private _generateIndexBuffer;
  11103. /**
  11104. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11105. */
  11106. private _genrateVertexBuffer;
  11107. /**
  11108. * Sets the main texture desired size which is the closest power of two
  11109. * of the engine canvas size.
  11110. */
  11111. private _setMainTextureSize;
  11112. /**
  11113. * Creates the main texture for the effect layer.
  11114. */
  11115. protected _createMainTexture(): void;
  11116. /**
  11117. * Checks for the readiness of the element composing the layer.
  11118. * @param subMesh the mesh to check for
  11119. * @param useInstances specify wether or not to use instances to render the mesh
  11120. * @param emissiveTexture the associated emissive texture used to generate the glow
  11121. * @return true if ready otherwise, false
  11122. */
  11123. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11124. /**
  11125. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11126. */
  11127. render(): void;
  11128. /**
  11129. * Determine if a given mesh will be used in the current effect.
  11130. * @param mesh mesh to test
  11131. * @returns true if the mesh will be used
  11132. */
  11133. hasMesh(mesh: AbstractMesh): boolean;
  11134. /**
  11135. * Returns true if the layer contains information to display, otherwise false.
  11136. * @returns true if the glow layer should be rendered
  11137. */
  11138. shouldRender(): boolean;
  11139. /**
  11140. * Returns true if the mesh should render, otherwise false.
  11141. * @param mesh The mesh to render
  11142. * @returns true if it should render otherwise false
  11143. */
  11144. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11145. /**
  11146. * Returns true if the mesh should render, otherwise false.
  11147. * @param mesh The mesh to render
  11148. * @returns true if it should render otherwise false
  11149. */
  11150. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11151. /**
  11152. * Renders the submesh passed in parameter to the generation map.
  11153. */
  11154. protected _renderSubMesh(subMesh: SubMesh): void;
  11155. /**
  11156. * Rebuild the required buffers.
  11157. * @hidden Internal use only.
  11158. */
  11159. _rebuild(): void;
  11160. /**
  11161. * Dispose only the render target textures and post process.
  11162. */
  11163. private _disposeTextureAndPostProcesses;
  11164. /**
  11165. * Dispose the highlight layer and free resources.
  11166. */
  11167. dispose(): void;
  11168. /**
  11169. * Gets the class name of the effect layer
  11170. * @returns the string with the class name of the effect layer
  11171. */
  11172. getClassName(): string;
  11173. /**
  11174. * Creates an effect layer from parsed effect layer data
  11175. * @param parsedEffectLayer defines effect layer data
  11176. * @param scene defines the current scene
  11177. * @param rootUrl defines the root URL containing the effect layer information
  11178. * @returns a parsed effect Layer
  11179. */
  11180. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11181. }
  11182. }
  11183. declare module BABYLON {
  11184. interface AbstractScene {
  11185. /**
  11186. * The list of effect layers (highlights/glow) added to the scene
  11187. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11188. * @see http://doc.babylonjs.com/how_to/glow_layer
  11189. */
  11190. effectLayers: Array<EffectLayer>;
  11191. /**
  11192. * Removes the given effect layer from this scene.
  11193. * @param toRemove defines the effect layer to remove
  11194. * @returns the index of the removed effect layer
  11195. */
  11196. removeEffectLayer(toRemove: EffectLayer): number;
  11197. /**
  11198. * Adds the given effect layer to this scene
  11199. * @param newEffectLayer defines the effect layer to add
  11200. */
  11201. addEffectLayer(newEffectLayer: EffectLayer): void;
  11202. }
  11203. /**
  11204. * Defines the layer scene component responsible to manage any effect layers
  11205. * in a given scene.
  11206. */
  11207. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11208. /**
  11209. * The component name helpfull to identify the component in the list of scene components.
  11210. */
  11211. readonly name: string;
  11212. /**
  11213. * The scene the component belongs to.
  11214. */
  11215. scene: Scene;
  11216. private _engine;
  11217. private _renderEffects;
  11218. private _needStencil;
  11219. private _previousStencilState;
  11220. /**
  11221. * Creates a new instance of the component for the given scene
  11222. * @param scene Defines the scene to register the component in
  11223. */
  11224. constructor(scene: Scene);
  11225. /**
  11226. * Registers the component in a given scene
  11227. */
  11228. register(): void;
  11229. /**
  11230. * Rebuilds the elements related to this component in case of
  11231. * context lost for instance.
  11232. */
  11233. rebuild(): void;
  11234. /**
  11235. * Serializes the component data to the specified json object
  11236. * @param serializationObject The object to serialize to
  11237. */
  11238. serialize(serializationObject: any): void;
  11239. /**
  11240. * Adds all the element from the container to the scene
  11241. * @param container the container holding the elements
  11242. */
  11243. addFromContainer(container: AbstractScene): void;
  11244. /**
  11245. * Removes all the elements in the container from the scene
  11246. * @param container contains the elements to remove
  11247. */
  11248. removeFromContainer(container: AbstractScene): void;
  11249. /**
  11250. * Disposes the component and the associated ressources.
  11251. */
  11252. dispose(): void;
  11253. private _isReadyForMesh;
  11254. private _renderMainTexture;
  11255. private _setStencil;
  11256. private _setStencilBack;
  11257. private _draw;
  11258. private _drawCamera;
  11259. private _drawRenderingGroup;
  11260. }
  11261. }
  11262. declare module BABYLON {
  11263. interface AbstractScene {
  11264. /**
  11265. * Return a the first highlight layer of the scene with a given name.
  11266. * @param name The name of the highlight layer to look for.
  11267. * @return The highlight layer if found otherwise null.
  11268. */
  11269. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11270. }
  11271. /**
  11272. * Glow layer options. This helps customizing the behaviour
  11273. * of the glow layer.
  11274. */
  11275. interface IGlowLayerOptions {
  11276. /**
  11277. * Multiplication factor apply to the canvas size to compute the render target size
  11278. * used to generated the glowing objects (the smaller the faster).
  11279. */
  11280. mainTextureRatio: number;
  11281. /**
  11282. * Enforces a fixed size texture to ensure resize independant blur.
  11283. */
  11284. mainTextureFixedSize?: number;
  11285. /**
  11286. * How big is the kernel of the blur texture.
  11287. */
  11288. blurKernelSize: number;
  11289. /**
  11290. * The camera attached to the layer.
  11291. */
  11292. camera: Nullable<Camera>;
  11293. /**
  11294. * Enable MSAA by chosing the number of samples.
  11295. */
  11296. mainTextureSamples?: number;
  11297. /**
  11298. * The rendering group to draw the layer in.
  11299. */
  11300. renderingGroupId: number;
  11301. }
  11302. /**
  11303. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11304. *
  11305. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11306. * glowy meshes to your scene.
  11307. *
  11308. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11309. */
  11310. class GlowLayer extends EffectLayer {
  11311. /**
  11312. * Effect Name of the layer.
  11313. */
  11314. static readonly EffectName: string;
  11315. /**
  11316. * The default blur kernel size used for the glow.
  11317. */
  11318. static DefaultBlurKernelSize: number;
  11319. /**
  11320. * The default texture size ratio used for the glow.
  11321. */
  11322. static DefaultTextureRatio: number;
  11323. /**
  11324. * Sets the kernel size of the blur.
  11325. */
  11326. /**
  11327. * Gets the kernel size of the blur.
  11328. */
  11329. blurKernelSize: number;
  11330. /**
  11331. * Sets the glow intensity.
  11332. */
  11333. /**
  11334. * Gets the glow intensity.
  11335. */
  11336. intensity: number;
  11337. private _options;
  11338. private _intensity;
  11339. private _horizontalBlurPostprocess1;
  11340. private _verticalBlurPostprocess1;
  11341. private _horizontalBlurPostprocess2;
  11342. private _verticalBlurPostprocess2;
  11343. private _blurTexture1;
  11344. private _blurTexture2;
  11345. private _postProcesses1;
  11346. private _postProcesses2;
  11347. private _includedOnlyMeshes;
  11348. private _excludedMeshes;
  11349. /**
  11350. * Callback used to let the user override the color selection on a per mesh basis
  11351. */
  11352. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11353. /**
  11354. * Callback used to let the user override the texture selection on a per mesh basis
  11355. */
  11356. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11357. /**
  11358. * Instantiates a new glow Layer and references it to the scene.
  11359. * @param name The name of the layer
  11360. * @param scene The scene to use the layer in
  11361. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11362. */
  11363. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11364. /**
  11365. * Get the effect name of the layer.
  11366. * @return The effect name
  11367. */
  11368. getEffectName(): string;
  11369. /**
  11370. * Create the merge effect. This is the shader use to blit the information back
  11371. * to the main canvas at the end of the scene rendering.
  11372. */
  11373. protected _createMergeEffect(): Effect;
  11374. /**
  11375. * Creates the render target textures and post processes used in the glow layer.
  11376. */
  11377. protected _createTextureAndPostProcesses(): void;
  11378. /**
  11379. * Checks for the readiness of the element composing the layer.
  11380. * @param subMesh the mesh to check for
  11381. * @param useInstances specify wether or not to use instances to render the mesh
  11382. * @param emissiveTexture the associated emissive texture used to generate the glow
  11383. * @return true if ready otherwise, false
  11384. */
  11385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11386. /**
  11387. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11388. */
  11389. needStencil(): boolean;
  11390. /**
  11391. * Implementation specific of rendering the generating effect on the main canvas.
  11392. * @param effect The effect used to render through
  11393. */
  11394. protected _internalRender(effect: Effect): void;
  11395. /**
  11396. * Sets the required values for both the emissive texture and and the main color.
  11397. */
  11398. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11399. /**
  11400. * Returns true if the mesh should render, otherwise false.
  11401. * @param mesh The mesh to render
  11402. * @returns true if it should render otherwise false
  11403. */
  11404. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11405. /**
  11406. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11407. * @param mesh The mesh to exclude from the glow layer
  11408. */
  11409. addExcludedMesh(mesh: Mesh): void;
  11410. /**
  11411. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11412. * @param mesh The mesh to remove
  11413. */
  11414. removeExcludedMesh(mesh: Mesh): void;
  11415. /**
  11416. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11417. * @param mesh The mesh to include in the glow layer
  11418. */
  11419. addIncludedOnlyMesh(mesh: Mesh): void;
  11420. /**
  11421. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11422. * @param mesh The mesh to remove
  11423. */
  11424. removeIncludedOnlyMesh(mesh: Mesh): void;
  11425. /**
  11426. * Determine if a given mesh will be used in the glow layer
  11427. * @param mesh The mesh to test
  11428. * @returns true if the mesh will be highlighted by the current glow layer
  11429. */
  11430. hasMesh(mesh: AbstractMesh): boolean;
  11431. /**
  11432. * Free any resources and references associated to a mesh.
  11433. * Internal use
  11434. * @param mesh The mesh to free.
  11435. * @hidden
  11436. */
  11437. _disposeMesh(mesh: Mesh): void;
  11438. /**
  11439. * Gets the class name of the effect layer
  11440. * @returns the string with the class name of the effect layer
  11441. */
  11442. getClassName(): string;
  11443. /**
  11444. * Serializes this glow layer
  11445. * @returns a serialized glow layer object
  11446. */
  11447. serialize(): any;
  11448. /**
  11449. * Creates a Glow Layer from parsed glow layer data
  11450. * @param parsedGlowLayer defines glow layer data
  11451. * @param scene defines the current scene
  11452. * @param rootUrl defines the root URL containing the glow layer information
  11453. * @returns a parsed Glow Layer
  11454. */
  11455. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11456. }
  11457. }
  11458. declare module BABYLON {
  11459. interface AbstractScene {
  11460. /**
  11461. * Return a the first highlight layer of the scene with a given name.
  11462. * @param name The name of the highlight layer to look for.
  11463. * @return The highlight layer if found otherwise null.
  11464. */
  11465. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11466. }
  11467. /**
  11468. * Highlight layer options. This helps customizing the behaviour
  11469. * of the highlight layer.
  11470. */
  11471. interface IHighlightLayerOptions {
  11472. /**
  11473. * Multiplication factor apply to the canvas size to compute the render target size
  11474. * used to generated the glowing objects (the smaller the faster).
  11475. */
  11476. mainTextureRatio: number;
  11477. /**
  11478. * Enforces a fixed size texture to ensure resize independant blur.
  11479. */
  11480. mainTextureFixedSize?: number;
  11481. /**
  11482. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11483. * of the picture to blur (the smaller the faster).
  11484. */
  11485. blurTextureSizeRatio: number;
  11486. /**
  11487. * How big in texel of the blur texture is the vertical blur.
  11488. */
  11489. blurVerticalSize: number;
  11490. /**
  11491. * How big in texel of the blur texture is the horizontal blur.
  11492. */
  11493. blurHorizontalSize: number;
  11494. /**
  11495. * Alpha blending mode used to apply the blur. Default is combine.
  11496. */
  11497. alphaBlendingMode: number;
  11498. /**
  11499. * The camera attached to the layer.
  11500. */
  11501. camera: Nullable<Camera>;
  11502. /**
  11503. * Should we display highlight as a solid stroke?
  11504. */
  11505. isStroke?: boolean;
  11506. /**
  11507. * The rendering group to draw the layer in.
  11508. */
  11509. renderingGroupId: number;
  11510. }
  11511. /**
  11512. * The highlight layer Helps adding a glow effect around a mesh.
  11513. *
  11514. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11515. * glowy meshes to your scene.
  11516. *
  11517. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11518. */
  11519. class HighlightLayer extends EffectLayer {
  11520. name: string;
  11521. /**
  11522. * Effect Name of the highlight layer.
  11523. */
  11524. static readonly EffectName: string;
  11525. /**
  11526. * The neutral color used during the preparation of the glow effect.
  11527. * This is black by default as the blend operation is a blend operation.
  11528. */
  11529. static NeutralColor: Color4;
  11530. /**
  11531. * Stencil value used for glowing meshes.
  11532. */
  11533. static GlowingMeshStencilReference: number;
  11534. /**
  11535. * Stencil value used for the other meshes in the scene.
  11536. */
  11537. static NormalMeshStencilReference: number;
  11538. /**
  11539. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11540. */
  11541. innerGlow: boolean;
  11542. /**
  11543. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11544. */
  11545. outerGlow: boolean;
  11546. /**
  11547. * Specifies the horizontal size of the blur.
  11548. */
  11549. /**
  11550. * Gets the horizontal size of the blur.
  11551. */
  11552. blurHorizontalSize: number;
  11553. /**
  11554. * Specifies the vertical size of the blur.
  11555. */
  11556. /**
  11557. * Gets the vertical size of the blur.
  11558. */
  11559. blurVerticalSize: number;
  11560. /**
  11561. * An event triggered when the highlight layer is being blurred.
  11562. */
  11563. onBeforeBlurObservable: Observable<HighlightLayer>;
  11564. /**
  11565. * An event triggered when the highlight layer has been blurred.
  11566. */
  11567. onAfterBlurObservable: Observable<HighlightLayer>;
  11568. private _instanceGlowingMeshStencilReference;
  11569. private _options;
  11570. private _downSamplePostprocess;
  11571. private _horizontalBlurPostprocess;
  11572. private _verticalBlurPostprocess;
  11573. private _blurTexture;
  11574. private _meshes;
  11575. private _excludedMeshes;
  11576. /**
  11577. * Instantiates a new highlight Layer and references it to the scene..
  11578. * @param name The name of the layer
  11579. * @param scene The scene to use the layer in
  11580. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11581. */
  11582. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11583. /**
  11584. * Get the effect name of the layer.
  11585. * @return The effect name
  11586. */
  11587. getEffectName(): string;
  11588. /**
  11589. * Create the merge effect. This is the shader use to blit the information back
  11590. * to the main canvas at the end of the scene rendering.
  11591. */
  11592. protected _createMergeEffect(): Effect;
  11593. /**
  11594. * Creates the render target textures and post processes used in the highlight layer.
  11595. */
  11596. protected _createTextureAndPostProcesses(): void;
  11597. /**
  11598. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11599. */
  11600. needStencil(): boolean;
  11601. /**
  11602. * Checks for the readiness of the element composing the layer.
  11603. * @param subMesh the mesh to check for
  11604. * @param useInstances specify wether or not to use instances to render the mesh
  11605. * @param emissiveTexture the associated emissive texture used to generate the glow
  11606. * @return true if ready otherwise, false
  11607. */
  11608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11609. /**
  11610. * Implementation specific of rendering the generating effect on the main canvas.
  11611. * @param effect The effect used to render through
  11612. */
  11613. protected _internalRender(effect: Effect): void;
  11614. /**
  11615. * Returns true if the layer contains information to display, otherwise false.
  11616. */
  11617. shouldRender(): boolean;
  11618. /**
  11619. * Returns true if the mesh should render, otherwise false.
  11620. * @param mesh The mesh to render
  11621. * @returns true if it should render otherwise false
  11622. */
  11623. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11624. /**
  11625. * Sets the required values for both the emissive texture and and the main color.
  11626. */
  11627. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11628. /**
  11629. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11630. * @param mesh The mesh to exclude from the highlight layer
  11631. */
  11632. addExcludedMesh(mesh: Mesh): void;
  11633. /**
  11634. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11635. * @param mesh The mesh to highlight
  11636. */
  11637. removeExcludedMesh(mesh: Mesh): void;
  11638. /**
  11639. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11640. * @param mesh mesh to test
  11641. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11642. */
  11643. hasMesh(mesh: AbstractMesh): boolean;
  11644. /**
  11645. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11646. * @param mesh The mesh to highlight
  11647. * @param color The color of the highlight
  11648. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11649. */
  11650. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11651. /**
  11652. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11653. * @param mesh The mesh to highlight
  11654. */
  11655. removeMesh(mesh: Mesh): void;
  11656. /**
  11657. * Force the stencil to the normal expected value for none glowing parts
  11658. */
  11659. private _defaultStencilReference;
  11660. /**
  11661. * Free any resources and references associated to a mesh.
  11662. * Internal use
  11663. * @param mesh The mesh to free.
  11664. * @hidden
  11665. */
  11666. _disposeMesh(mesh: Mesh): void;
  11667. /**
  11668. * Dispose the highlight layer and free resources.
  11669. */
  11670. dispose(): void;
  11671. /**
  11672. * Gets the class name of the effect layer
  11673. * @returns the string with the class name of the effect layer
  11674. */
  11675. getClassName(): string;
  11676. /**
  11677. * Serializes this Highlight layer
  11678. * @returns a serialized Highlight layer object
  11679. */
  11680. serialize(): any;
  11681. /**
  11682. * Creates a Highlight layer from parsed Highlight layer data
  11683. * @param parsedHightlightLayer defines the Highlight layer data
  11684. * @param scene defines the current scene
  11685. * @param rootUrl defines the root URL containing the Highlight layer information
  11686. * @returns a parsed Highlight layer
  11687. */
  11688. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11689. }
  11690. }
  11691. declare module BABYLON {
  11692. class Layer {
  11693. name: string;
  11694. texture: Nullable<Texture>;
  11695. isBackground: boolean;
  11696. color: Color4;
  11697. scale: Vector2;
  11698. offset: Vector2;
  11699. alphaBlendingMode: number;
  11700. alphaTest: boolean;
  11701. layerMask: number;
  11702. private _scene;
  11703. private _vertexBuffers;
  11704. private _indexBuffer;
  11705. private _effect;
  11706. private _alphaTestEffect;
  11707. /**
  11708. * An event triggered when the layer is disposed.
  11709. */
  11710. onDisposeObservable: Observable<Layer>;
  11711. private _onDisposeObserver;
  11712. onDispose: () => void;
  11713. /**
  11714. * An event triggered before rendering the scene
  11715. */
  11716. onBeforeRenderObservable: Observable<Layer>;
  11717. private _onBeforeRenderObserver;
  11718. onBeforeRender: () => void;
  11719. /**
  11720. * An event triggered after rendering the scene
  11721. */
  11722. onAfterRenderObservable: Observable<Layer>;
  11723. private _onAfterRenderObserver;
  11724. onAfterRender: () => void;
  11725. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11726. private _createIndexBuffer;
  11727. /** @hidden */
  11728. _rebuild(): void;
  11729. render(): void;
  11730. dispose(): void;
  11731. }
  11732. }
  11733. declare module BABYLON {
  11734. interface AbstractScene {
  11735. /**
  11736. * The list of layers (background and foreground) of the scene
  11737. */
  11738. layers: Array<Layer>;
  11739. }
  11740. /**
  11741. * Defines the layer scene component responsible to manage any layers
  11742. * in a given scene.
  11743. */
  11744. class LayerSceneComponent implements ISceneComponent {
  11745. /**
  11746. * The component name helpfull to identify the component in the list of scene components.
  11747. */
  11748. readonly name: string;
  11749. /**
  11750. * The scene the component belongs to.
  11751. */
  11752. scene: Scene;
  11753. private _engine;
  11754. /**
  11755. * Creates a new instance of the component for the given scene
  11756. * @param scene Defines the scene to register the component in
  11757. */
  11758. constructor(scene: Scene);
  11759. /**
  11760. * Registers the component in a given scene
  11761. */
  11762. register(): void;
  11763. /**
  11764. * Rebuilds the elements related to this component in case of
  11765. * context lost for instance.
  11766. */
  11767. rebuild(): void;
  11768. /**
  11769. * Disposes the component and the associated ressources.
  11770. */
  11771. dispose(): void;
  11772. private _draw;
  11773. private _drawBackground;
  11774. private _drawForeground;
  11775. }
  11776. }
  11777. declare module BABYLON {
  11778. class LensFlare {
  11779. size: number;
  11780. position: number;
  11781. color: Color3;
  11782. texture: Nullable<Texture>;
  11783. alphaMode: number;
  11784. private _system;
  11785. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11786. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11787. dispose(): void;
  11788. }
  11789. }
  11790. declare module BABYLON {
  11791. class LensFlareSystem {
  11792. name: string;
  11793. lensFlares: LensFlare[];
  11794. borderLimit: number;
  11795. viewportBorder: number;
  11796. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11797. layerMask: number;
  11798. id: string;
  11799. private _scene;
  11800. private _emitter;
  11801. private _vertexBuffers;
  11802. private _indexBuffer;
  11803. private _effect;
  11804. private _positionX;
  11805. private _positionY;
  11806. private _isEnabled;
  11807. constructor(name: string, emitter: any, scene: Scene);
  11808. isEnabled: boolean;
  11809. getScene(): Scene;
  11810. getEmitter(): any;
  11811. setEmitter(newEmitter: any): void;
  11812. getEmitterPosition(): Vector3;
  11813. computeEffectivePosition(globalViewport: Viewport): boolean;
  11814. /** @hidden */
  11815. _isVisible(): boolean;
  11816. render(): boolean;
  11817. dispose(): void;
  11818. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11819. serialize(): any;
  11820. }
  11821. }
  11822. declare module BABYLON {
  11823. interface AbstractScene {
  11824. /**
  11825. * The list of lens flare system added to the scene
  11826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11827. */
  11828. lensFlareSystems: Array<LensFlareSystem>;
  11829. /**
  11830. * Removes the given lens flare system from this scene.
  11831. * @param toRemove The lens flare system to remove
  11832. * @returns The index of the removed lens flare system
  11833. */
  11834. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11835. /**
  11836. * Adds the given lens flare system to this scene
  11837. * @param newLensFlareSystem The lens flare system to add
  11838. */
  11839. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11840. /**
  11841. * Gets a lens flare system using its name
  11842. * @param name defines the name to look for
  11843. * @returns the lens flare system or null if not found
  11844. */
  11845. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11846. /**
  11847. * Gets a lens flare system using its id
  11848. * @param id defines the id to look for
  11849. * @returns the lens flare system or null if not found
  11850. */
  11851. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11852. }
  11853. /**
  11854. * Defines the lens flare scene component responsible to manage any lens flares
  11855. * in a given scene.
  11856. */
  11857. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11858. /**
  11859. * The component name helpfull to identify the component in the list of scene components.
  11860. */
  11861. readonly name: string;
  11862. /**
  11863. * The scene the component belongs to.
  11864. */
  11865. scene: Scene;
  11866. /**
  11867. * Creates a new instance of the component for the given scene
  11868. * @param scene Defines the scene to register the component in
  11869. */
  11870. constructor(scene: Scene);
  11871. /**
  11872. * Registers the component in a given scene
  11873. */
  11874. register(): void;
  11875. /**
  11876. * Rebuilds the elements related to this component in case of
  11877. * context lost for instance.
  11878. */
  11879. rebuild(): void;
  11880. /**
  11881. * Adds all the element from the container to the scene
  11882. * @param container the container holding the elements
  11883. */
  11884. addFromContainer(container: AbstractScene): void;
  11885. /**
  11886. * Removes all the elements in the container from the scene
  11887. * @param container contains the elements to remove
  11888. */
  11889. removeFromContainer(container: AbstractScene): void;
  11890. /**
  11891. * Serializes the component data to the specified json object
  11892. * @param serializationObject The object to serialize to
  11893. */
  11894. serialize(serializationObject: any): void;
  11895. /**
  11896. * Disposes the component and the associated ressources.
  11897. */
  11898. dispose(): void;
  11899. private _draw;
  11900. }
  11901. }
  11902. declare module BABYLON {
  11903. /**
  11904. * A directional light is defined by a direction (what a surprise!).
  11905. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11906. * 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.
  11907. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11908. */
  11909. class DirectionalLight extends ShadowLight {
  11910. private _shadowFrustumSize;
  11911. /**
  11912. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11913. */
  11914. /**
  11915. * Specifies a fix frustum size for the shadow generation.
  11916. */
  11917. shadowFrustumSize: number;
  11918. private _shadowOrthoScale;
  11919. /**
  11920. * Gets the shadow projection scale against the optimal computed one.
  11921. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11922. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11923. */
  11924. /**
  11925. * Sets the shadow projection scale against the optimal computed one.
  11926. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11927. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11928. */
  11929. shadowOrthoScale: number;
  11930. /**
  11931. * Automatically compute the projection matrix to best fit (including all the casters)
  11932. * on each frame.
  11933. */
  11934. autoUpdateExtends: boolean;
  11935. private _orthoLeft;
  11936. private _orthoRight;
  11937. private _orthoTop;
  11938. private _orthoBottom;
  11939. /**
  11940. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11941. * The directional light is emitted from everywhere in the given direction.
  11942. * It can cast shawdows.
  11943. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11944. * @param name The friendly name of the light
  11945. * @param direction The direction of the light
  11946. * @param scene The scene the light belongs to
  11947. */
  11948. constructor(name: string, direction: Vector3, scene: Scene);
  11949. /**
  11950. * Returns the string "DirectionalLight".
  11951. * @return The class name
  11952. */
  11953. getClassName(): string;
  11954. /**
  11955. * Returns the integer 1.
  11956. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11957. */
  11958. getTypeID(): number;
  11959. /**
  11960. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11961. * Returns the DirectionalLight Shadow projection matrix.
  11962. */
  11963. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11964. /**
  11965. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11966. * Returns the DirectionalLight Shadow projection matrix.
  11967. */
  11968. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11969. /**
  11970. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11971. * Returns the DirectionalLight Shadow projection matrix.
  11972. */
  11973. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11974. protected _buildUniformLayout(): void;
  11975. /**
  11976. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11977. * @param effect The effect to update
  11978. * @param lightIndex The index of the light in the effect to update
  11979. * @returns The directional light
  11980. */
  11981. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11982. /**
  11983. * Gets the minZ used for shadow according to both the scene and the light.
  11984. *
  11985. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11986. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11987. * @param activeCamera The camera we are returning the min for
  11988. * @returns the depth min z
  11989. */
  11990. getDepthMinZ(activeCamera: Camera): number;
  11991. /**
  11992. * Gets the maxZ used for shadow according to both the scene and the light.
  11993. *
  11994. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11995. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11996. * @param activeCamera The camera we are returning the max for
  11997. * @returns the depth max z
  11998. */
  11999. getDepthMaxZ(activeCamera: Camera): number;
  12000. /**
  12001. * Prepares the list of defines specific to the light type.
  12002. * @param defines the list of defines
  12003. * @param lightIndex defines the index of the light for the effect
  12004. */
  12005. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12006. }
  12007. }
  12008. declare module BABYLON {
  12009. /**
  12010. * The HemisphericLight simulates the ambient environment light,
  12011. * so the passed direction is the light reflection direction, not the incoming direction.
  12012. */
  12013. class HemisphericLight extends Light {
  12014. /**
  12015. * The groundColor is the light in the opposite direction to the one specified during creation.
  12016. * 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.
  12017. */
  12018. groundColor: Color3;
  12019. /**
  12020. * The light reflection direction, not the incoming direction.
  12021. */
  12022. direction: Vector3;
  12023. private _worldMatrix;
  12024. /**
  12025. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12026. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12027. * The HemisphericLight can't cast shadows.
  12028. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12029. * @param name The friendly name of the light
  12030. * @param direction The direction of the light reflection
  12031. * @param scene The scene the light belongs to
  12032. */
  12033. constructor(name: string, direction: Vector3, scene: Scene);
  12034. protected _buildUniformLayout(): void;
  12035. /**
  12036. * Returns the string "HemisphericLight".
  12037. * @return The class name
  12038. */
  12039. getClassName(): string;
  12040. /**
  12041. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12042. * Returns the updated direction.
  12043. * @param target The target the direction should point to
  12044. * @return The computed direction
  12045. */
  12046. setDirectionToTarget(target: Vector3): Vector3;
  12047. /**
  12048. * Returns the shadow generator associated to the light.
  12049. * @returns Always null for hemispheric lights because it does not support shadows.
  12050. */
  12051. getShadowGenerator(): Nullable<ShadowGenerator>;
  12052. /**
  12053. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12054. * @param effect The effect to update
  12055. * @param lightIndex The index of the light in the effect to update
  12056. * @returns The hemispheric light
  12057. */
  12058. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12059. /**
  12060. * @hidden internal use only.
  12061. */
  12062. _getWorldMatrix(): Matrix;
  12063. /**
  12064. * Returns the integer 3.
  12065. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12066. */
  12067. getTypeID(): number;
  12068. /**
  12069. * Prepares the list of defines specific to the light type.
  12070. * @param defines the list of defines
  12071. * @param lightIndex defines the index of the light for the effect
  12072. */
  12073. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12074. }
  12075. }
  12076. declare module BABYLON {
  12077. /**
  12078. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12079. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12080. * 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.
  12081. */
  12082. abstract class Light extends Node {
  12083. /**
  12084. * Falloff Default: light is falling off following the material specification:
  12085. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12086. */
  12087. static readonly FALLOFF_DEFAULT: number;
  12088. /**
  12089. * Falloff Physical: light is falling off following the inverse squared distance law.
  12090. */
  12091. static readonly FALLOFF_PHYSICAL: number;
  12092. /**
  12093. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12094. * to enhance interoperability with other engines.
  12095. */
  12096. static readonly FALLOFF_GLTF: number;
  12097. /**
  12098. * Falloff Standard: light is falling off like in the standard material
  12099. * to enhance interoperability with other materials.
  12100. */
  12101. static readonly FALLOFF_STANDARD: number;
  12102. /**
  12103. * If every light affecting the material is in this lightmapMode,
  12104. * material.lightmapTexture adds or multiplies
  12105. * (depends on material.useLightmapAsShadowmap)
  12106. * after every other light calculations.
  12107. */
  12108. static readonly LIGHTMAP_DEFAULT: number;
  12109. /**
  12110. * material.lightmapTexture as only diffuse lighting from this light
  12111. * adds only specular lighting from this light
  12112. * adds dynamic shadows
  12113. */
  12114. static readonly LIGHTMAP_SPECULAR: number;
  12115. /**
  12116. * material.lightmapTexture as only lighting
  12117. * no light calculation from this light
  12118. * only adds dynamic shadows from this light
  12119. */
  12120. static readonly LIGHTMAP_SHADOWSONLY: number;
  12121. /**
  12122. * Each light type uses the default quantity according to its type:
  12123. * point/spot lights use luminous intensity
  12124. * directional lights use illuminance
  12125. */
  12126. static readonly INTENSITYMODE_AUTOMATIC: number;
  12127. /**
  12128. * lumen (lm)
  12129. */
  12130. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12131. /**
  12132. * candela (lm/sr)
  12133. */
  12134. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12135. /**
  12136. * lux (lm/m^2)
  12137. */
  12138. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12139. /**
  12140. * nit (cd/m^2)
  12141. */
  12142. static readonly INTENSITYMODE_LUMINANCE: number;
  12143. /**
  12144. * Light type const id of the point light.
  12145. */
  12146. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12147. /**
  12148. * Light type const id of the directional light.
  12149. */
  12150. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12151. /**
  12152. * Light type const id of the spot light.
  12153. */
  12154. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12155. /**
  12156. * Light type const id of the hemispheric light.
  12157. */
  12158. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12159. /**
  12160. * Diffuse gives the basic color to an object.
  12161. */
  12162. diffuse: Color3;
  12163. /**
  12164. * Specular produces a highlight color on an object.
  12165. * Note: This is note affecting PBR materials.
  12166. */
  12167. specular: Color3;
  12168. /**
  12169. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12170. * falling off base on range or angle.
  12171. * This can be set to any values in Light.FALLOFF_x.
  12172. *
  12173. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12174. * other types of materials.
  12175. */
  12176. falloffType: number;
  12177. /**
  12178. * Strength of the light.
  12179. * Note: By default it is define in the framework own unit.
  12180. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12181. */
  12182. intensity: number;
  12183. private _range;
  12184. protected _inverseSquaredRange: number;
  12185. /**
  12186. * Defines how far from the source the light is impacting in scene units.
  12187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12188. */
  12189. /**
  12190. * Defines how far from the source the light is impacting in scene units.
  12191. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12192. */
  12193. range: number;
  12194. /**
  12195. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12196. * of light.
  12197. */
  12198. private _photometricScale;
  12199. private _intensityMode;
  12200. /**
  12201. * Gets the photometric scale used to interpret the intensity.
  12202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12203. */
  12204. /**
  12205. * Sets the photometric scale used to interpret the intensity.
  12206. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12207. */
  12208. intensityMode: number;
  12209. private _radius;
  12210. /**
  12211. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12212. */
  12213. /**
  12214. * sets the light radius used by PBR Materials to simulate soft area lights.
  12215. */
  12216. radius: number;
  12217. private _renderPriority;
  12218. /**
  12219. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12220. * exceeding the number allowed of the materials.
  12221. */
  12222. renderPriority: number;
  12223. private _shadowEnabled;
  12224. /**
  12225. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12226. * the current shadow generator.
  12227. */
  12228. /**
  12229. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12230. * the current shadow generator.
  12231. */
  12232. shadowEnabled: boolean;
  12233. private _includedOnlyMeshes;
  12234. /**
  12235. * Gets the only meshes impacted by this light.
  12236. */
  12237. /**
  12238. * Sets the only meshes impacted by this light.
  12239. */
  12240. includedOnlyMeshes: AbstractMesh[];
  12241. private _excludedMeshes;
  12242. /**
  12243. * Gets the meshes not impacted by this light.
  12244. */
  12245. /**
  12246. * Sets the meshes not impacted by this light.
  12247. */
  12248. excludedMeshes: AbstractMesh[];
  12249. private _excludeWithLayerMask;
  12250. /**
  12251. * Gets the layer id use to find what meshes are not impacted by the light.
  12252. * Inactive if 0
  12253. */
  12254. /**
  12255. * Sets the layer id use to find what meshes are not impacted by the light.
  12256. * Inactive if 0
  12257. */
  12258. excludeWithLayerMask: number;
  12259. private _includeOnlyWithLayerMask;
  12260. /**
  12261. * Gets the layer id use to find what meshes are impacted by the light.
  12262. * Inactive if 0
  12263. */
  12264. /**
  12265. * Sets the layer id use to find what meshes are impacted by the light.
  12266. * Inactive if 0
  12267. */
  12268. includeOnlyWithLayerMask: number;
  12269. private _lightmapMode;
  12270. /**
  12271. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12272. */
  12273. /**
  12274. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12275. */
  12276. lightmapMode: number;
  12277. private _parentedWorldMatrix;
  12278. /**
  12279. * Shadow generator associted to the light.
  12280. * @hidden Internal use only.
  12281. */
  12282. _shadowGenerator: Nullable<IShadowGenerator>;
  12283. /**
  12284. * @hidden Internal use only.
  12285. */
  12286. _excludedMeshesIds: string[];
  12287. /**
  12288. * @hidden Internal use only.
  12289. */
  12290. _includedOnlyMeshesIds: string[];
  12291. /**
  12292. * The current light unifom buffer.
  12293. * @hidden Internal use only.
  12294. */
  12295. _uniformBuffer: UniformBuffer;
  12296. /**
  12297. * Creates a Light object in the scene.
  12298. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12299. * @param name The firendly name of the light
  12300. * @param scene The scene the light belongs too
  12301. */
  12302. constructor(name: string, scene: Scene);
  12303. protected abstract _buildUniformLayout(): void;
  12304. /**
  12305. * Sets the passed Effect "effect" with the Light information.
  12306. * @param effect The effect to update
  12307. * @param lightIndex The index of the light in the effect to update
  12308. * @returns The light
  12309. */
  12310. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12311. /**
  12312. * @hidden internal use only.
  12313. */
  12314. abstract _getWorldMatrix(): Matrix;
  12315. /**
  12316. * Returns the string "Light".
  12317. * @returns the class name
  12318. */
  12319. getClassName(): string;
  12320. /**
  12321. * Converts the light information to a readable string for debug purpose.
  12322. * @param fullDetails Supports for multiple levels of logging within scene loading
  12323. * @returns the human readable light info
  12324. */
  12325. toString(fullDetails?: boolean): string;
  12326. /**
  12327. * Set the enabled state of this node.
  12328. * @param value - the new enabled state
  12329. */
  12330. setEnabled(value: boolean): void;
  12331. /**
  12332. * Returns the Light associated shadow generator if any.
  12333. * @return the associated shadow generator.
  12334. */
  12335. getShadowGenerator(): Nullable<IShadowGenerator>;
  12336. /**
  12337. * Returns a Vector3, the absolute light position in the World.
  12338. * @returns the world space position of the light
  12339. */
  12340. getAbsolutePosition(): Vector3;
  12341. /**
  12342. * Specifies if the light will affect the passed mesh.
  12343. * @param mesh The mesh to test against the light
  12344. * @return true the mesh is affected otherwise, false.
  12345. */
  12346. canAffectMesh(mesh: AbstractMesh): boolean;
  12347. /**
  12348. * Computes and Returns the light World matrix.
  12349. * @returns the world matrix
  12350. */
  12351. getWorldMatrix(): Matrix;
  12352. /**
  12353. * Sort function to order lights for rendering.
  12354. * @param a First Light object to compare to second.
  12355. * @param b Second Light object to compare first.
  12356. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12357. */
  12358. static CompareLightsPriority(a: Light, b: Light): number;
  12359. /**
  12360. * Releases resources associated with this node.
  12361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12363. */
  12364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12365. /**
  12366. * Returns the light type ID (integer).
  12367. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12368. */
  12369. getTypeID(): number;
  12370. /**
  12371. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12372. * @returns the scaled intensity in intensity mode unit
  12373. */
  12374. getScaledIntensity(): number;
  12375. /**
  12376. * Returns a new Light object, named "name", from the current one.
  12377. * @param name The name of the cloned light
  12378. * @returns the new created light
  12379. */
  12380. clone(name: string): Nullable<Light>;
  12381. /**
  12382. * Serializes the current light into a Serialization object.
  12383. * @returns the serialized object.
  12384. */
  12385. serialize(): any;
  12386. /**
  12387. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12388. * This new light is named "name" and added to the passed scene.
  12389. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12390. * @param name The friendly name of the light
  12391. * @param scene The scene the new light will belong to
  12392. * @returns the constructor function
  12393. */
  12394. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12395. /**
  12396. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12397. * @param parsedLight The JSON representation of the light
  12398. * @param scene The scene to create the parsed light in
  12399. * @returns the created light after parsing
  12400. */
  12401. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12402. private _hookArrayForExcluded;
  12403. private _hookArrayForIncludedOnly;
  12404. private _resyncMeshes;
  12405. /**
  12406. * Forces the meshes to update their light related information in their rendering used effects
  12407. * @hidden Internal Use Only
  12408. */
  12409. _markMeshesAsLightDirty(): void;
  12410. /**
  12411. * Recomputes the cached photometric scale if needed.
  12412. */
  12413. private _computePhotometricScale;
  12414. /**
  12415. * Returns the Photometric Scale according to the light type and intensity mode.
  12416. */
  12417. private _getPhotometricScale;
  12418. /**
  12419. * Reorder the light in the scene according to their defined priority.
  12420. * @hidden Internal Use Only
  12421. */
  12422. _reorderLightsInScene(): void;
  12423. /**
  12424. * Prepares the list of defines specific to the light type.
  12425. * @param defines the list of defines
  12426. * @param lightIndex defines the index of the light for the effect
  12427. */
  12428. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12429. }
  12430. }
  12431. declare module BABYLON {
  12432. /**
  12433. * A point light is a light defined by an unique point in world space.
  12434. * The light is emitted in every direction from this point.
  12435. * A good example of a point light is a standard light bulb.
  12436. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12437. */
  12438. class PointLight extends ShadowLight {
  12439. private _shadowAngle;
  12440. /**
  12441. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12442. * This specifies what angle the shadow will use to be created.
  12443. *
  12444. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12445. */
  12446. /**
  12447. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12448. * This specifies what angle the shadow will use to be created.
  12449. *
  12450. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12451. */
  12452. shadowAngle: number;
  12453. /**
  12454. * Gets the direction if it has been set.
  12455. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12456. */
  12457. /**
  12458. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12459. */
  12460. direction: Vector3;
  12461. /**
  12462. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12463. * A PointLight emits the light in every direction.
  12464. * It can cast shadows.
  12465. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12466. * ```javascript
  12467. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12468. * ```
  12469. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12470. * @param name The light friendly name
  12471. * @param position The position of the point light in the scene
  12472. * @param scene The scene the lights belongs to
  12473. */
  12474. constructor(name: string, position: Vector3, scene: Scene);
  12475. /**
  12476. * Returns the string "PointLight"
  12477. * @returns the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Returns the integer 0.
  12482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12483. */
  12484. getTypeID(): number;
  12485. /**
  12486. * Specifies wether or not the shadowmap should be a cube texture.
  12487. * @returns true if the shadowmap needs to be a cube texture.
  12488. */
  12489. needCube(): boolean;
  12490. /**
  12491. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12492. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12493. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12494. */
  12495. getShadowDirection(faceIndex?: number): Vector3;
  12496. /**
  12497. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12498. * - fov = PI / 2
  12499. * - aspect ratio : 1.0
  12500. * - z-near and far equal to the active camera minZ and maxZ.
  12501. * Returns the PointLight.
  12502. */
  12503. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12504. protected _buildUniformLayout(): void;
  12505. /**
  12506. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12507. * @param effect The effect to update
  12508. * @param lightIndex The index of the light in the effect to update
  12509. * @returns The point light
  12510. */
  12511. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12512. /**
  12513. * Prepares the list of defines specific to the light type.
  12514. * @param defines the list of defines
  12515. * @param lightIndex defines the index of the light for the effect
  12516. */
  12517. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12518. }
  12519. }
  12520. declare module BABYLON {
  12521. /**
  12522. * Interface describing all the common properties and methods a shadow light needs to implement.
  12523. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12524. * as well as binding the different shadow properties to the effects.
  12525. */
  12526. interface IShadowLight extends Light {
  12527. /**
  12528. * The light id in the scene (used in scene.findLighById for instance)
  12529. */
  12530. id: string;
  12531. /**
  12532. * The position the shdow will be casted from.
  12533. */
  12534. position: Vector3;
  12535. /**
  12536. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12537. */
  12538. direction: Vector3;
  12539. /**
  12540. * The transformed position. Position of the light in world space taking parenting in account.
  12541. */
  12542. transformedPosition: Vector3;
  12543. /**
  12544. * The transformed direction. Direction of the light in world space taking parenting in account.
  12545. */
  12546. transformedDirection: Vector3;
  12547. /**
  12548. * The friendly name of the light in the scene.
  12549. */
  12550. name: string;
  12551. /**
  12552. * Defines the shadow projection clipping minimum z value.
  12553. */
  12554. shadowMinZ: number;
  12555. /**
  12556. * Defines the shadow projection clipping maximum z value.
  12557. */
  12558. shadowMaxZ: number;
  12559. /**
  12560. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12561. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12562. */
  12563. computeTransformedInformation(): boolean;
  12564. /**
  12565. * Gets the scene the light belongs to.
  12566. * @returns The scene
  12567. */
  12568. getScene(): Scene;
  12569. /**
  12570. * Callback defining a custom Projection Matrix Builder.
  12571. * This can be used to override the default projection matrix computation.
  12572. */
  12573. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12574. /**
  12575. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12576. * @param matrix The materix to updated with the projection information
  12577. * @param viewMatrix The transform matrix of the light
  12578. * @param renderList The list of mesh to render in the map
  12579. * @returns The current light
  12580. */
  12581. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12582. /**
  12583. * Gets the current depth scale used in ESM.
  12584. * @returns The scale
  12585. */
  12586. getDepthScale(): number;
  12587. /**
  12588. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12589. * @returns true if a cube texture needs to be use
  12590. */
  12591. needCube(): boolean;
  12592. /**
  12593. * Detects if the projection matrix requires to be recomputed this frame.
  12594. * @returns true if it requires to be recomputed otherwise, false.
  12595. */
  12596. needProjectionMatrixCompute(): boolean;
  12597. /**
  12598. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12599. */
  12600. forceProjectionMatrixCompute(): void;
  12601. /**
  12602. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12603. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12604. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12605. */
  12606. getShadowDirection(faceIndex?: number): Vector3;
  12607. /**
  12608. * Gets the minZ used for shadow according to both the scene and the light.
  12609. * @param activeCamera The camera we are returning the min for
  12610. * @returns the depth min z
  12611. */
  12612. getDepthMinZ(activeCamera: Camera): number;
  12613. /**
  12614. * Gets the maxZ used for shadow according to both the scene and the light.
  12615. * @param activeCamera The camera we are returning the max for
  12616. * @returns the depth max z
  12617. */
  12618. getDepthMaxZ(activeCamera: Camera): number;
  12619. }
  12620. /**
  12621. * Base implementation IShadowLight
  12622. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12623. */
  12624. abstract class ShadowLight extends Light implements IShadowLight {
  12625. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12626. protected _position: Vector3;
  12627. protected _setPosition(value: Vector3): void;
  12628. /**
  12629. * Sets the position the shadow will be casted from. Also use as the light position for both
  12630. * point and spot lights.
  12631. */
  12632. /**
  12633. * Sets the position the shadow will be casted from. Also use as the light position for both
  12634. * point and spot lights.
  12635. */
  12636. position: Vector3;
  12637. protected _direction: Vector3;
  12638. protected _setDirection(value: Vector3): void;
  12639. /**
  12640. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12641. * Also use as the light direction on spot and directional lights.
  12642. */
  12643. /**
  12644. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12645. * Also use as the light direction on spot and directional lights.
  12646. */
  12647. direction: Vector3;
  12648. private _shadowMinZ;
  12649. /**
  12650. * Gets the shadow projection clipping minimum z value.
  12651. */
  12652. /**
  12653. * Sets the shadow projection clipping minimum z value.
  12654. */
  12655. shadowMinZ: number;
  12656. private _shadowMaxZ;
  12657. /**
  12658. * Sets the shadow projection clipping maximum z value.
  12659. */
  12660. /**
  12661. * Gets the shadow projection clipping maximum z value.
  12662. */
  12663. shadowMaxZ: number;
  12664. /**
  12665. * Callback defining a custom Projection Matrix Builder.
  12666. * This can be used to override the default projection matrix computation.
  12667. */
  12668. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12669. /**
  12670. * The transformed position. Position of the light in world space taking parenting in account.
  12671. */
  12672. transformedPosition: Vector3;
  12673. /**
  12674. * The transformed direction. Direction of the light in world space taking parenting in account.
  12675. */
  12676. transformedDirection: Vector3;
  12677. private _worldMatrix;
  12678. private _needProjectionMatrixCompute;
  12679. /**
  12680. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12681. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12682. */
  12683. computeTransformedInformation(): boolean;
  12684. /**
  12685. * Return the depth scale used for the shadow map.
  12686. * @returns the depth scale.
  12687. */
  12688. getDepthScale(): number;
  12689. /**
  12690. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12691. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12692. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12693. */
  12694. getShadowDirection(faceIndex?: number): Vector3;
  12695. /**
  12696. * Returns the ShadowLight absolute position in the World.
  12697. * @returns the position vector in world space
  12698. */
  12699. getAbsolutePosition(): Vector3;
  12700. /**
  12701. * Sets the ShadowLight direction toward the passed target.
  12702. * @param target The point tot target in local space
  12703. * @returns the updated ShadowLight direction
  12704. */
  12705. setDirectionToTarget(target: Vector3): Vector3;
  12706. /**
  12707. * Returns the light rotation in euler definition.
  12708. * @returns the x y z rotation in local space.
  12709. */
  12710. getRotation(): Vector3;
  12711. /**
  12712. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12713. * @returns true if a cube texture needs to be use
  12714. */
  12715. needCube(): boolean;
  12716. /**
  12717. * Detects if the projection matrix requires to be recomputed this frame.
  12718. * @returns true if it requires to be recomputed otherwise, false.
  12719. */
  12720. needProjectionMatrixCompute(): boolean;
  12721. /**
  12722. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12723. */
  12724. forceProjectionMatrixCompute(): void;
  12725. /**
  12726. * Get the world matrix of the sahdow lights.
  12727. * @hidden Internal Use Only
  12728. */
  12729. _getWorldMatrix(): Matrix;
  12730. /**
  12731. * Gets the minZ used for shadow according to both the scene and the light.
  12732. * @param activeCamera The camera we are returning the min for
  12733. * @returns the depth min z
  12734. */
  12735. getDepthMinZ(activeCamera: Camera): number;
  12736. /**
  12737. * Gets the maxZ used for shadow according to both the scene and the light.
  12738. * @param activeCamera The camera we are returning the max for
  12739. * @returns the depth max z
  12740. */
  12741. getDepthMaxZ(activeCamera: Camera): number;
  12742. /**
  12743. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12744. * @param matrix The materix to updated with the projection information
  12745. * @param viewMatrix The transform matrix of the light
  12746. * @param renderList The list of mesh to render in the map
  12747. * @returns The current light
  12748. */
  12749. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12750. }
  12751. }
  12752. declare module BABYLON {
  12753. /**
  12754. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12755. * These values define a cone of light starting from the position, emitting toward the direction.
  12756. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12757. * and the exponent defines the speed of the decay of the light with distance (reach).
  12758. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12759. */
  12760. class SpotLight extends ShadowLight {
  12761. private _angle;
  12762. private _innerAngle;
  12763. private _cosHalfAngle;
  12764. private _lightAngleScale;
  12765. private _lightAngleOffset;
  12766. /**
  12767. * Gets the cone angle of the spot light in Radians.
  12768. */
  12769. /**
  12770. * Sets the cone angle of the spot light in Radians.
  12771. */
  12772. angle: number;
  12773. /**
  12774. * Only used in gltf falloff mode, this defines the angle where
  12775. * the directional falloff will start before cutting at angle which could be seen
  12776. * as outer angle.
  12777. */
  12778. /**
  12779. * Only used in gltf falloff mode, this defines the angle where
  12780. * the directional falloff will start before cutting at angle which could be seen
  12781. * as outer angle.
  12782. */
  12783. innerAngle: number;
  12784. private _shadowAngleScale;
  12785. /**
  12786. * Allows scaling the angle of the light for shadow generation only.
  12787. */
  12788. /**
  12789. * Allows scaling the angle of the light for shadow generation only.
  12790. */
  12791. shadowAngleScale: number;
  12792. /**
  12793. * The light decay speed with the distance from the emission spot.
  12794. */
  12795. exponent: number;
  12796. private _projectionTextureMatrix;
  12797. /**
  12798. * Allows reading the projecton texture
  12799. */
  12800. readonly projectionTextureMatrix: Matrix;
  12801. protected _projectionTextureLightNear: number;
  12802. /**
  12803. * Gets the near clip of the Spotlight for texture projection.
  12804. */
  12805. /**
  12806. * Sets the near clip of the Spotlight for texture projection.
  12807. */
  12808. projectionTextureLightNear: number;
  12809. protected _projectionTextureLightFar: number;
  12810. /**
  12811. * Gets the far clip of the Spotlight for texture projection.
  12812. */
  12813. /**
  12814. * Sets the far clip of the Spotlight for texture projection.
  12815. */
  12816. projectionTextureLightFar: number;
  12817. protected _projectionTextureUpDirection: Vector3;
  12818. /**
  12819. * Gets the Up vector of the Spotlight for texture projection.
  12820. */
  12821. /**
  12822. * Sets the Up vector of the Spotlight for texture projection.
  12823. */
  12824. projectionTextureUpDirection: Vector3;
  12825. private _projectionTexture;
  12826. /**
  12827. * Gets the projection texture of the light.
  12828. */
  12829. /**
  12830. * Sets the projection texture of the light.
  12831. */
  12832. projectionTexture: Nullable<BaseTexture>;
  12833. private _projectionTextureViewLightDirty;
  12834. private _projectionTextureProjectionLightDirty;
  12835. private _projectionTextureDirty;
  12836. private _projectionTextureViewTargetVector;
  12837. private _projectionTextureViewLightMatrix;
  12838. private _projectionTextureProjectionLightMatrix;
  12839. private _projectionTextureScalingMatrix;
  12840. /**
  12841. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12842. * It can cast shadows.
  12843. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12844. * @param name The light friendly name
  12845. * @param position The position of the spot light in the scene
  12846. * @param direction The direction of the light in the scene
  12847. * @param angle The cone angle of the light in Radians
  12848. * @param exponent The light decay speed with the distance from the emission spot
  12849. * @param scene The scene the lights belongs to
  12850. */
  12851. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12852. /**
  12853. * Returns the string "SpotLight".
  12854. * @returns the class name
  12855. */
  12856. getClassName(): string;
  12857. /**
  12858. * Returns the integer 2.
  12859. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12860. */
  12861. getTypeID(): number;
  12862. /**
  12863. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12864. */
  12865. protected _setDirection(value: Vector3): void;
  12866. /**
  12867. * Overrides the position setter to recompute the projection texture view light Matrix.
  12868. */
  12869. protected _setPosition(value: Vector3): void;
  12870. /**
  12871. * 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.
  12872. * Returns the SpotLight.
  12873. */
  12874. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12875. protected _computeProjectionTextureViewLightMatrix(): void;
  12876. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12877. /**
  12878. * Main function for light texture projection matrix computing.
  12879. */
  12880. protected _computeProjectionTextureMatrix(): void;
  12881. protected _buildUniformLayout(): void;
  12882. private _computeAngleValues;
  12883. /**
  12884. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12885. * @param effect The effect to update
  12886. * @param lightIndex The index of the light in the effect to update
  12887. * @returns The spot light
  12888. */
  12889. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12890. /**
  12891. * Disposes the light and the associated resources.
  12892. */
  12893. dispose(): void;
  12894. /**
  12895. * Prepares the list of defines specific to the light type.
  12896. * @param defines the list of defines
  12897. * @param lightIndex defines the index of the light for the effect
  12898. */
  12899. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12900. }
  12901. }
  12902. declare module BABYLON {
  12903. interface ILoadingScreen {
  12904. displayLoadingUI: () => void;
  12905. hideLoadingUI: () => void;
  12906. loadingUIBackgroundColor: string;
  12907. loadingUIText: string;
  12908. }
  12909. class DefaultLoadingScreen implements ILoadingScreen {
  12910. private _renderingCanvas;
  12911. private _loadingText;
  12912. private _loadingDivBackgroundColor;
  12913. private _loadingDiv;
  12914. private _loadingTextDiv;
  12915. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12916. displayLoadingUI(): void;
  12917. hideLoadingUI(): void;
  12918. loadingUIText: string;
  12919. loadingUIBackgroundColor: string;
  12920. private _resizeLoadingUI;
  12921. }
  12922. }
  12923. declare module BABYLON {
  12924. class SceneLoaderProgressEvent {
  12925. readonly lengthComputable: boolean;
  12926. readonly loaded: number;
  12927. readonly total: number;
  12928. constructor(lengthComputable: boolean, loaded: number, total: number);
  12929. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12930. }
  12931. interface ISceneLoaderPluginExtensions {
  12932. [extension: string]: {
  12933. isBinary: boolean;
  12934. };
  12935. }
  12936. interface ISceneLoaderPluginFactory {
  12937. name: string;
  12938. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12939. canDirectLoad?: (data: string) => boolean;
  12940. }
  12941. interface ISceneLoaderPlugin {
  12942. /**
  12943. * The friendly name of this plugin.
  12944. */
  12945. name: string;
  12946. /**
  12947. * The file extensions supported by this plugin.
  12948. */
  12949. extensions: string | ISceneLoaderPluginExtensions;
  12950. /**
  12951. * Import meshes into a scene.
  12952. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12953. * @param scene The scene to import into
  12954. * @param data The data to import
  12955. * @param rootUrl The root url for scene and resources
  12956. * @param meshes The meshes array to import into
  12957. * @param particleSystems The particle systems array to import into
  12958. * @param skeletons The skeletons array to import into
  12959. * @param onError The callback when import fails
  12960. * @returns True if successful or false otherwise
  12961. */
  12962. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12963. /**
  12964. * Load into a scene.
  12965. * @param scene The scene to load into
  12966. * @param data The data to import
  12967. * @param rootUrl The root url for scene and resources
  12968. * @param onError The callback when import fails
  12969. * @returns true if successful or false otherwise
  12970. */
  12971. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12972. /**
  12973. * The callback that returns true if the data can be directly loaded.
  12974. */
  12975. canDirectLoad?: (data: string) => boolean;
  12976. /**
  12977. * The callback that allows custom handling of the root url based on the response url.
  12978. */
  12979. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12980. /**
  12981. * Load into an asset container.
  12982. * @param scene The scene to load into
  12983. * @param data The data to import
  12984. * @param rootUrl The root url for scene and resources
  12985. * @param onError The callback when import fails
  12986. * @returns The loaded asset container
  12987. */
  12988. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12989. }
  12990. interface ISceneLoaderPluginAsync {
  12991. /**
  12992. * The friendly name of this plugin.
  12993. */
  12994. name: string;
  12995. /**
  12996. * The file extensions supported by this plugin.
  12997. */
  12998. extensions: string | ISceneLoaderPluginExtensions;
  12999. /**
  13000. * Import meshes into a scene.
  13001. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13002. * @param scene The scene to import into
  13003. * @param data The data to import
  13004. * @param rootUrl The root url for scene and resources
  13005. * @param onProgress The callback when the load progresses
  13006. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13007. */
  13008. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  13009. meshes: AbstractMesh[];
  13010. particleSystems: IParticleSystem[];
  13011. skeletons: Skeleton[];
  13012. animationGroups: AnimationGroup[];
  13013. }>;
  13014. /**
  13015. * Load into a scene.
  13016. * @param scene The scene to load into
  13017. * @param data The data to import
  13018. * @param rootUrl The root url for scene and resources
  13019. * @param onProgress The callback when the load progresses
  13020. * @returns Nothing
  13021. */
  13022. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  13023. /**
  13024. * The callback that returns true if the data can be directly loaded.
  13025. */
  13026. canDirectLoad?: (data: string) => boolean;
  13027. /**
  13028. * The callback that allows custom handling of the root url based on the response url.
  13029. */
  13030. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13031. /**
  13032. * Load into an asset container.
  13033. * @param scene The scene to load into
  13034. * @param data The data to import
  13035. * @param rootUrl The root url for scene and resources
  13036. * @param onProgress The callback when the load progresses
  13037. * @returns The loaded asset container
  13038. */
  13039. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  13040. }
  13041. class SceneLoader {
  13042. private static _ForceFullSceneLoadingForIncremental;
  13043. private static _ShowLoadingScreen;
  13044. private static _CleanBoneMatrixWeights;
  13045. static readonly NO_LOGGING: number;
  13046. static readonly MINIMAL_LOGGING: number;
  13047. static readonly SUMMARY_LOGGING: number;
  13048. static readonly DETAILED_LOGGING: number;
  13049. private static _loggingLevel;
  13050. static ForceFullSceneLoadingForIncremental: boolean;
  13051. static ShowLoadingScreen: boolean;
  13052. static loggingLevel: number;
  13053. static CleanBoneMatrixWeights: boolean;
  13054. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13055. private static _registeredPlugins;
  13056. private static _getDefaultPlugin;
  13057. private static _getPluginForExtension;
  13058. private static _getPluginForDirectLoad;
  13059. private static _getPluginForFilename;
  13060. private static _getDirectLoad;
  13061. private static _loadData;
  13062. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13063. static IsPluginForExtensionAvailable(extension: string): boolean;
  13064. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13065. /**
  13066. * Import meshes into a scene
  13067. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13068. * @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)
  13069. * @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)
  13070. * @param scene the instance of BABYLON.Scene to append to
  13071. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13072. * @param onProgress a callback with a progress event for each file being loaded
  13073. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13074. * @param pluginExtension the extension used to determine the plugin
  13075. * @returns The loaded plugin
  13076. */
  13077. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13078. /**
  13079. * Import meshes into a scene
  13080. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13081. * @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)
  13082. * @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)
  13083. * @param scene the instance of BABYLON.Scene to append to
  13084. * @param onProgress a callback with a progress event for each file being loaded
  13085. * @param pluginExtension the extension used to determine the plugin
  13086. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13087. */
  13088. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13089. meshes: AbstractMesh[];
  13090. particleSystems: IParticleSystem[];
  13091. skeletons: Skeleton[];
  13092. animationGroups: AnimationGroup[];
  13093. }>;
  13094. /**
  13095. * Load a scene
  13096. * @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)
  13097. * @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)
  13098. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13099. * @param onSuccess a callback with the scene when import succeeds
  13100. * @param onProgress a callback with a progress event for each file being loaded
  13101. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13102. * @param pluginExtension the extension used to determine the plugin
  13103. * @returns The loaded plugin
  13104. */
  13105. 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>;
  13106. /**
  13107. * Load a scene
  13108. * @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)
  13109. * @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)
  13110. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13111. * @param onProgress a callback with a progress event for each file being loaded
  13112. * @param pluginExtension the extension used to determine the plugin
  13113. * @returns The loaded scene
  13114. */
  13115. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13116. /**
  13117. * Append a scene
  13118. * @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)
  13119. * @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)
  13120. * @param scene is the instance of BABYLON.Scene to append to
  13121. * @param onSuccess a callback with the scene when import succeeds
  13122. * @param onProgress a callback with a progress event for each file being loaded
  13123. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13124. * @param pluginExtension the extension used to determine the plugin
  13125. * @returns The loaded plugin
  13126. */
  13127. 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>;
  13128. /**
  13129. * Append a scene
  13130. * @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)
  13131. * @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)
  13132. * @param scene is the instance of BABYLON.Scene to append to
  13133. * @param onProgress a callback with a progress event for each file being loaded
  13134. * @param pluginExtension the extension used to determine the plugin
  13135. * @returns The given scene
  13136. */
  13137. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13138. /**
  13139. * Load a scene into an asset container
  13140. * @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)
  13141. * @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)
  13142. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13143. * @param onSuccess a callback with the scene when import succeeds
  13144. * @param onProgress a callback with a progress event for each file being loaded
  13145. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13146. * @param pluginExtension the extension used to determine the plugin
  13147. * @returns The loaded plugin
  13148. */
  13149. 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>;
  13150. /**
  13151. * Load a scene into an asset container
  13152. * @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)
  13153. * @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)
  13154. * @param scene is the instance of BABYLON.Scene to append to
  13155. * @param onProgress a callback with a progress event for each file being loaded
  13156. * @param pluginExtension the extension used to determine the plugin
  13157. * @returns The loaded asset container
  13158. */
  13159. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13160. }
  13161. }
  13162. declare module BABYLON {
  13163. /**
  13164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13166. * 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;
  13167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13168. */
  13169. class ColorCurves {
  13170. private _dirty;
  13171. private _tempColor;
  13172. private _globalCurve;
  13173. private _highlightsCurve;
  13174. private _midtonesCurve;
  13175. private _shadowsCurve;
  13176. private _positiveCurve;
  13177. private _negativeCurve;
  13178. private _globalHue;
  13179. private _globalDensity;
  13180. private _globalSaturation;
  13181. private _globalExposure;
  13182. /**
  13183. * Gets the global Hue value.
  13184. * 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).
  13185. */
  13186. /**
  13187. * Sets the global Hue value.
  13188. * 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).
  13189. */
  13190. globalHue: number;
  13191. /**
  13192. * Gets the global Density value.
  13193. * 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.
  13194. * Values less than zero provide a filter of opposite hue.
  13195. */
  13196. /**
  13197. * Sets the global Density value.
  13198. * 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.
  13199. * Values less than zero provide a filter of opposite hue.
  13200. */
  13201. globalDensity: number;
  13202. /**
  13203. * Gets the global Saturation value.
  13204. * 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.
  13205. */
  13206. /**
  13207. * Sets the global Saturation value.
  13208. * 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.
  13209. */
  13210. globalSaturation: number;
  13211. /**
  13212. * Gets the global Exposure value.
  13213. * 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.
  13214. */
  13215. /**
  13216. * Sets the global Exposure value.
  13217. * 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.
  13218. */
  13219. globalExposure: number;
  13220. private _highlightsHue;
  13221. private _highlightsDensity;
  13222. private _highlightsSaturation;
  13223. private _highlightsExposure;
  13224. /**
  13225. * Gets the highlights Hue value.
  13226. * 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).
  13227. */
  13228. /**
  13229. * Sets the highlights Hue value.
  13230. * 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).
  13231. */
  13232. highlightsHue: number;
  13233. /**
  13234. * Gets the highlights Density value.
  13235. * 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.
  13236. * Values less than zero provide a filter of opposite hue.
  13237. */
  13238. /**
  13239. * Sets the highlights Density value.
  13240. * 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.
  13241. * Values less than zero provide a filter of opposite hue.
  13242. */
  13243. highlightsDensity: number;
  13244. /**
  13245. * Gets the highlights Saturation value.
  13246. * 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.
  13247. */
  13248. /**
  13249. * Sets the highlights Saturation value.
  13250. * 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.
  13251. */
  13252. highlightsSaturation: number;
  13253. /**
  13254. * Gets the highlights Exposure value.
  13255. * 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.
  13256. */
  13257. /**
  13258. * Sets the highlights Exposure value.
  13259. * 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.
  13260. */
  13261. highlightsExposure: number;
  13262. private _midtonesHue;
  13263. private _midtonesDensity;
  13264. private _midtonesSaturation;
  13265. private _midtonesExposure;
  13266. /**
  13267. * Gets the midtones Hue value.
  13268. * 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).
  13269. */
  13270. /**
  13271. * Sets the midtones Hue value.
  13272. * 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).
  13273. */
  13274. midtonesHue: number;
  13275. /**
  13276. * Gets the midtones Density value.
  13277. * 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.
  13278. * Values less than zero provide a filter of opposite hue.
  13279. */
  13280. /**
  13281. * Sets the midtones Density value.
  13282. * 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.
  13283. * Values less than zero provide a filter of opposite hue.
  13284. */
  13285. midtonesDensity: number;
  13286. /**
  13287. * Gets the midtones Saturation value.
  13288. * 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.
  13289. */
  13290. /**
  13291. * Sets the midtones Saturation value.
  13292. * 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.
  13293. */
  13294. midtonesSaturation: number;
  13295. /**
  13296. * Gets the midtones Exposure value.
  13297. * 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.
  13298. */
  13299. /**
  13300. * Sets the midtones Exposure value.
  13301. * 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.
  13302. */
  13303. midtonesExposure: number;
  13304. private _shadowsHue;
  13305. private _shadowsDensity;
  13306. private _shadowsSaturation;
  13307. private _shadowsExposure;
  13308. /**
  13309. * Gets the shadows Hue value.
  13310. * 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).
  13311. */
  13312. /**
  13313. * Sets the shadows Hue value.
  13314. * 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).
  13315. */
  13316. shadowsHue: number;
  13317. /**
  13318. * Gets the shadows Density value.
  13319. * 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.
  13320. * Values less than zero provide a filter of opposite hue.
  13321. */
  13322. /**
  13323. * Sets the shadows Density value.
  13324. * 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.
  13325. * Values less than zero provide a filter of opposite hue.
  13326. */
  13327. shadowsDensity: number;
  13328. /**
  13329. * Gets the shadows Saturation value.
  13330. * 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.
  13331. */
  13332. /**
  13333. * Sets the shadows Saturation value.
  13334. * 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.
  13335. */
  13336. shadowsSaturation: number;
  13337. /**
  13338. * Gets the shadows Exposure value.
  13339. * 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.
  13340. */
  13341. /**
  13342. * Sets the shadows Exposure value.
  13343. * 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.
  13344. */
  13345. shadowsExposure: number;
  13346. getClassName(): string;
  13347. /**
  13348. * Binds the color curves to the shader.
  13349. * @param colorCurves The color curve to bind
  13350. * @param effect The effect to bind to
  13351. */
  13352. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13353. /**
  13354. * Prepare the list of uniforms associated with the ColorCurves effects.
  13355. * @param uniformsList The list of uniforms used in the effect
  13356. */
  13357. static PrepareUniforms(uniformsList: string[]): void;
  13358. /**
  13359. * Returns color grading data based on a hue, density, saturation and exposure value.
  13360. * @param filterHue The hue of the color filter.
  13361. * @param filterDensity The density of the color filter.
  13362. * @param saturation The saturation.
  13363. * @param exposure The exposure.
  13364. * @param result The result data container.
  13365. */
  13366. private getColorGradingDataToRef;
  13367. /**
  13368. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13369. * @param value The input slider value in range [-100,100].
  13370. * @returns Adjusted value.
  13371. */
  13372. private static applyColorGradingSliderNonlinear;
  13373. /**
  13374. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13375. * @param hue The hue (H) input.
  13376. * @param saturation The saturation (S) input.
  13377. * @param brightness The brightness (B) input.
  13378. * @result An RGBA color represented as Vector4.
  13379. */
  13380. private static fromHSBToRef;
  13381. /**
  13382. * Returns a value clamped between min and max
  13383. * @param value The value to clamp
  13384. * @param min The minimum of value
  13385. * @param max The maximum of value
  13386. * @returns The clamped value.
  13387. */
  13388. private static clamp;
  13389. /**
  13390. * Clones the current color curve instance.
  13391. * @return The cloned curves
  13392. */
  13393. clone(): ColorCurves;
  13394. /**
  13395. * Serializes the current color curve instance to a json representation.
  13396. * @return a JSON representation
  13397. */
  13398. serialize(): any;
  13399. /**
  13400. * Parses the color curve from a json representation.
  13401. * @param source the JSON source to parse
  13402. * @return The parsed curves
  13403. */
  13404. static Parse(source: any): ColorCurves;
  13405. }
  13406. }
  13407. declare module BABYLON {
  13408. /**
  13409. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13410. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13411. */
  13412. class EffectFallbacks {
  13413. private _defines;
  13414. private _currentRank;
  13415. private _maxRank;
  13416. private _mesh;
  13417. /**
  13418. * Removes the fallback from the bound mesh.
  13419. */
  13420. unBindMesh(): void;
  13421. /**
  13422. * Adds a fallback on the specified property.
  13423. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13424. * @param define The name of the define in the shader
  13425. */
  13426. addFallback(rank: number, define: string): void;
  13427. /**
  13428. * Sets the mesh to use CPU skinning when needing to fallback.
  13429. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13430. * @param mesh The mesh to use the fallbacks.
  13431. */
  13432. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13433. /**
  13434. * Checks to see if more fallbacks are still availible.
  13435. */
  13436. readonly isMoreFallbacks: boolean;
  13437. /**
  13438. * Removes the defines that shoould be removed when falling back.
  13439. * @param currentDefines defines the current define statements for the shader.
  13440. * @param effect defines the current effect we try to compile
  13441. * @returns The resulting defines with defines of the current rank removed.
  13442. */
  13443. reduce(currentDefines: string, effect: Effect): string;
  13444. }
  13445. /**
  13446. * Options to be used when creating an effect.
  13447. */
  13448. class EffectCreationOptions {
  13449. /**
  13450. * Atrributes that will be used in the shader.
  13451. */
  13452. attributes: string[];
  13453. /**
  13454. * Uniform varible names that will be set in the shader.
  13455. */
  13456. uniformsNames: string[];
  13457. /**
  13458. * Uniform buffer varible names that will be set in the shader.
  13459. */
  13460. uniformBuffersNames: string[];
  13461. /**
  13462. * Sampler texture variable names that will be set in the shader.
  13463. */
  13464. samplers: string[];
  13465. /**
  13466. * Define statements that will be set in the shader.
  13467. */
  13468. defines: any;
  13469. /**
  13470. * Possible fallbacks for this effect to improve performance when needed.
  13471. */
  13472. fallbacks: Nullable<EffectFallbacks>;
  13473. /**
  13474. * Callback that will be called when the shader is compiled.
  13475. */
  13476. onCompiled: Nullable<(effect: Effect) => void>;
  13477. /**
  13478. * Callback that will be called if an error occurs during shader compilation.
  13479. */
  13480. onError: Nullable<(effect: Effect, errors: string) => void>;
  13481. /**
  13482. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13483. */
  13484. indexParameters: any;
  13485. /**
  13486. * Max number of lights that can be used in the shader.
  13487. */
  13488. maxSimultaneousLights: number;
  13489. /**
  13490. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13491. */
  13492. transformFeedbackVaryings: Nullable<string[]>;
  13493. }
  13494. /**
  13495. * Effect containing vertex and fragment shader that can be executed on an object.
  13496. */
  13497. class Effect {
  13498. /**
  13499. * Name of the effect.
  13500. */
  13501. name: any;
  13502. /**
  13503. * String container all the define statements that should be set on the shader.
  13504. */
  13505. defines: string;
  13506. /**
  13507. * Callback that will be called when the shader is compiled.
  13508. */
  13509. onCompiled: Nullable<(effect: Effect) => void>;
  13510. /**
  13511. * Callback that will be called if an error occurs during shader compilation.
  13512. */
  13513. onError: Nullable<(effect: Effect, errors: string) => void>;
  13514. /**
  13515. * Callback that will be called when effect is bound.
  13516. */
  13517. onBind: Nullable<(effect: Effect) => void>;
  13518. /**
  13519. * Unique ID of the effect.
  13520. */
  13521. uniqueId: number;
  13522. /**
  13523. * Observable that will be called when the shader is compiled.
  13524. */
  13525. onCompileObservable: Observable<Effect>;
  13526. /**
  13527. * Observable that will be called if an error occurs during shader compilation.
  13528. */
  13529. onErrorObservable: Observable<Effect>;
  13530. /** @hidden */
  13531. _onBindObservable: Nullable<Observable<Effect>>;
  13532. /**
  13533. * Observable that will be called when effect is bound.
  13534. */
  13535. readonly onBindObservable: Observable<Effect>;
  13536. /** @hidden */
  13537. _bonesComputationForcedToCPU: boolean;
  13538. private static _uniqueIdSeed;
  13539. private _engine;
  13540. private _uniformBuffersNames;
  13541. private _uniformsNames;
  13542. private _samplers;
  13543. private _isReady;
  13544. private _compilationError;
  13545. private _attributesNames;
  13546. private _attributes;
  13547. private _uniforms;
  13548. /**
  13549. * Key for the effect.
  13550. * @hidden
  13551. */
  13552. _key: string;
  13553. private _indexParameters;
  13554. private _fallbacks;
  13555. private _vertexSourceCode;
  13556. private _fragmentSourceCode;
  13557. private _vertexSourceCodeOverride;
  13558. private _fragmentSourceCodeOverride;
  13559. private _transformFeedbackVaryings;
  13560. /**
  13561. * Compiled shader to webGL program.
  13562. * @hidden
  13563. */
  13564. _program: WebGLProgram;
  13565. private _valueCache;
  13566. private static _baseCache;
  13567. /**
  13568. * Instantiates an effect.
  13569. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13570. * @param baseName Name of the effect.
  13571. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13572. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13573. * @param samplers List of sampler variables that will be passed to the shader.
  13574. * @param engine Engine to be used to render the effect
  13575. * @param defines Define statements to be added to the shader.
  13576. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13577. * @param onCompiled Callback that will be called when the shader is compiled.
  13578. * @param onError Callback that will be called if an error occurs during shader compilation.
  13579. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13580. */
  13581. 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);
  13582. /**
  13583. * Unique key for this effect
  13584. */
  13585. readonly key: string;
  13586. /**
  13587. * If the effect has been compiled and prepared.
  13588. * @returns if the effect is compiled and prepared.
  13589. */
  13590. isReady(): boolean;
  13591. /**
  13592. * The engine the effect was initialized with.
  13593. * @returns the engine.
  13594. */
  13595. getEngine(): Engine;
  13596. /**
  13597. * The compiled webGL program for the effect
  13598. * @returns the webGL program.
  13599. */
  13600. getProgram(): WebGLProgram;
  13601. /**
  13602. * The set of names of attribute variables for the shader.
  13603. * @returns An array of attribute names.
  13604. */
  13605. getAttributesNames(): string[];
  13606. /**
  13607. * Returns the attribute at the given index.
  13608. * @param index The index of the attribute.
  13609. * @returns The location of the attribute.
  13610. */
  13611. getAttributeLocation(index: number): number;
  13612. /**
  13613. * Returns the attribute based on the name of the variable.
  13614. * @param name of the attribute to look up.
  13615. * @returns the attribute location.
  13616. */
  13617. getAttributeLocationByName(name: string): number;
  13618. /**
  13619. * The number of attributes.
  13620. * @returns the numnber of attributes.
  13621. */
  13622. getAttributesCount(): number;
  13623. /**
  13624. * Gets the index of a uniform variable.
  13625. * @param uniformName of the uniform to look up.
  13626. * @returns the index.
  13627. */
  13628. getUniformIndex(uniformName: string): number;
  13629. /**
  13630. * Returns the attribute based on the name of the variable.
  13631. * @param uniformName of the uniform to look up.
  13632. * @returns the location of the uniform.
  13633. */
  13634. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13635. /**
  13636. * Returns an array of sampler variable names
  13637. * @returns The array of sampler variable neames.
  13638. */
  13639. getSamplers(): string[];
  13640. /**
  13641. * The error from the last compilation.
  13642. * @returns the error string.
  13643. */
  13644. getCompilationError(): string;
  13645. /**
  13646. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13647. * @param func The callback to be used.
  13648. */
  13649. executeWhenCompiled(func: (effect: Effect) => void): void;
  13650. /** @hidden */
  13651. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13652. /** @hidden */
  13653. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13654. /** @hidden */
  13655. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13656. private _processShaderConversion;
  13657. private _processIncludes;
  13658. private _processPrecision;
  13659. /**
  13660. * Recompiles the webGL program
  13661. * @param vertexSourceCode The source code for the vertex shader.
  13662. * @param fragmentSourceCode The source code for the fragment shader.
  13663. * @param onCompiled Callback called when completed.
  13664. * @param onError Callback called on error.
  13665. * @hidden
  13666. */
  13667. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13668. /**
  13669. * Gets the uniform locations of the the specified variable names
  13670. * @param names THe names of the variables to lookup.
  13671. * @returns Array of locations in the same order as variable names.
  13672. */
  13673. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13674. /**
  13675. * Prepares the effect
  13676. * @hidden
  13677. */
  13678. _prepareEffect(): void;
  13679. /**
  13680. * Checks if the effect is supported. (Must be called after compilation)
  13681. */
  13682. readonly isSupported: boolean;
  13683. /**
  13684. * Binds a texture to the engine to be used as output of the shader.
  13685. * @param channel Name of the output variable.
  13686. * @param texture Texture to bind.
  13687. * @hidden
  13688. */
  13689. _bindTexture(channel: string, texture: InternalTexture): void;
  13690. /**
  13691. * Sets a texture on the engine to be used in the shader.
  13692. * @param channel Name of the sampler variable.
  13693. * @param texture Texture to set.
  13694. */
  13695. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13696. /**
  13697. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13698. * @param channel Name of the sampler variable.
  13699. * @param texture Texture to set.
  13700. */
  13701. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13702. /**
  13703. * Sets an array of textures on the engine to be used in the shader.
  13704. * @param channel Name of the variable.
  13705. * @param textures Textures to set.
  13706. */
  13707. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13708. /**
  13709. * 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)
  13710. * @param channel Name of the sampler variable.
  13711. * @param postProcess Post process to get the input texture from.
  13712. */
  13713. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13714. /**
  13715. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13716. * 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)
  13717. * @param channel Name of the sampler variable.
  13718. * @param postProcess Post process to get the output texture from.
  13719. */
  13720. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13721. /** @hidden */
  13722. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13723. /** @hidden */
  13724. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13725. /** @hidden */
  13726. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13727. /** @hidden */
  13728. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13729. /**
  13730. * Binds a buffer to a uniform.
  13731. * @param buffer Buffer to bind.
  13732. * @param name Name of the uniform variable to bind to.
  13733. */
  13734. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13735. /**
  13736. * Binds block to a uniform.
  13737. * @param blockName Name of the block to bind.
  13738. * @param index Index to bind.
  13739. */
  13740. bindUniformBlock(blockName: string, index: number): void;
  13741. /**
  13742. * Sets an interger value on a uniform variable.
  13743. * @param uniformName Name of the variable.
  13744. * @param value Value to be set.
  13745. * @returns this effect.
  13746. */
  13747. setInt(uniformName: string, value: number): Effect;
  13748. /**
  13749. * Sets an int array on a uniform variable.
  13750. * @param uniformName Name of the variable.
  13751. * @param array array to be set.
  13752. * @returns this effect.
  13753. */
  13754. setIntArray(uniformName: string, array: Int32Array): Effect;
  13755. /**
  13756. * 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)
  13757. * @param uniformName Name of the variable.
  13758. * @param array array to be set.
  13759. * @returns this effect.
  13760. */
  13761. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13762. /**
  13763. * 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)
  13764. * @param uniformName Name of the variable.
  13765. * @param array array to be set.
  13766. * @returns this effect.
  13767. */
  13768. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13769. /**
  13770. * 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)
  13771. * @param uniformName Name of the variable.
  13772. * @param array array to be set.
  13773. * @returns this effect.
  13774. */
  13775. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13776. /**
  13777. * Sets an float array on a uniform variable.
  13778. * @param uniformName Name of the variable.
  13779. * @param array array to be set.
  13780. * @returns this effect.
  13781. */
  13782. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13783. /**
  13784. * 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)
  13785. * @param uniformName Name of the variable.
  13786. * @param array array to be set.
  13787. * @returns this effect.
  13788. */
  13789. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13790. /**
  13791. * 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)
  13792. * @param uniformName Name of the variable.
  13793. * @param array array to be set.
  13794. * @returns this effect.
  13795. */
  13796. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13797. /**
  13798. * 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)
  13799. * @param uniformName Name of the variable.
  13800. * @param array array to be set.
  13801. * @returns this effect.
  13802. */
  13803. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13804. /**
  13805. * Sets an array on a uniform variable.
  13806. * @param uniformName Name of the variable.
  13807. * @param array array to be set.
  13808. * @returns this effect.
  13809. */
  13810. setArray(uniformName: string, array: number[]): Effect;
  13811. /**
  13812. * 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)
  13813. * @param uniformName Name of the variable.
  13814. * @param array array to be set.
  13815. * @returns this effect.
  13816. */
  13817. setArray2(uniformName: string, array: number[]): Effect;
  13818. /**
  13819. * 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)
  13820. * @param uniformName Name of the variable.
  13821. * @param array array to be set.
  13822. * @returns this effect.
  13823. */
  13824. setArray3(uniformName: string, array: number[]): Effect;
  13825. /**
  13826. * 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)
  13827. * @param uniformName Name of the variable.
  13828. * @param array array to be set.
  13829. * @returns this effect.
  13830. */
  13831. setArray4(uniformName: string, array: number[]): Effect;
  13832. /**
  13833. * Sets matrices on a uniform variable.
  13834. * @param uniformName Name of the variable.
  13835. * @param matrices matrices to be set.
  13836. * @returns this effect.
  13837. */
  13838. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13839. /**
  13840. * Sets matrix on a uniform variable.
  13841. * @param uniformName Name of the variable.
  13842. * @param matrix matrix to be set.
  13843. * @returns this effect.
  13844. */
  13845. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13846. /**
  13847. * 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)
  13848. * @param uniformName Name of the variable.
  13849. * @param matrix matrix to be set.
  13850. * @returns this effect.
  13851. */
  13852. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13853. /**
  13854. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13855. * @param uniformName Name of the variable.
  13856. * @param matrix matrix to be set.
  13857. * @returns this effect.
  13858. */
  13859. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13860. /**
  13861. * Sets a float on a uniform variable.
  13862. * @param uniformName Name of the variable.
  13863. * @param value value to be set.
  13864. * @returns this effect.
  13865. */
  13866. setFloat(uniformName: string, value: number): Effect;
  13867. /**
  13868. * Sets a boolean on a uniform variable.
  13869. * @param uniformName Name of the variable.
  13870. * @param bool value to be set.
  13871. * @returns this effect.
  13872. */
  13873. setBool(uniformName: string, bool: boolean): Effect;
  13874. /**
  13875. * Sets a Vector2 on a uniform variable.
  13876. * @param uniformName Name of the variable.
  13877. * @param vector2 vector2 to be set.
  13878. * @returns this effect.
  13879. */
  13880. setVector2(uniformName: string, vector2: Vector2): Effect;
  13881. /**
  13882. * Sets a float2 on a uniform variable.
  13883. * @param uniformName Name of the variable.
  13884. * @param x First float in float2.
  13885. * @param y Second float in float2.
  13886. * @returns this effect.
  13887. */
  13888. setFloat2(uniformName: string, x: number, y: number): Effect;
  13889. /**
  13890. * Sets a Vector3 on a uniform variable.
  13891. * @param uniformName Name of the variable.
  13892. * @param vector3 Value to be set.
  13893. * @returns this effect.
  13894. */
  13895. setVector3(uniformName: string, vector3: Vector3): Effect;
  13896. /**
  13897. * Sets a float3 on a uniform variable.
  13898. * @param uniformName Name of the variable.
  13899. * @param x First float in float3.
  13900. * @param y Second float in float3.
  13901. * @param z Third float in float3.
  13902. * @returns this effect.
  13903. */
  13904. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13905. /**
  13906. * Sets a Vector4 on a uniform variable.
  13907. * @param uniformName Name of the variable.
  13908. * @param vector4 Value to be set.
  13909. * @returns this effect.
  13910. */
  13911. setVector4(uniformName: string, vector4: Vector4): Effect;
  13912. /**
  13913. * Sets a float4 on a uniform variable.
  13914. * @param uniformName Name of the variable.
  13915. * @param x First float in float4.
  13916. * @param y Second float in float4.
  13917. * @param z Third float in float4.
  13918. * @param w Fourth float in float4.
  13919. * @returns this effect.
  13920. */
  13921. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13922. /**
  13923. * Sets a Color3 on a uniform variable.
  13924. * @param uniformName Name of the variable.
  13925. * @param color3 Value to be set.
  13926. * @returns this effect.
  13927. */
  13928. setColor3(uniformName: string, color3: Color3): Effect;
  13929. /**
  13930. * Sets a Color4 on a uniform variable.
  13931. * @param uniformName Name of the variable.
  13932. * @param color3 Value to be set.
  13933. * @param alpha Alpha value to be set.
  13934. * @returns this effect.
  13935. */
  13936. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13937. /**
  13938. * Sets a Color4 on a uniform variable
  13939. * @param uniformName defines the name of the variable
  13940. * @param color4 defines the value to be set
  13941. * @returns this effect.
  13942. */
  13943. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13944. /**
  13945. * This function will add a new shader to the shader store
  13946. * @param name the name of the shader
  13947. * @param pixelShader optional pixel shader content
  13948. * @param vertexShader optional vertex shader content
  13949. */
  13950. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13951. /**
  13952. * Store of each shader (The can be looked up using effect.key)
  13953. */
  13954. static ShadersStore: {
  13955. [key: string]: string;
  13956. };
  13957. /**
  13958. * Store of each included file for a shader (The can be looked up using effect.key)
  13959. */
  13960. static IncludesShadersStore: {
  13961. [key: string]: string;
  13962. };
  13963. /**
  13964. * Resets the cache of effects.
  13965. */
  13966. static ResetCache(): void;
  13967. }
  13968. }
  13969. declare module BABYLON {
  13970. class FresnelParameters {
  13971. private _isEnabled;
  13972. isEnabled: boolean;
  13973. leftColor: Color3;
  13974. rightColor: Color3;
  13975. bias: number;
  13976. power: number;
  13977. clone(): FresnelParameters;
  13978. serialize(): any;
  13979. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13980. }
  13981. }
  13982. declare module BABYLON {
  13983. /**
  13984. * Interface to follow in your material defines to integrate easily the
  13985. * Image proccessing functions.
  13986. * @hidden
  13987. */
  13988. interface IImageProcessingConfigurationDefines {
  13989. IMAGEPROCESSING: boolean;
  13990. VIGNETTE: boolean;
  13991. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13992. VIGNETTEBLENDMODEOPAQUE: boolean;
  13993. TONEMAPPING: boolean;
  13994. TONEMAPPING_ACES: boolean;
  13995. CONTRAST: boolean;
  13996. EXPOSURE: boolean;
  13997. COLORCURVES: boolean;
  13998. COLORGRADING: boolean;
  13999. COLORGRADING3D: boolean;
  14000. SAMPLER3DGREENDEPTH: boolean;
  14001. SAMPLER3DBGRMAP: boolean;
  14002. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14003. }
  14004. /**
  14005. * @hidden
  14006. */
  14007. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14008. IMAGEPROCESSING: boolean;
  14009. VIGNETTE: boolean;
  14010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14011. VIGNETTEBLENDMODEOPAQUE: boolean;
  14012. TONEMAPPING: boolean;
  14013. TONEMAPPING_ACES: boolean;
  14014. CONTRAST: boolean;
  14015. COLORCURVES: boolean;
  14016. COLORGRADING: boolean;
  14017. COLORGRADING3D: boolean;
  14018. SAMPLER3DGREENDEPTH: boolean;
  14019. SAMPLER3DBGRMAP: boolean;
  14020. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14021. EXPOSURE: boolean;
  14022. constructor();
  14023. }
  14024. /**
  14025. * This groups together the common properties used for image processing either in direct forward pass
  14026. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14027. * or not.
  14028. */
  14029. class ImageProcessingConfiguration {
  14030. /**
  14031. * Default tone mapping applied in BabylonJS.
  14032. */
  14033. static readonly TONEMAPPING_STANDARD: number;
  14034. /**
  14035. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14036. * to other engines rendering to increase portability.
  14037. */
  14038. static readonly TONEMAPPING_ACES: number;
  14039. /**
  14040. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14041. */
  14042. colorCurves: Nullable<ColorCurves>;
  14043. private _colorCurvesEnabled;
  14044. /**
  14045. * Gets wether the color curves effect is enabled.
  14046. */
  14047. /**
  14048. * Sets wether the color curves effect is enabled.
  14049. */
  14050. colorCurvesEnabled: boolean;
  14051. /**
  14052. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14053. */
  14054. colorGradingTexture: Nullable<BaseTexture>;
  14055. private _colorGradingEnabled;
  14056. /**
  14057. * Gets wether the color grading effect is enabled.
  14058. */
  14059. /**
  14060. * Sets wether the color grading effect is enabled.
  14061. */
  14062. colorGradingEnabled: boolean;
  14063. private _colorGradingWithGreenDepth;
  14064. /**
  14065. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14066. */
  14067. /**
  14068. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14069. */
  14070. colorGradingWithGreenDepth: boolean;
  14071. private _colorGradingBGR;
  14072. /**
  14073. * Gets wether the color grading texture contains BGR values.
  14074. */
  14075. /**
  14076. * Sets wether the color grading texture contains BGR values.
  14077. */
  14078. colorGradingBGR: boolean;
  14079. /** @hidden */
  14080. _exposure: number;
  14081. /**
  14082. * Gets the Exposure used in the effect.
  14083. */
  14084. /**
  14085. * Sets the Exposure used in the effect.
  14086. */
  14087. exposure: number;
  14088. private _toneMappingEnabled;
  14089. /**
  14090. * Gets wether the tone mapping effect is enabled.
  14091. */
  14092. /**
  14093. * Sets wether the tone mapping effect is enabled.
  14094. */
  14095. toneMappingEnabled: boolean;
  14096. private _toneMappingType;
  14097. /**
  14098. * Gets the type of tone mapping effect.
  14099. */
  14100. /**
  14101. * Sets the type of tone mapping effect used in BabylonJS.
  14102. */
  14103. toneMappingType: number;
  14104. protected _contrast: number;
  14105. /**
  14106. * Gets the contrast used in the effect.
  14107. */
  14108. /**
  14109. * Sets the contrast used in the effect.
  14110. */
  14111. contrast: number;
  14112. /**
  14113. * Vignette stretch size.
  14114. */
  14115. vignetteStretch: number;
  14116. /**
  14117. * Vignette centre X Offset.
  14118. */
  14119. vignetteCentreX: number;
  14120. /**
  14121. * Vignette centre Y Offset.
  14122. */
  14123. vignetteCentreY: number;
  14124. /**
  14125. * Vignette weight or intensity of the vignette effect.
  14126. */
  14127. vignetteWeight: number;
  14128. /**
  14129. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14130. * if vignetteEnabled is set to true.
  14131. */
  14132. vignetteColor: Color4;
  14133. /**
  14134. * Camera field of view used by the Vignette effect.
  14135. */
  14136. vignetteCameraFov: number;
  14137. private _vignetteBlendMode;
  14138. /**
  14139. * Gets the vignette blend mode allowing different kind of effect.
  14140. */
  14141. /**
  14142. * Sets the vignette blend mode allowing different kind of effect.
  14143. */
  14144. vignetteBlendMode: number;
  14145. private _vignetteEnabled;
  14146. /**
  14147. * Gets wether the vignette effect is enabled.
  14148. */
  14149. /**
  14150. * Sets wether the vignette effect is enabled.
  14151. */
  14152. vignetteEnabled: boolean;
  14153. private _applyByPostProcess;
  14154. /**
  14155. * Gets wether the image processing is applied through a post process or not.
  14156. */
  14157. /**
  14158. * Sets wether the image processing is applied through a post process or not.
  14159. */
  14160. applyByPostProcess: boolean;
  14161. private _isEnabled;
  14162. /**
  14163. * Gets wether the image processing is enabled or not.
  14164. */
  14165. /**
  14166. * Sets wether the image processing is enabled or not.
  14167. */
  14168. isEnabled: boolean;
  14169. /**
  14170. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14171. */
  14172. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14173. /**
  14174. * Method called each time the image processing information changes requires to recompile the effect.
  14175. */
  14176. protected _updateParameters(): void;
  14177. getClassName(): string;
  14178. /**
  14179. * Prepare the list of uniforms associated with the Image Processing effects.
  14180. * @param uniformsList The list of uniforms used in the effect
  14181. * @param defines the list of defines currently in use
  14182. */
  14183. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14184. /**
  14185. * Prepare the list of samplers associated with the Image Processing effects.
  14186. * @param uniformsList The list of uniforms used in the effect
  14187. * @param defines the list of defines currently in use
  14188. */
  14189. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14190. /**
  14191. * Prepare the list of defines associated to the shader.
  14192. * @param defines the list of defines to complete
  14193. */
  14194. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14195. /**
  14196. * Returns true if all the image processing information are ready.
  14197. */
  14198. isReady(): boolean;
  14199. /**
  14200. * Binds the image processing to the shader.
  14201. * @param effect The effect to bind to
  14202. */
  14203. bind(effect: Effect, aspectRatio?: number): void;
  14204. /**
  14205. * Clones the current image processing instance.
  14206. * @return The cloned image processing
  14207. */
  14208. clone(): ImageProcessingConfiguration;
  14209. /**
  14210. * Serializes the current image processing instance to a json representation.
  14211. * @return a JSON representation
  14212. */
  14213. serialize(): any;
  14214. /**
  14215. * Parses the image processing from a json representation.
  14216. * @param source the JSON source to parse
  14217. * @return The parsed image processing
  14218. */
  14219. static Parse(source: any): ImageProcessingConfiguration;
  14220. private static _VIGNETTEMODE_MULTIPLY;
  14221. private static _VIGNETTEMODE_OPAQUE;
  14222. /**
  14223. * Used to apply the vignette as a mix with the pixel color.
  14224. */
  14225. static readonly VIGNETTEMODE_MULTIPLY: number;
  14226. /**
  14227. * Used to apply the vignette as a replacement of the pixel color.
  14228. */
  14229. static readonly VIGNETTEMODE_OPAQUE: number;
  14230. }
  14231. }
  14232. declare module BABYLON {
  14233. /**
  14234. * Manages the defines for the Material
  14235. */
  14236. class MaterialDefines {
  14237. private _keys;
  14238. private _isDirty;
  14239. /** @hidden */
  14240. _renderId: number;
  14241. /** @hidden */
  14242. _areLightsDirty: boolean;
  14243. /** @hidden */
  14244. _areAttributesDirty: boolean;
  14245. /** @hidden */
  14246. _areTexturesDirty: boolean;
  14247. /** @hidden */
  14248. _areFresnelDirty: boolean;
  14249. /** @hidden */
  14250. _areMiscDirty: boolean;
  14251. /** @hidden */
  14252. _areImageProcessingDirty: boolean;
  14253. /** @hidden */
  14254. _normals: boolean;
  14255. /** @hidden */
  14256. _uvs: boolean;
  14257. /** @hidden */
  14258. _needNormals: boolean;
  14259. /** @hidden */
  14260. _needUVs: boolean;
  14261. /**
  14262. * Specifies if the material needs to be re-calculated
  14263. */
  14264. readonly isDirty: boolean;
  14265. /**
  14266. * Marks the material to indicate that it has been re-calculated
  14267. */
  14268. markAsProcessed(): void;
  14269. /**
  14270. * Marks the material to indicate that it needs to be re-calculated
  14271. */
  14272. markAsUnprocessed(): void;
  14273. /**
  14274. * Marks the material to indicate all of its defines need to be re-calculated
  14275. */
  14276. markAllAsDirty(): void;
  14277. /**
  14278. * Marks the material to indicate that image processing needs to be re-calculated
  14279. */
  14280. markAsImageProcessingDirty(): void;
  14281. /**
  14282. * Marks the material to indicate the lights need to be re-calculated
  14283. */
  14284. markAsLightDirty(): void;
  14285. /**
  14286. * Marks the attribute state as changed
  14287. */
  14288. markAsAttributesDirty(): void;
  14289. /**
  14290. * Marks the texture state as changed
  14291. */
  14292. markAsTexturesDirty(): void;
  14293. /**
  14294. * Marks the fresnel state as changed
  14295. */
  14296. markAsFresnelDirty(): void;
  14297. /**
  14298. * Marks the misc state as changed
  14299. */
  14300. markAsMiscDirty(): void;
  14301. /**
  14302. * Rebuilds the material defines
  14303. */
  14304. rebuild(): void;
  14305. /**
  14306. * Specifies if two material defines are equal
  14307. * @param other - A material define instance to compare to
  14308. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14309. */
  14310. isEqual(other: MaterialDefines): boolean;
  14311. /**
  14312. * Clones this instance's defines to another instance
  14313. * @param other - material defines to clone values to
  14314. */
  14315. cloneTo(other: MaterialDefines): void;
  14316. /**
  14317. * Resets the material define values
  14318. */
  14319. reset(): void;
  14320. /**
  14321. * Converts the material define values to a string
  14322. * @returns - String of material define information
  14323. */
  14324. toString(): string;
  14325. }
  14326. /**
  14327. * Base class for the main features of a material in Babylon.js
  14328. */
  14329. class Material implements IAnimatable {
  14330. private static _TriangleFillMode;
  14331. private static _WireFrameFillMode;
  14332. private static _PointFillMode;
  14333. private static _PointListDrawMode;
  14334. private static _LineListDrawMode;
  14335. private static _LineLoopDrawMode;
  14336. private static _LineStripDrawMode;
  14337. private static _TriangleStripDrawMode;
  14338. private static _TriangleFanDrawMode;
  14339. /**
  14340. * Returns the triangle fill mode
  14341. */
  14342. static readonly TriangleFillMode: number;
  14343. /**
  14344. * Returns the wireframe mode
  14345. */
  14346. static readonly WireFrameFillMode: number;
  14347. /**
  14348. * Returns the point fill mode
  14349. */
  14350. static readonly PointFillMode: number;
  14351. /**
  14352. * Returns the point list draw mode
  14353. */
  14354. static readonly PointListDrawMode: number;
  14355. /**
  14356. * Returns the line list draw mode
  14357. */
  14358. static readonly LineListDrawMode: number;
  14359. /**
  14360. * Returns the line loop draw mode
  14361. */
  14362. static readonly LineLoopDrawMode: number;
  14363. /**
  14364. * Returns the line strip draw mode
  14365. */
  14366. static readonly LineStripDrawMode: number;
  14367. /**
  14368. * Returns the triangle strip draw mode
  14369. */
  14370. static readonly TriangleStripDrawMode: number;
  14371. /**
  14372. * Returns the triangle fan draw mode
  14373. */
  14374. static readonly TriangleFanDrawMode: number;
  14375. /**
  14376. * Stores the clock-wise side orientation
  14377. */
  14378. private static _ClockWiseSideOrientation;
  14379. /**
  14380. * Stores the counter clock-wise side orientation
  14381. */
  14382. private static _CounterClockWiseSideOrientation;
  14383. /**
  14384. * Returns the clock-wise side orientation
  14385. */
  14386. static readonly ClockWiseSideOrientation: number;
  14387. /**
  14388. * Returns the counter clock-wise side orientation
  14389. */
  14390. static readonly CounterClockWiseSideOrientation: number;
  14391. /**
  14392. * The dirty texture flag value
  14393. */
  14394. private static _TextureDirtyFlag;
  14395. /**
  14396. * The dirty light flag value
  14397. */
  14398. private static _LightDirtyFlag;
  14399. /**
  14400. * The dirty fresnel flag value
  14401. */
  14402. private static _FresnelDirtyFlag;
  14403. /**
  14404. * The dirty attribute flag value
  14405. */
  14406. private static _AttributesDirtyFlag;
  14407. /**
  14408. * The dirty misc flag value
  14409. */
  14410. private static _MiscDirtyFlag;
  14411. /**
  14412. * Returns the dirty texture flag value
  14413. */
  14414. static readonly TextureDirtyFlag: number;
  14415. /**
  14416. * Returns the dirty light flag value
  14417. */
  14418. static readonly LightDirtyFlag: number;
  14419. /**
  14420. * Returns the dirty fresnel flag value
  14421. */
  14422. static readonly FresnelDirtyFlag: number;
  14423. /**
  14424. * Returns the dirty attributes flag value
  14425. */
  14426. static readonly AttributesDirtyFlag: number;
  14427. /**
  14428. * Returns the dirty misc flag value
  14429. */
  14430. static readonly MiscDirtyFlag: number;
  14431. /**
  14432. * The ID of the material
  14433. */
  14434. id: string;
  14435. /**
  14436. * Gets or sets the unique id of the material
  14437. */
  14438. uniqueId: number;
  14439. /**
  14440. * The name of the material
  14441. */
  14442. name: string;
  14443. /**
  14444. * Specifies if the ready state should be checked on each call
  14445. */
  14446. checkReadyOnEveryCall: boolean;
  14447. /**
  14448. * Specifies if the ready state should be checked once
  14449. */
  14450. checkReadyOnlyOnce: boolean;
  14451. /**
  14452. * The state of the material
  14453. */
  14454. state: string;
  14455. /**
  14456. * The alpha value of the material
  14457. */
  14458. protected _alpha: number;
  14459. /**
  14460. * Sets the alpha value of the material
  14461. */
  14462. /**
  14463. * Gets the alpha value of the material
  14464. */
  14465. alpha: number;
  14466. /**
  14467. * Specifies if back face culling is enabled
  14468. */
  14469. protected _backFaceCulling: boolean;
  14470. /**
  14471. * Sets the back-face culling state
  14472. */
  14473. /**
  14474. * Gets the back-face culling state
  14475. */
  14476. backFaceCulling: boolean;
  14477. /**
  14478. * Stores the value for side orientation
  14479. */
  14480. sideOrientation: number;
  14481. /**
  14482. * Callback triggered when the material is compiled
  14483. */
  14484. onCompiled: (effect: Effect) => void;
  14485. /**
  14486. * Callback triggered when an error occurs
  14487. */
  14488. onError: (effect: Effect, errors: string) => void;
  14489. /**
  14490. * Callback triggered to get the render target textures
  14491. */
  14492. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14493. /**
  14494. * Specifies if the material should be serialized
  14495. */
  14496. doNotSerialize: boolean;
  14497. /**
  14498. * Specifies if the effect should be stored on sub meshes
  14499. */
  14500. storeEffectOnSubMeshes: boolean;
  14501. /**
  14502. * Stores the animations for the material
  14503. */
  14504. animations: Array<Animation>;
  14505. /**
  14506. * An event triggered when the material is disposed
  14507. */
  14508. onDisposeObservable: Observable<Material>;
  14509. /**
  14510. * An observer which watches for dispose events
  14511. */
  14512. private _onDisposeObserver;
  14513. private _onUnBindObservable;
  14514. /**
  14515. * Called during a dispose event
  14516. */
  14517. onDispose: () => void;
  14518. private _onBindObservable;
  14519. /**
  14520. * An event triggered when the material is bound
  14521. */
  14522. readonly onBindObservable: Observable<AbstractMesh>;
  14523. /**
  14524. * An observer which watches for bind events
  14525. */
  14526. private _onBindObserver;
  14527. /**
  14528. * Called during a bind event
  14529. */
  14530. onBind: (Mesh: AbstractMesh) => void;
  14531. /**
  14532. * An event triggered when the material is unbound
  14533. */
  14534. readonly onUnBindObservable: Observable<Material>;
  14535. /**
  14536. * Stores the value of the alpha mode
  14537. */
  14538. private _alphaMode;
  14539. /**
  14540. * Sets the value of the alpha mode.
  14541. *
  14542. * | Value | Type | Description |
  14543. * | --- | --- | --- |
  14544. * | 0 | ALPHA_DISABLE | |
  14545. * | 1 | ALPHA_ADD | |
  14546. * | 2 | ALPHA_COMBINE | |
  14547. * | 3 | ALPHA_SUBTRACT | |
  14548. * | 4 | ALPHA_MULTIPLY | |
  14549. * | 5 | ALPHA_MAXIMIZED | |
  14550. * | 6 | ALPHA_ONEONE | |
  14551. * | 7 | ALPHA_PREMULTIPLIED | |
  14552. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14553. * | 9 | ALPHA_INTERPOLATE | |
  14554. * | 10 | ALPHA_SCREENMODE | |
  14555. *
  14556. */
  14557. /**
  14558. * Gets the value of the alpha mode
  14559. */
  14560. alphaMode: number;
  14561. /**
  14562. * Stores the state of the need depth pre-pass value
  14563. */
  14564. private _needDepthPrePass;
  14565. /**
  14566. * Sets the need depth pre-pass value
  14567. */
  14568. /**
  14569. * Gets the depth pre-pass value
  14570. */
  14571. needDepthPrePass: boolean;
  14572. /**
  14573. * Specifies if depth writing should be disabled
  14574. */
  14575. disableDepthWrite: boolean;
  14576. /**
  14577. * Specifies if depth writing should be forced
  14578. */
  14579. forceDepthWrite: boolean;
  14580. /**
  14581. * Specifies if there should be a separate pass for culling
  14582. */
  14583. separateCullingPass: boolean;
  14584. /**
  14585. * Stores the state specifing if fog should be enabled
  14586. */
  14587. private _fogEnabled;
  14588. /**
  14589. * Sets the state for enabling fog
  14590. */
  14591. /**
  14592. * Gets the value of the fog enabled state
  14593. */
  14594. fogEnabled: boolean;
  14595. /**
  14596. * Stores the size of points
  14597. */
  14598. pointSize: number;
  14599. /**
  14600. * Stores the z offset value
  14601. */
  14602. zOffset: number;
  14603. /**
  14604. * Gets a value specifying if wireframe mode is enabled
  14605. */
  14606. /**
  14607. * Sets the state of wireframe mode
  14608. */
  14609. wireframe: boolean;
  14610. /**
  14611. * Gets the value specifying if point clouds are enabled
  14612. */
  14613. /**
  14614. * Sets the state of point cloud mode
  14615. */
  14616. pointsCloud: boolean;
  14617. /**
  14618. * Gets the material fill mode
  14619. */
  14620. /**
  14621. * Sets the material fill mode
  14622. */
  14623. fillMode: number;
  14624. /**
  14625. * @hidden
  14626. * Stores the effects for the material
  14627. */
  14628. _effect: Nullable<Effect>;
  14629. /**
  14630. * @hidden
  14631. * Specifies if the material was previously ready
  14632. */
  14633. _wasPreviouslyReady: boolean;
  14634. /**
  14635. * Specifies if uniform buffers should be used
  14636. */
  14637. private _useUBO;
  14638. /**
  14639. * Stores a reference to the scene
  14640. */
  14641. private _scene;
  14642. /**
  14643. * Stores the fill mode state
  14644. */
  14645. private _fillMode;
  14646. /**
  14647. * Specifies if the depth write state should be cached
  14648. */
  14649. private _cachedDepthWriteState;
  14650. /**
  14651. * Stores the uniform buffer
  14652. */
  14653. protected _uniformBuffer: UniformBuffer;
  14654. /**
  14655. * Creates a material instance
  14656. * @param name defines the name of the material
  14657. * @param scene defines the scene to reference
  14658. * @param doNotAdd specifies if the material should be added to the scene
  14659. */
  14660. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14661. /**
  14662. * Returns a string representation of the current material
  14663. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14664. * @returns a string with material information
  14665. */
  14666. toString(fullDetails?: boolean): string;
  14667. /**
  14668. * Gets the class name of the material
  14669. * @returns a string with the class name of the material
  14670. */
  14671. getClassName(): string;
  14672. /**
  14673. * Specifies if updates for the material been locked
  14674. */
  14675. readonly isFrozen: boolean;
  14676. /**
  14677. * Locks updates for the material
  14678. */
  14679. freeze(): void;
  14680. /**
  14681. * Unlocks updates for the material
  14682. */
  14683. unfreeze(): void;
  14684. /**
  14685. * Specifies if the material is ready to be used
  14686. * @param mesh defines the mesh to check
  14687. * @param useInstances specifies if instances should be used
  14688. * @returns a boolean indicating if the material is ready to be used
  14689. */
  14690. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14691. /**
  14692. * Specifies that the submesh is ready to be used
  14693. * @param mesh defines the mesh to check
  14694. * @param subMesh defines which submesh to check
  14695. * @param useInstances specifies that instances should be used
  14696. * @returns a boolean indicating that the submesh is ready or not
  14697. */
  14698. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14699. /**
  14700. * Returns the material effect
  14701. * @returns the effect associated with the material
  14702. */
  14703. getEffect(): Nullable<Effect>;
  14704. /**
  14705. * Returns the current scene
  14706. * @returns a Scene
  14707. */
  14708. getScene(): Scene;
  14709. /**
  14710. * Specifies if the material will require alpha blending
  14711. * @returns a boolean specifying if alpha blending is needed
  14712. */
  14713. needAlphaBlending(): boolean;
  14714. /**
  14715. * Specifies if the mesh will require alpha blending
  14716. * @param mesh defines the mesh to check
  14717. * @returns a boolean specifying if alpha blending is needed for the mesh
  14718. */
  14719. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14720. /**
  14721. * Specifies if this material should be rendered in alpha test mode
  14722. * @returns a boolean specifying if an alpha test is needed.
  14723. */
  14724. needAlphaTesting(): boolean;
  14725. /**
  14726. * Gets the texture used for the alpha test
  14727. * @returns the texture to use for alpha testing
  14728. */
  14729. getAlphaTestTexture(): Nullable<BaseTexture>;
  14730. /**
  14731. * Marks the material to indicate that it needs to be re-calculated
  14732. */
  14733. markDirty(): void;
  14734. /** @hidden */
  14735. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14736. /**
  14737. * Binds the material to the mesh
  14738. * @param world defines the world transformation matrix
  14739. * @param mesh defines the mesh to bind the material to
  14740. */
  14741. bind(world: Matrix, mesh?: Mesh): void;
  14742. /**
  14743. * Binds the submesh to the material
  14744. * @param world defines the world transformation matrix
  14745. * @param mesh defines the mesh containing the submesh
  14746. * @param subMesh defines the submesh to bind the material to
  14747. */
  14748. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14749. /**
  14750. * Binds the world matrix to the material
  14751. * @param world defines the world transformation matrix
  14752. */
  14753. bindOnlyWorldMatrix(world: Matrix): void;
  14754. /**
  14755. * Binds the scene's uniform buffer to the effect.
  14756. * @param effect defines the effect to bind to the scene uniform buffer
  14757. * @param sceneUbo defines the uniform buffer storing scene data
  14758. */
  14759. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14760. /**
  14761. * Binds the view matrix to the effect
  14762. * @param effect defines the effect to bind the view matrix to
  14763. */
  14764. bindView(effect: Effect): void;
  14765. /**
  14766. * Binds the view projection matrix to the effect
  14767. * @param effect defines the effect to bind the view projection matrix to
  14768. */
  14769. bindViewProjection(effect: Effect): void;
  14770. /**
  14771. * Specifies if material alpha testing should be turned on for the mesh
  14772. * @param mesh defines the mesh to check
  14773. */
  14774. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14775. /**
  14776. * Processes to execute after binding the material to a mesh
  14777. * @param mesh defines the rendered mesh
  14778. */
  14779. protected _afterBind(mesh?: Mesh): void;
  14780. /**
  14781. * Unbinds the material from the mesh
  14782. */
  14783. unbind(): void;
  14784. /**
  14785. * Gets the active textures from the material
  14786. * @returns an array of textures
  14787. */
  14788. getActiveTextures(): BaseTexture[];
  14789. /**
  14790. * Specifies if the material uses a texture
  14791. * @param texture defines the texture to check against the material
  14792. * @returns a boolean specifying if the material uses the texture
  14793. */
  14794. hasTexture(texture: BaseTexture): boolean;
  14795. /**
  14796. * Makes a duplicate of the material, and gives it a new name
  14797. * @param name defines the new name for the duplicated material
  14798. * @returns the cloned material
  14799. */
  14800. clone(name: string): Nullable<Material>;
  14801. /**
  14802. * Gets the meshes bound to the material
  14803. * @returns an array of meshes bound to the material
  14804. */
  14805. getBindedMeshes(): AbstractMesh[];
  14806. /**
  14807. * Force shader compilation
  14808. * @param mesh defines the mesh associated with this material
  14809. * @param onCompiled defines a function to execute once the material is compiled
  14810. * @param options defines the options to configure the compilation
  14811. */
  14812. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14813. clipPlane: boolean;
  14814. }>): void;
  14815. /**
  14816. * Force shader compilation
  14817. * @param mesh defines the mesh that will use this material
  14818. * @param options defines additional options for compiling the shaders
  14819. * @returns a promise that resolves when the compilation completes
  14820. */
  14821. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14822. clipPlane: boolean;
  14823. }>): Promise<void>;
  14824. /**
  14825. * Marks a define in the material to indicate that it needs to be re-computed
  14826. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14827. */
  14828. markAsDirty(flag: number): void;
  14829. /**
  14830. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14831. * @param func defines a function which checks material defines against the submeshes
  14832. */
  14833. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14834. /**
  14835. * Indicates that image processing needs to be re-calculated for all submeshes
  14836. */
  14837. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14838. /**
  14839. * Indicates that textures need to be re-calculated for all submeshes
  14840. */
  14841. protected _markAllSubMeshesAsTexturesDirty(): void;
  14842. /**
  14843. * Indicates that fresnel needs to be re-calculated for all submeshes
  14844. */
  14845. protected _markAllSubMeshesAsFresnelDirty(): void;
  14846. /**
  14847. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14848. */
  14849. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14850. /**
  14851. * Indicates that lights need to be re-calculated for all submeshes
  14852. */
  14853. protected _markAllSubMeshesAsLightsDirty(): void;
  14854. /**
  14855. * Indicates that attributes need to be re-calculated for all submeshes
  14856. */
  14857. protected _markAllSubMeshesAsAttributesDirty(): void;
  14858. /**
  14859. * Indicates that misc needs to be re-calculated for all submeshes
  14860. */
  14861. protected _markAllSubMeshesAsMiscDirty(): void;
  14862. /**
  14863. * Indicates that textures and misc need to be re-calculated for all submeshes
  14864. */
  14865. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14866. /**
  14867. * Disposes the material
  14868. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14869. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14870. */
  14871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14872. /**
  14873. * Serializes this material
  14874. * @returns the serialized material object
  14875. */
  14876. serialize(): any;
  14877. /**
  14878. * Creates a MultiMaterial from parsed MultiMaterial data.
  14879. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14880. * @param scene defines the hosting scene
  14881. * @returns a new MultiMaterial
  14882. */
  14883. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14884. /**
  14885. * Creates a material from parsed material data
  14886. * @param parsedMaterial defines parsed material data
  14887. * @param scene defines the hosting scene
  14888. * @param rootUrl defines the root URL to use to load textures
  14889. * @returns a new material
  14890. */
  14891. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14892. }
  14893. }
  14894. declare module BABYLON {
  14895. /**
  14896. * "Static Class" containing the most commonly used helper while dealing with material for
  14897. * rendering purpose.
  14898. *
  14899. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14900. *
  14901. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14902. */
  14903. class MaterialHelper {
  14904. /**
  14905. * Bind the current view position to an effect.
  14906. * @param effect The effect to be bound
  14907. * @param scene The scene the eyes position is used from
  14908. */
  14909. static BindEyePosition(effect: Effect, scene: Scene): void;
  14910. /**
  14911. * Helps preparing the defines values about the UVs in used in the effect.
  14912. * UVs are shared as much as we can accross chanels in the shaders.
  14913. * @param texture The texture we are preparing the UVs for
  14914. * @param defines The defines to update
  14915. * @param key The chanel key "diffuse", "specular"... used in the shader
  14916. */
  14917. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14918. /**
  14919. * Binds a texture matrix value to its corrsponding uniform
  14920. * @param texture The texture to bind the matrix for
  14921. * @param uniformBuffer The uniform buffer receivin the data
  14922. * @param key The chanel key "diffuse", "specular"... used in the shader
  14923. */
  14924. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14925. /**
  14926. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14927. * @param mesh defines the current mesh
  14928. * @param scene defines the current scene
  14929. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14930. * @param pointsCloud defines if point cloud rendering has to be turned on
  14931. * @param fogEnabled defines if fog has to be turned on
  14932. * @param alphaTest defines if alpha testing has to be turned on
  14933. * @param defines defines the current list of defines
  14934. */
  14935. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14936. /**
  14937. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14938. * @param scene defines the current scene
  14939. * @param engine defines the current engine
  14940. * @param defines specifies the list of active defines
  14941. * @param useInstances defines if instances have to be turned on
  14942. * @param useClipPlane defines if clip plane have to be turned on
  14943. */
  14944. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14945. /**
  14946. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14947. * @param mesh The mesh containing the geometry data we will draw
  14948. * @param defines The defines to update
  14949. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14950. * @param useBones Precise whether bones should be used or not (override mesh info)
  14951. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14952. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14953. * @returns false if defines are considered not dirty and have not been checked
  14954. */
  14955. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14956. /**
  14957. * Prepares the defines related to the light information passed in parameter
  14958. * @param scene The scene we are intending to draw
  14959. * @param mesh The mesh the effect is compiling for
  14960. * @param defines The defines to update
  14961. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14962. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14963. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14964. * @returns true if normals will be required for the rest of the effect
  14965. */
  14966. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14967. /**
  14968. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14969. * that won t be acctive due to defines being turned off.
  14970. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14971. * @param samplersList The samplers list
  14972. * @param defines The defines helping in the list generation
  14973. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14974. */
  14975. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14976. /**
  14977. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14978. * @param defines The defines to update while falling back
  14979. * @param fallbacks The authorized effect fallbacks
  14980. * @param maxSimultaneousLights The maximum number of lights allowed
  14981. * @param rank the current rank of the Effect
  14982. * @returns The newly affected rank
  14983. */
  14984. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14985. /**
  14986. * Prepares the list of attributes required for morph targets according to the effect defines.
  14987. * @param attribs The current list of supported attribs
  14988. * @param mesh The mesh to prepare the morph targets attributes for
  14989. * @param defines The current Defines of the effect
  14990. */
  14991. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14992. /**
  14993. * Prepares the list of attributes required for bones according to the effect defines.
  14994. * @param attribs The current list of supported attribs
  14995. * @param mesh The mesh to prepare the bones attributes for
  14996. * @param defines The current Defines of the effect
  14997. * @param fallbacks The current efffect fallback strategy
  14998. */
  14999. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  15000. /**
  15001. * Prepares the list of attributes required for instances according to the effect defines.
  15002. * @param attribs The current list of supported attribs
  15003. * @param defines The current Defines of the effect
  15004. */
  15005. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  15006. /**
  15007. * Binds the light shadow information to the effect for the given mesh.
  15008. * @param light The light containing the generator
  15009. * @param scene The scene the lights belongs to
  15010. * @param mesh The mesh we are binding the information to render
  15011. * @param lightIndex The light index in the effect used to render the mesh
  15012. * @param effect The effect we are binding the data to
  15013. */
  15014. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  15015. /**
  15016. * Binds the light information to the effect.
  15017. * @param light The light containing the generator
  15018. * @param effect The effect we are binding the data to
  15019. * @param lightIndex The light index in the effect used to render
  15020. */
  15021. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  15022. /**
  15023. * Binds the lights information from the scene to the effect for the given mesh.
  15024. * @param scene The scene the lights belongs to
  15025. * @param mesh The mesh we are binding the information to render
  15026. * @param effect The effect we are binding the data to
  15027. * @param defines The generated defines for the effect
  15028. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  15029. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  15030. */
  15031. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  15032. /**
  15033. * Binds the fog information from the scene to the effect for the given mesh.
  15034. * @param scene The scene the lights belongs to
  15035. * @param mesh The mesh we are binding the information to render
  15036. * @param effect The effect we are binding the data to
  15037. */
  15038. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  15039. /**
  15040. * Binds the bones information from the mesh to the effect.
  15041. * @param mesh The mesh we are binding the information to render
  15042. * @param effect The effect we are binding the data to
  15043. */
  15044. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  15045. /**
  15046. * Binds the morph targets information from the mesh to the effect.
  15047. * @param abstractMesh The mesh we are binding the information to render
  15048. * @param effect The effect we are binding the data to
  15049. */
  15050. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  15051. /**
  15052. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15053. * @param defines The generated defines used in the effect
  15054. * @param effect The effect we are binding the data to
  15055. * @param scene The scene we are willing to render with logarithmic scale for
  15056. */
  15057. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  15058. /**
  15059. * Binds the clip plane information from the scene to the effect.
  15060. * @param scene The scene the clip plane information are extracted from
  15061. * @param effect The effect we are binding the data to
  15062. */
  15063. static BindClipPlane(effect: Effect, scene: Scene): void;
  15064. }
  15065. }
  15066. declare module BABYLON {
  15067. class MultiMaterial extends Material {
  15068. private _subMaterials;
  15069. subMaterials: Nullable<Material>[];
  15070. constructor(name: string, scene: Scene);
  15071. private _hookArray;
  15072. getSubMaterial(index: number): Nullable<Material>;
  15073. getActiveTextures(): BaseTexture[];
  15074. getClassName(): string;
  15075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15076. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  15077. serialize(): any;
  15078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15079. }
  15080. }
  15081. declare module BABYLON {
  15082. class PushMaterial extends Material {
  15083. protected _activeEffect: Effect;
  15084. protected _normalMatrix: Matrix;
  15085. constructor(name: string, scene: Scene);
  15086. getEffect(): Effect;
  15087. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15088. /**
  15089. * Binds the given world matrix to the active effect
  15090. *
  15091. * @param world the matrix to bind
  15092. */
  15093. bindOnlyWorldMatrix(world: Matrix): void;
  15094. /**
  15095. * Binds the given normal matrix to the active effect
  15096. *
  15097. * @param normalMatrix the matrix to bind
  15098. */
  15099. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  15100. bind(world: Matrix, mesh?: Mesh): void;
  15101. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  15102. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  15103. }
  15104. }
  15105. declare module BABYLON {
  15106. class ShaderMaterial extends Material {
  15107. private _shaderPath;
  15108. private _options;
  15109. private _textures;
  15110. private _textureArrays;
  15111. private _floats;
  15112. private _ints;
  15113. private _floatsArrays;
  15114. private _colors3;
  15115. private _colors3Arrays;
  15116. private _colors4;
  15117. private _vectors2;
  15118. private _vectors3;
  15119. private _vectors4;
  15120. private _matrices;
  15121. private _matrices3x3;
  15122. private _matrices2x2;
  15123. private _vectors2Arrays;
  15124. private _vectors3Arrays;
  15125. private _cachedWorldViewMatrix;
  15126. private _renderId;
  15127. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15128. getClassName(): string;
  15129. needAlphaBlending(): boolean;
  15130. needAlphaTesting(): boolean;
  15131. private _checkUniform;
  15132. setTexture(name: string, texture: Texture): ShaderMaterial;
  15133. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15134. setFloat(name: string, value: number): ShaderMaterial;
  15135. setInt(name: string, value: number): ShaderMaterial;
  15136. setFloats(name: string, value: number[]): ShaderMaterial;
  15137. setColor3(name: string, value: Color3): ShaderMaterial;
  15138. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15139. setColor4(name: string, value: Color4): ShaderMaterial;
  15140. setVector2(name: string, value: Vector2): ShaderMaterial;
  15141. setVector3(name: string, value: Vector3): ShaderMaterial;
  15142. setVector4(name: string, value: Vector4): ShaderMaterial;
  15143. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15144. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15145. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15146. setArray2(name: string, value: number[]): ShaderMaterial;
  15147. setArray3(name: string, value: number[]): ShaderMaterial;
  15148. private _checkCache;
  15149. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15150. bindOnlyWorldMatrix(world: Matrix): void;
  15151. bind(world: Matrix, mesh?: Mesh): void;
  15152. getActiveTextures(): BaseTexture[];
  15153. hasTexture(texture: BaseTexture): boolean;
  15154. clone(name: string): ShaderMaterial;
  15155. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15156. serialize(): any;
  15157. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15158. }
  15159. }
  15160. declare module BABYLON {
  15161. /** @hidden */
  15162. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15163. MAINUV1: boolean;
  15164. MAINUV2: boolean;
  15165. DIFFUSE: boolean;
  15166. DIFFUSEDIRECTUV: number;
  15167. AMBIENT: boolean;
  15168. AMBIENTDIRECTUV: number;
  15169. OPACITY: boolean;
  15170. OPACITYDIRECTUV: number;
  15171. OPACITYRGB: boolean;
  15172. REFLECTION: boolean;
  15173. EMISSIVE: boolean;
  15174. EMISSIVEDIRECTUV: number;
  15175. SPECULAR: boolean;
  15176. SPECULARDIRECTUV: number;
  15177. BUMP: boolean;
  15178. BUMPDIRECTUV: number;
  15179. PARALLAX: boolean;
  15180. PARALLAXOCCLUSION: boolean;
  15181. SPECULAROVERALPHA: boolean;
  15182. CLIPPLANE: boolean;
  15183. CLIPPLANE2: boolean;
  15184. CLIPPLANE3: boolean;
  15185. CLIPPLANE4: boolean;
  15186. ALPHATEST: boolean;
  15187. DEPTHPREPASS: boolean;
  15188. ALPHAFROMDIFFUSE: boolean;
  15189. POINTSIZE: boolean;
  15190. FOG: boolean;
  15191. SPECULARTERM: boolean;
  15192. DIFFUSEFRESNEL: boolean;
  15193. OPACITYFRESNEL: boolean;
  15194. REFLECTIONFRESNEL: boolean;
  15195. REFRACTIONFRESNEL: boolean;
  15196. EMISSIVEFRESNEL: boolean;
  15197. FRESNEL: boolean;
  15198. NORMAL: boolean;
  15199. UV1: boolean;
  15200. UV2: boolean;
  15201. VERTEXCOLOR: boolean;
  15202. VERTEXALPHA: boolean;
  15203. NUM_BONE_INFLUENCERS: number;
  15204. BonesPerMesh: number;
  15205. INSTANCES: boolean;
  15206. GLOSSINESS: boolean;
  15207. ROUGHNESS: boolean;
  15208. EMISSIVEASILLUMINATION: boolean;
  15209. LINKEMISSIVEWITHDIFFUSE: boolean;
  15210. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15211. LIGHTMAP: boolean;
  15212. LIGHTMAPDIRECTUV: number;
  15213. OBJECTSPACE_NORMALMAP: boolean;
  15214. USELIGHTMAPASSHADOWMAP: boolean;
  15215. REFLECTIONMAP_3D: boolean;
  15216. REFLECTIONMAP_SPHERICAL: boolean;
  15217. REFLECTIONMAP_PLANAR: boolean;
  15218. REFLECTIONMAP_CUBIC: boolean;
  15219. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15220. REFLECTIONMAP_PROJECTION: boolean;
  15221. REFLECTIONMAP_SKYBOX: boolean;
  15222. REFLECTIONMAP_EXPLICIT: boolean;
  15223. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15224. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15225. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15226. INVERTCUBICMAP: boolean;
  15227. LOGARITHMICDEPTH: boolean;
  15228. REFRACTION: boolean;
  15229. REFRACTIONMAP_3D: boolean;
  15230. REFLECTIONOVERALPHA: boolean;
  15231. TWOSIDEDLIGHTING: boolean;
  15232. SHADOWFLOAT: boolean;
  15233. MORPHTARGETS: boolean;
  15234. MORPHTARGETS_NORMAL: boolean;
  15235. MORPHTARGETS_TANGENT: boolean;
  15236. NUM_MORPH_INFLUENCERS: number;
  15237. NONUNIFORMSCALING: boolean;
  15238. PREMULTIPLYALPHA: boolean;
  15239. IMAGEPROCESSING: boolean;
  15240. VIGNETTE: boolean;
  15241. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15242. VIGNETTEBLENDMODEOPAQUE: boolean;
  15243. TONEMAPPING: boolean;
  15244. TONEMAPPING_ACES: boolean;
  15245. CONTRAST: boolean;
  15246. COLORCURVES: boolean;
  15247. COLORGRADING: boolean;
  15248. COLORGRADING3D: boolean;
  15249. SAMPLER3DGREENDEPTH: boolean;
  15250. SAMPLER3DBGRMAP: boolean;
  15251. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15252. /**
  15253. * If the reflection texture on this material is in linear color space
  15254. * @hidden
  15255. */
  15256. IS_REFLECTION_LINEAR: boolean;
  15257. /**
  15258. * If the refraction texture on this material is in linear color space
  15259. * @hidden
  15260. */
  15261. IS_REFRACTION_LINEAR: boolean;
  15262. EXPOSURE: boolean;
  15263. constructor();
  15264. setReflectionMode(modeToEnable: string): void;
  15265. }
  15266. class StandardMaterial extends PushMaterial {
  15267. private _diffuseTexture;
  15268. diffuseTexture: Nullable<BaseTexture>;
  15269. private _ambientTexture;
  15270. ambientTexture: Nullable<BaseTexture>;
  15271. private _opacityTexture;
  15272. opacityTexture: Nullable<BaseTexture>;
  15273. private _reflectionTexture;
  15274. reflectionTexture: Nullable<BaseTexture>;
  15275. private _emissiveTexture;
  15276. emissiveTexture: Nullable<BaseTexture>;
  15277. private _specularTexture;
  15278. specularTexture: Nullable<BaseTexture>;
  15279. private _bumpTexture;
  15280. bumpTexture: Nullable<BaseTexture>;
  15281. private _lightmapTexture;
  15282. lightmapTexture: Nullable<BaseTexture>;
  15283. private _refractionTexture;
  15284. refractionTexture: Nullable<BaseTexture>;
  15285. ambientColor: Color3;
  15286. diffuseColor: Color3;
  15287. specularColor: Color3;
  15288. emissiveColor: Color3;
  15289. specularPower: number;
  15290. private _useAlphaFromDiffuseTexture;
  15291. useAlphaFromDiffuseTexture: boolean;
  15292. private _useEmissiveAsIllumination;
  15293. useEmissiveAsIllumination: boolean;
  15294. private _linkEmissiveWithDiffuse;
  15295. linkEmissiveWithDiffuse: boolean;
  15296. private _useSpecularOverAlpha;
  15297. useSpecularOverAlpha: boolean;
  15298. private _useReflectionOverAlpha;
  15299. useReflectionOverAlpha: boolean;
  15300. private _disableLighting;
  15301. disableLighting: boolean;
  15302. private _useObjectSpaceNormalMap;
  15303. /**
  15304. * Allows using an object space normal map (instead of tangent space).
  15305. */
  15306. useObjectSpaceNormalMap: boolean;
  15307. private _useParallax;
  15308. useParallax: boolean;
  15309. private _useParallaxOcclusion;
  15310. useParallaxOcclusion: boolean;
  15311. parallaxScaleBias: number;
  15312. private _roughness;
  15313. roughness: number;
  15314. indexOfRefraction: number;
  15315. invertRefractionY: boolean;
  15316. /**
  15317. * Defines the alpha limits in alpha test mode
  15318. */
  15319. alphaCutOff: number;
  15320. private _useLightmapAsShadowmap;
  15321. useLightmapAsShadowmap: boolean;
  15322. private _diffuseFresnelParameters;
  15323. diffuseFresnelParameters: FresnelParameters;
  15324. private _opacityFresnelParameters;
  15325. opacityFresnelParameters: FresnelParameters;
  15326. private _reflectionFresnelParameters;
  15327. reflectionFresnelParameters: FresnelParameters;
  15328. private _refractionFresnelParameters;
  15329. refractionFresnelParameters: FresnelParameters;
  15330. private _emissiveFresnelParameters;
  15331. emissiveFresnelParameters: FresnelParameters;
  15332. private _useReflectionFresnelFromSpecular;
  15333. useReflectionFresnelFromSpecular: boolean;
  15334. private _useGlossinessFromSpecularMapAlpha;
  15335. useGlossinessFromSpecularMapAlpha: boolean;
  15336. private _maxSimultaneousLights;
  15337. maxSimultaneousLights: number;
  15338. /**
  15339. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15340. */
  15341. private _invertNormalMapX;
  15342. invertNormalMapX: boolean;
  15343. /**
  15344. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15345. */
  15346. private _invertNormalMapY;
  15347. invertNormalMapY: boolean;
  15348. /**
  15349. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15350. */
  15351. private _twoSidedLighting;
  15352. twoSidedLighting: boolean;
  15353. /**
  15354. * Default configuration related to image processing available in the standard Material.
  15355. */
  15356. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15357. /**
  15358. * Gets the image processing configuration used either in this material.
  15359. */
  15360. /**
  15361. * Sets the Default image processing configuration used either in the this material.
  15362. *
  15363. * If sets to null, the scene one is in use.
  15364. */
  15365. imageProcessingConfiguration: ImageProcessingConfiguration;
  15366. /**
  15367. * Keep track of the image processing observer to allow dispose and replace.
  15368. */
  15369. private _imageProcessingObserver;
  15370. /**
  15371. * Attaches a new image processing configuration to the Standard Material.
  15372. * @param configuration
  15373. */
  15374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15375. /**
  15376. * Gets wether the color curves effect is enabled.
  15377. */
  15378. /**
  15379. * Sets wether the color curves effect is enabled.
  15380. */
  15381. cameraColorCurvesEnabled: boolean;
  15382. /**
  15383. * Gets wether the color grading effect is enabled.
  15384. */
  15385. /**
  15386. * Gets wether the color grading effect is enabled.
  15387. */
  15388. cameraColorGradingEnabled: boolean;
  15389. /**
  15390. * Gets wether tonemapping is enabled or not.
  15391. */
  15392. /**
  15393. * Sets wether tonemapping is enabled or not
  15394. */
  15395. cameraToneMappingEnabled: boolean;
  15396. /**
  15397. * The camera exposure used on this material.
  15398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15399. * This corresponds to a photographic exposure.
  15400. */
  15401. /**
  15402. * The camera exposure used on this material.
  15403. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15404. * This corresponds to a photographic exposure.
  15405. */
  15406. cameraExposure: number;
  15407. /**
  15408. * Gets The camera contrast used on this material.
  15409. */
  15410. /**
  15411. * Sets The camera contrast used on this material.
  15412. */
  15413. cameraContrast: number;
  15414. /**
  15415. * Gets the Color Grading 2D Lookup Texture.
  15416. */
  15417. /**
  15418. * Sets the Color Grading 2D Lookup Texture.
  15419. */
  15420. cameraColorGradingTexture: Nullable<BaseTexture>;
  15421. /**
  15422. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15423. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15424. * 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;
  15425. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15426. */
  15427. /**
  15428. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15429. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15430. * 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;
  15431. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15432. */
  15433. cameraColorCurves: Nullable<ColorCurves>;
  15434. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15435. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15436. protected _worldViewProjectionMatrix: Matrix;
  15437. protected _globalAmbientColor: Color3;
  15438. protected _useLogarithmicDepth: boolean;
  15439. constructor(name: string, scene: Scene);
  15440. getClassName(): string;
  15441. useLogarithmicDepth: boolean;
  15442. needAlphaBlending(): boolean;
  15443. needAlphaTesting(): boolean;
  15444. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15445. getAlphaTestTexture(): Nullable<BaseTexture>;
  15446. /**
  15447. * Child classes can use it to update shaders
  15448. */
  15449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15450. buildUniformLayout(): void;
  15451. unbind(): void;
  15452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15453. getAnimatables(): IAnimatable[];
  15454. getActiveTextures(): BaseTexture[];
  15455. hasTexture(texture: BaseTexture): boolean;
  15456. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15457. clone(name: string): StandardMaterial;
  15458. serialize(): any;
  15459. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15460. static _DiffuseTextureEnabled: boolean;
  15461. static DiffuseTextureEnabled: boolean;
  15462. static _AmbientTextureEnabled: boolean;
  15463. static AmbientTextureEnabled: boolean;
  15464. static _OpacityTextureEnabled: boolean;
  15465. static OpacityTextureEnabled: boolean;
  15466. static _ReflectionTextureEnabled: boolean;
  15467. static ReflectionTextureEnabled: boolean;
  15468. static _EmissiveTextureEnabled: boolean;
  15469. static EmissiveTextureEnabled: boolean;
  15470. static _SpecularTextureEnabled: boolean;
  15471. static SpecularTextureEnabled: boolean;
  15472. static _BumpTextureEnabled: boolean;
  15473. static BumpTextureEnabled: boolean;
  15474. static _LightmapTextureEnabled: boolean;
  15475. static LightmapTextureEnabled: boolean;
  15476. static _RefractionTextureEnabled: boolean;
  15477. static RefractionTextureEnabled: boolean;
  15478. static _ColorGradingTextureEnabled: boolean;
  15479. static ColorGradingTextureEnabled: boolean;
  15480. static _FresnelEnabled: boolean;
  15481. static FresnelEnabled: boolean;
  15482. }
  15483. }
  15484. declare module BABYLON {
  15485. class UniformBuffer {
  15486. private _engine;
  15487. private _buffer;
  15488. private _data;
  15489. private _bufferData;
  15490. private _dynamic?;
  15491. private _uniformLocations;
  15492. private _uniformSizes;
  15493. private _uniformLocationPointer;
  15494. private _needSync;
  15495. private _noUBO;
  15496. private _currentEffect;
  15497. private static _MAX_UNIFORM_SIZE;
  15498. private static _tempBuffer;
  15499. /**
  15500. * Wrapper for updateUniform.
  15501. * @method updateMatrix3x3
  15502. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15503. * @param {Float32Array} matrix
  15504. */
  15505. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15506. /**
  15507. * Wrapper for updateUniform.
  15508. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15509. * @param {Float32Array} matrix
  15510. */
  15511. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15512. /**
  15513. * Wrapper for updateUniform.
  15514. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15515. * @param {number} x
  15516. */
  15517. updateFloat: (name: string, x: number) => void;
  15518. /**
  15519. * Wrapper for updateUniform.
  15520. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15521. * @param {number} x
  15522. * @param {number} y
  15523. * @param {string} [suffix] Suffix to add to the uniform name.
  15524. */
  15525. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15526. /**
  15527. * Wrapper for updateUniform.
  15528. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15529. * @param {number} x
  15530. * @param {number} y
  15531. * @param {number} z
  15532. * @param {string} [suffix] Suffix to add to the uniform name.
  15533. */
  15534. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15535. /**
  15536. * Wrapper for updateUniform.
  15537. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15538. * @param {number} x
  15539. * @param {number} y
  15540. * @param {number} z
  15541. * @param {number} w
  15542. * @param {string} [suffix] Suffix to add to the uniform name.
  15543. */
  15544. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15545. /**
  15546. * Wrapper for updateUniform.
  15547. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15548. * @param {Matrix} A 4x4 matrix.
  15549. */
  15550. updateMatrix: (name: string, mat: Matrix) => void;
  15551. /**
  15552. * Wrapper for updateUniform.
  15553. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15554. * @param {Vector3} vector
  15555. */
  15556. updateVector3: (name: string, vector: Vector3) => void;
  15557. /**
  15558. * Wrapper for updateUniform.
  15559. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15560. * @param {Vector4} vector
  15561. */
  15562. updateVector4: (name: string, vector: Vector4) => void;
  15563. /**
  15564. * Wrapper for updateUniform.
  15565. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15566. * @param {Color3} color
  15567. * @param {string} [suffix] Suffix to add to the uniform name.
  15568. */
  15569. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15570. /**
  15571. * Wrapper for updateUniform.
  15572. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15573. * @param {Color3} color
  15574. * @param {number} alpha
  15575. * @param {string} [suffix] Suffix to add to the uniform name.
  15576. */
  15577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15578. /**
  15579. * Uniform buffer objects.
  15580. *
  15581. * Handles blocks of uniform on the GPU.
  15582. *
  15583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15584. *
  15585. * For more information, please refer to :
  15586. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15587. */
  15588. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15589. /**
  15590. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15591. * or just falling back on setUniformXXX calls.
  15592. */
  15593. readonly useUbo: boolean;
  15594. /**
  15595. * Indicates if the WebGL underlying uniform buffer is in sync
  15596. * with the javascript cache data.
  15597. */
  15598. readonly isSync: boolean;
  15599. /**
  15600. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15601. * Also, a dynamic UniformBuffer will disable cache verification and always
  15602. * update the underlying WebGL uniform buffer to the GPU.
  15603. */
  15604. isDynamic(): boolean;
  15605. /**
  15606. * The data cache on JS side.
  15607. */
  15608. getData(): Float32Array;
  15609. /**
  15610. * The underlying WebGL Uniform buffer.
  15611. */
  15612. getBuffer(): Nullable<WebGLBuffer>;
  15613. /**
  15614. * std140 layout specifies how to align data within an UBO structure.
  15615. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15616. * for specs.
  15617. */
  15618. private _fillAlignment;
  15619. /**
  15620. * Adds an uniform in the buffer.
  15621. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15622. * for the layout to be correct !
  15623. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15624. * @param {number|number[]} size Data size, or data directly.
  15625. */
  15626. addUniform(name: string, size: number | number[]): void;
  15627. /**
  15628. * Wrapper for addUniform.
  15629. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15630. * @param {Matrix} mat A 4x4 matrix.
  15631. */
  15632. addMatrix(name: string, mat: Matrix): void;
  15633. /**
  15634. * Wrapper for addUniform.
  15635. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15636. * @param {number} x
  15637. * @param {number} y
  15638. */
  15639. addFloat2(name: string, x: number, y: number): void;
  15640. /**
  15641. * Wrapper for addUniform.
  15642. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15643. * @param {number} x
  15644. * @param {number} y
  15645. * @param {number} z
  15646. */
  15647. addFloat3(name: string, x: number, y: number, z: number): void;
  15648. /**
  15649. * Wrapper for addUniform.
  15650. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15651. * @param {Color3} color
  15652. */
  15653. addColor3(name: string, color: Color3): void;
  15654. /**
  15655. * Wrapper for addUniform.
  15656. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15657. * @param {Color3} color
  15658. * @param {number} alpha
  15659. */
  15660. addColor4(name: string, color: Color3, alpha: number): void;
  15661. /**
  15662. * Wrapper for addUniform.
  15663. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15664. * @param {Vector3} vector
  15665. */
  15666. addVector3(name: string, vector: Vector3): void;
  15667. /**
  15668. * Wrapper for addUniform.
  15669. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15670. */
  15671. addMatrix3x3(name: string): void;
  15672. /**
  15673. * Wrapper for addUniform.
  15674. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15675. */
  15676. addMatrix2x2(name: string): void;
  15677. /**
  15678. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15679. */
  15680. create(): void;
  15681. /** @hidden */
  15682. _rebuild(): void;
  15683. /**
  15684. * Updates the WebGL Uniform Buffer on the GPU.
  15685. * If the `dynamic` flag is set to true, no cache comparison is done.
  15686. * Otherwise, the buffer will be updated only if the cache differs.
  15687. */
  15688. update(): void;
  15689. /**
  15690. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15691. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15692. * @param {number[]|Float32Array} data Flattened data
  15693. * @param {number} size Size of the data.
  15694. */
  15695. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15696. private _updateMatrix3x3ForUniform;
  15697. private _updateMatrix3x3ForEffect;
  15698. private _updateMatrix2x2ForEffect;
  15699. private _updateMatrix2x2ForUniform;
  15700. private _updateFloatForEffect;
  15701. private _updateFloatForUniform;
  15702. private _updateFloat2ForEffect;
  15703. private _updateFloat2ForUniform;
  15704. private _updateFloat3ForEffect;
  15705. private _updateFloat3ForUniform;
  15706. private _updateFloat4ForEffect;
  15707. private _updateFloat4ForUniform;
  15708. private _updateMatrixForEffect;
  15709. private _updateMatrixForUniform;
  15710. private _updateVector3ForEffect;
  15711. private _updateVector3ForUniform;
  15712. private _updateVector4ForEffect;
  15713. private _updateVector4ForUniform;
  15714. private _updateColor3ForEffect;
  15715. private _updateColor3ForUniform;
  15716. private _updateColor4ForEffect;
  15717. private _updateColor4ForUniform;
  15718. /**
  15719. * Sets a sampler uniform on the effect.
  15720. * @param {string} name Name of the sampler.
  15721. * @param {Texture} texture
  15722. */
  15723. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15724. /**
  15725. * Directly updates the value of the uniform in the cache AND on the GPU.
  15726. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15727. * @param {number[]|Float32Array} data Flattened data
  15728. */
  15729. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15730. /**
  15731. * Binds this uniform buffer to an effect.
  15732. * @param {Effect} effect
  15733. * @param {string} name Name of the uniform block in the shader.
  15734. */
  15735. bindToEffect(effect: Effect, name: string): void;
  15736. /**
  15737. * Disposes the uniform buffer.
  15738. */
  15739. dispose(): void;
  15740. }
  15741. }
  15742. declare module BABYLON {
  15743. class Scalar {
  15744. /**
  15745. * Two pi constants convenient for computation.
  15746. */
  15747. static TwoPi: number;
  15748. /**
  15749. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15750. */
  15751. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15752. /**
  15753. * Returns a string : the upper case translation of the number i to hexadecimal.
  15754. */
  15755. static ToHex(i: number): string;
  15756. /**
  15757. * Returns -1 if value is negative and +1 is value is positive.
  15758. * Returns the value itself if it's equal to zero.
  15759. */
  15760. static Sign(value: number): number;
  15761. /**
  15762. * Returns the value itself if it's between min and max.
  15763. * Returns min if the value is lower than min.
  15764. * Returns max if the value is greater than max.
  15765. */
  15766. static Clamp(value: number, min?: number, max?: number): number;
  15767. /**
  15768. * Returns the log2 of value.
  15769. */
  15770. static Log2(value: number): number;
  15771. /**
  15772. * Loops the value, so that it is never larger than length and never smaller than 0.
  15773. *
  15774. * This is similar to the modulo operator but it works with floating point numbers.
  15775. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15776. * With t = 5 and length = 2.5, the result would be 0.0.
  15777. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15778. */
  15779. static Repeat(value: number, length: number): number;
  15780. /**
  15781. * Normalize the value between 0.0 and 1.0 using min and max values
  15782. */
  15783. static Normalize(value: number, min: number, max: number): number;
  15784. /**
  15785. * Denormalize the value from 0.0 and 1.0 using min and max values
  15786. */
  15787. static Denormalize(normalized: number, min: number, max: number): number;
  15788. /**
  15789. * Calculates the shortest difference between two given angles given in degrees.
  15790. */
  15791. static DeltaAngle(current: number, target: number): number;
  15792. /**
  15793. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15794. *
  15795. * The returned value will move back and forth between 0 and length
  15796. */
  15797. static PingPong(tx: number, length: number): number;
  15798. /**
  15799. * Interpolates between min and max with smoothing at the limits.
  15800. *
  15801. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15802. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15803. */
  15804. static SmoothStep(from: number, to: number, tx: number): number;
  15805. /**
  15806. * Moves a value current towards target.
  15807. *
  15808. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15809. * Negative values of maxDelta pushes the value away from target.
  15810. */
  15811. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15812. /**
  15813. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15814. *
  15815. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15816. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15817. */
  15818. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15819. /**
  15820. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15821. */
  15822. static Lerp(start: number, end: number, amount: number): number;
  15823. /**
  15824. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15825. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15826. */
  15827. static LerpAngle(start: number, end: number, amount: number): number;
  15828. /**
  15829. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15830. */
  15831. static InverseLerp(a: number, b: number, value: number): number;
  15832. /**
  15833. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15834. */
  15835. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15836. /**
  15837. * Returns a random float number between and min and max values
  15838. */
  15839. static RandomRange(min: number, max: number): number;
  15840. /**
  15841. * This function returns percentage of a number in a given range.
  15842. *
  15843. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15844. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15845. */
  15846. static RangeToPercent(number: number, min: number, max: number): number;
  15847. /**
  15848. * This function returns number that corresponds to the percentage in a given range.
  15849. *
  15850. * PercentToRange(0.34,0,100) will return 34.
  15851. */
  15852. static PercentToRange(percent: number, min: number, max: number): number;
  15853. /**
  15854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15855. * @param angle The angle to normalize in radian.
  15856. * @return The converted angle.
  15857. */
  15858. static NormalizeRadians(angle: number): number;
  15859. }
  15860. }
  15861. declare module BABYLON {
  15862. const ToGammaSpace: number;
  15863. const ToLinearSpace = 2.2;
  15864. const Epsilon = 0.001;
  15865. /**
  15866. * Class used to hold a RBG color
  15867. */
  15868. class Color3 {
  15869. /**
  15870. * Defines the red component (between 0 and 1, default is 0)
  15871. */
  15872. r: number;
  15873. /**
  15874. * Defines the green component (between 0 and 1, default is 0)
  15875. */
  15876. g: number;
  15877. /**
  15878. * Defines the blue component (between 0 and 1, default is 0)
  15879. */
  15880. b: number;
  15881. /**
  15882. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15883. * @param r defines the red component (between 0 and 1, default is 0)
  15884. * @param g defines the green component (between 0 and 1, default is 0)
  15885. * @param b defines the blue component (between 0 and 1, default is 0)
  15886. */
  15887. constructor(
  15888. /**
  15889. * Defines the red component (between 0 and 1, default is 0)
  15890. */
  15891. r?: number,
  15892. /**
  15893. * Defines the green component (between 0 and 1, default is 0)
  15894. */
  15895. g?: number,
  15896. /**
  15897. * Defines the blue component (between 0 and 1, default is 0)
  15898. */
  15899. b?: number);
  15900. /**
  15901. * Creates a string with the Color3 current values
  15902. * @returns the string representation of the Color3 object
  15903. */
  15904. toString(): string;
  15905. /**
  15906. * Returns the string "Color3"
  15907. * @returns "Color3"
  15908. */
  15909. getClassName(): string;
  15910. /**
  15911. * Compute the Color3 hash code
  15912. * @returns an unique number that can be used to hash Color3 objects
  15913. */
  15914. getHashCode(): number;
  15915. /**
  15916. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15917. * @param array defines the array where to store the r,g,b components
  15918. * @param index defines an optional index in the target array to define where to start storing values
  15919. * @returns the current Color3 object
  15920. */
  15921. toArray(array: FloatArray, index?: number): Color3;
  15922. /**
  15923. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15924. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15925. * @returns a new {BABYLON.Color4} object
  15926. */
  15927. toColor4(alpha?: number): Color4;
  15928. /**
  15929. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15930. * @returns the new array
  15931. */
  15932. asArray(): number[];
  15933. /**
  15934. * Returns the luminance value
  15935. * @returns a float value
  15936. */
  15937. toLuminance(): number;
  15938. /**
  15939. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15940. * @param otherColor defines the second operand
  15941. * @returns the new Color3 object
  15942. */
  15943. multiply(otherColor: Color3): Color3;
  15944. /**
  15945. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15946. * @param otherColor defines the second operand
  15947. * @param result defines the Color3 object where to store the result
  15948. * @returns the current Color3
  15949. */
  15950. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15951. /**
  15952. * Determines equality between Color3 objects
  15953. * @param otherColor defines the second operand
  15954. * @returns true if the rgb values are equal to the given ones
  15955. */
  15956. equals(otherColor: Color3): boolean;
  15957. /**
  15958. * Determines equality between the current Color3 object and a set of r,b,g values
  15959. * @param r defines the red component to check
  15960. * @param g defines the green component to check
  15961. * @param b defines the blue component to check
  15962. * @returns true if the rgb values are equal to the given ones
  15963. */
  15964. equalsFloats(r: number, g: number, b: number): boolean;
  15965. /**
  15966. * Multiplies in place each rgb value by scale
  15967. * @param scale defines the scaling factor
  15968. * @returns the updated Color3
  15969. */
  15970. scale(scale: number): Color3;
  15971. /**
  15972. * Multiplies the rgb values by scale and stores the result into "result"
  15973. * @param scale defines the scaling factor
  15974. * @param result defines the Color3 object where to store the result
  15975. * @returns the unmodified current Color3
  15976. */
  15977. scaleToRef(scale: number, result: Color3): Color3;
  15978. /**
  15979. * Scale the current Color3 values by a factor and add the result to a given Color3
  15980. * @param scale defines the scale factor
  15981. * @param result defines color to store the result into
  15982. * @returns the unmodified current Color3
  15983. */
  15984. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15985. /**
  15986. * Clamps the rgb values by the min and max values and stores the result into "result"
  15987. * @param min defines minimum clamping value (default is 0)
  15988. * @param max defines maximum clamping value (default is 1)
  15989. * @param result defines color to store the result into
  15990. * @returns the original Color3
  15991. */
  15992. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15993. /**
  15994. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15995. * @param otherColor defines the second operand
  15996. * @returns the new Color3
  15997. */
  15998. add(otherColor: Color3): Color3;
  15999. /**
  16000. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16001. * @param otherColor defines the second operand
  16002. * @param result defines Color3 object to store the result into
  16003. * @returns the unmodified current Color3
  16004. */
  16005. addToRef(otherColor: Color3, result: Color3): Color3;
  16006. /**
  16007. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16008. * @param otherColor defines the second operand
  16009. * @returns the new Color3
  16010. */
  16011. subtract(otherColor: Color3): Color3;
  16012. /**
  16013. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16014. * @param otherColor defines the second operand
  16015. * @param result defines Color3 object to store the result into
  16016. * @returns the unmodified current Color3
  16017. */
  16018. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16019. /**
  16020. * Copy the current object
  16021. * @returns a new Color3 copied the current one
  16022. */
  16023. clone(): Color3;
  16024. /**
  16025. * Copies the rgb values from the source in the current Color3
  16026. * @param source defines the source Color3 object
  16027. * @returns the updated Color3 object
  16028. */
  16029. copyFrom(source: Color3): Color3;
  16030. /**
  16031. * Updates the Color3 rgb values from the given floats
  16032. * @param r defines the red component to read from
  16033. * @param g defines the green component to read from
  16034. * @param b defines the blue component to read from
  16035. * @returns the current Color3 object
  16036. */
  16037. copyFromFloats(r: number, g: number, b: number): Color3;
  16038. /**
  16039. * Updates the Color3 rgb values from the given floats
  16040. * @param r defines the red component to read from
  16041. * @param g defines the green component to read from
  16042. * @param b defines the blue component to read from
  16043. * @returns the current Color3 object
  16044. */
  16045. set(r: number, g: number, b: number): Color3;
  16046. /**
  16047. * Compute the Color3 hexadecimal code as a string
  16048. * @returns a string containing the hexadecimal representation of the Color3 object
  16049. */
  16050. toHexString(): string;
  16051. /**
  16052. * Computes a new Color3 converted from the current one to linear space
  16053. * @returns a new Color3 object
  16054. */
  16055. toLinearSpace(): Color3;
  16056. /**
  16057. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  16058. * @param convertedColor defines the Color3 object where to store the linear space version
  16059. * @returns the unmodified Color3
  16060. */
  16061. toLinearSpaceToRef(convertedColor: Color3): Color3;
  16062. /**
  16063. * Computes a new Color3 converted from the current one to gamma space
  16064. * @returns a new Color3 object
  16065. */
  16066. toGammaSpace(): Color3;
  16067. /**
  16068. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  16069. * @param convertedColor defines the Color3 object where to store the gamma space version
  16070. * @returns the unmodified Color3
  16071. */
  16072. toGammaSpaceToRef(convertedColor: Color3): Color3;
  16073. /**
  16074. * Creates a new Color3 from the string containing valid hexadecimal values
  16075. * @param hex defines a string containing valid hexadecimal values
  16076. * @returns a new Color3 object
  16077. */
  16078. static FromHexString(hex: string): Color3;
  16079. /**
  16080. * Creates a new Vector3 from the starting index of the given array
  16081. * @param array defines the source array
  16082. * @param offset defines an offset in the source array
  16083. * @returns a new Color3 object
  16084. */
  16085. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  16086. /**
  16087. * Creates a new Color3 from integer values (< 256)
  16088. * @param r defines the red component to read from (value between 0 and 255)
  16089. * @param g defines the green component to read from (value between 0 and 255)
  16090. * @param b defines the blue component to read from (value between 0 and 255)
  16091. * @returns a new Color3 object
  16092. */
  16093. static FromInts(r: number, g: number, b: number): Color3;
  16094. /**
  16095. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16096. * @param start defines the start Color3 value
  16097. * @param end defines the end Color3 value
  16098. * @param amount defines the gradient value between start and end
  16099. * @returns a new Color3 object
  16100. */
  16101. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  16102. /**
  16103. * Returns a Color3 value containing a red color
  16104. * @returns a new Color3 object
  16105. */
  16106. static Red(): Color3;
  16107. /**
  16108. * Returns a Color3 value containing a green color
  16109. * @returns a new Color3 object
  16110. */
  16111. static Green(): Color3;
  16112. /**
  16113. * Returns a Color3 value containing a blue color
  16114. * @returns a new Color3 object
  16115. */
  16116. static Blue(): Color3;
  16117. /**
  16118. * Returns a Color3 value containing a black color
  16119. * @returns a new Color3 object
  16120. */
  16121. static Black(): Color3;
  16122. /**
  16123. * Returns a Color3 value containing a white color
  16124. * @returns a new Color3 object
  16125. */
  16126. static White(): Color3;
  16127. /**
  16128. * Returns a Color3 value containing a purple color
  16129. * @returns a new Color3 object
  16130. */
  16131. static Purple(): Color3;
  16132. /**
  16133. * Returns a Color3 value containing a magenta color
  16134. * @returns a new Color3 object
  16135. */
  16136. static Magenta(): Color3;
  16137. /**
  16138. * Returns a Color3 value containing a yellow color
  16139. * @returns a new Color3 object
  16140. */
  16141. static Yellow(): Color3;
  16142. /**
  16143. * Returns a Color3 value containing a gray color
  16144. * @returns a new Color3 object
  16145. */
  16146. static Gray(): Color3;
  16147. /**
  16148. * Returns a Color3 value containing a teal color
  16149. * @returns a new Color3 object
  16150. */
  16151. static Teal(): Color3;
  16152. /**
  16153. * Returns a Color3 value containing a random color
  16154. * @returns a new Color3 object
  16155. */
  16156. static Random(): Color3;
  16157. }
  16158. /**
  16159. * Class used to hold a RBGA color
  16160. */
  16161. class Color4 {
  16162. /**
  16163. * Defines the red component (between 0 and 1, default is 0)
  16164. */
  16165. r: number;
  16166. /**
  16167. * Defines the green component (between 0 and 1, default is 0)
  16168. */
  16169. g: number;
  16170. /**
  16171. * Defines the blue component (between 0 and 1, default is 0)
  16172. */
  16173. b: number;
  16174. /**
  16175. * Defines the alpha component (between 0 and 1, default is 1)
  16176. */
  16177. a: number;
  16178. /**
  16179. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  16180. * @param r defines the red component (between 0 and 1, default is 0)
  16181. * @param g defines the green component (between 0 and 1, default is 0)
  16182. * @param b defines the blue component (between 0 and 1, default is 0)
  16183. * @param a defines the alpha component (between 0 and 1, default is 1)
  16184. */
  16185. constructor(
  16186. /**
  16187. * Defines the red component (between 0 and 1, default is 0)
  16188. */
  16189. r?: number,
  16190. /**
  16191. * Defines the green component (between 0 and 1, default is 0)
  16192. */
  16193. g?: number,
  16194. /**
  16195. * Defines the blue component (between 0 and 1, default is 0)
  16196. */
  16197. b?: number,
  16198. /**
  16199. * Defines the alpha component (between 0 and 1, default is 1)
  16200. */
  16201. a?: number);
  16202. /**
  16203. * Adds in place the given Color4 values to the current Color4 object
  16204. * @param right defines the second operand
  16205. * @returns the current updated Color4 object
  16206. */
  16207. addInPlace(right: Color4): Color4;
  16208. /**
  16209. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  16210. * @returns the new array
  16211. */
  16212. asArray(): number[];
  16213. /**
  16214. * Stores from the starting index in the given array the Color4 successive values
  16215. * @param array defines the array where to store the r,g,b components
  16216. * @param index defines an optional index in the target array to define where to start storing values
  16217. * @returns the current Color4 object
  16218. */
  16219. toArray(array: number[], index?: number): Color4;
  16220. /**
  16221. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  16222. * @param right defines the second operand
  16223. * @returns a new Color4 object
  16224. */
  16225. add(right: Color4): Color4;
  16226. /**
  16227. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16228. * @param right defines the second operand
  16229. * @returns a new Color4 object
  16230. */
  16231. subtract(right: Color4): Color4;
  16232. /**
  16233. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16234. * @param right defines the second operand
  16235. * @param result defines the Color4 object where to store the result
  16236. * @returns the current Color4 object
  16237. */
  16238. subtractToRef(right: Color4, result: Color4): Color4;
  16239. /**
  16240. * Creates a new Color4 with the current Color4 values multiplied by scale
  16241. * @param scale defines the scaling factor to apply
  16242. * @returns a new Color4 object
  16243. */
  16244. scale(scale: number): Color4;
  16245. /**
  16246. * Multiplies the current Color4 values by scale and stores the result in "result"
  16247. * @param scale defines the scaling factor to apply
  16248. * @param result defines the Color4 object where to store the result
  16249. * @returns the current unmodified Color4
  16250. */
  16251. scaleToRef(scale: number, result: Color4): Color4;
  16252. /**
  16253. * Scale the current Color4 values by a factor and add the result to a given Color4
  16254. * @param scale defines the scale factor
  16255. * @param result defines the Color4 object where to store the result
  16256. * @returns the unmodified current Color4
  16257. */
  16258. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16259. /**
  16260. * Clamps the rgb values by the min and max values and stores the result into "result"
  16261. * @param min defines minimum clamping value (default is 0)
  16262. * @param max defines maximum clamping value (default is 1)
  16263. * @param result defines color to store the result into.
  16264. * @returns the cuurent Color4
  16265. */
  16266. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16267. /**
  16268. * Multipy an Color4 value by another and return a new Color4 object
  16269. * @param color defines the Color4 value to multiply by
  16270. * @returns a new Color4 object
  16271. */
  16272. multiply(color: Color4): Color4;
  16273. /**
  16274. * Multipy a Color4 value by another and push the result in a reference value
  16275. * @param color defines the Color4 value to multiply by
  16276. * @param result defines the Color4 to fill the result in
  16277. * @returns the result Color4
  16278. */
  16279. multiplyToRef(color: Color4, result: Color4): Color4;
  16280. /**
  16281. * Creates a string with the Color4 current values
  16282. * @returns the string representation of the Color4 object
  16283. */
  16284. toString(): string;
  16285. /**
  16286. * Returns the string "Color4"
  16287. * @returns "Color4"
  16288. */
  16289. getClassName(): string;
  16290. /**
  16291. * Compute the Color4 hash code
  16292. * @returns an unique number that can be used to hash Color4 objects
  16293. */
  16294. getHashCode(): number;
  16295. /**
  16296. * Creates a new Color4 copied from the current one
  16297. * @returns a new Color4 object
  16298. */
  16299. clone(): Color4;
  16300. /**
  16301. * Copies the given Color4 values into the current one
  16302. * @param source defines the source Color4 object
  16303. * @returns the current updated Color4 object
  16304. */
  16305. copyFrom(source: Color4): Color4;
  16306. /**
  16307. * Copies the given float values into the current one
  16308. * @param r defines the red component to read from
  16309. * @param g defines the green component to read from
  16310. * @param b defines the blue component to read from
  16311. * @param a defines the alpha component to read from
  16312. * @returns the current updated Color4 object
  16313. */
  16314. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16315. /**
  16316. * Copies the given float values into the current one
  16317. * @param r defines the red component to read from
  16318. * @param g defines the green component to read from
  16319. * @param b defines the blue component to read from
  16320. * @param a defines the alpha component to read from
  16321. * @returns the current updated Color4 object
  16322. */
  16323. set(r: number, g: number, b: number, a: number): Color4;
  16324. /**
  16325. * Compute the Color4 hexadecimal code as a string
  16326. * @returns a string containing the hexadecimal representation of the Color4 object
  16327. */
  16328. toHexString(): string;
  16329. /**
  16330. * Computes a new Color4 converted from the current one to linear space
  16331. * @returns a new Color4 object
  16332. */
  16333. toLinearSpace(): Color4;
  16334. /**
  16335. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16336. * @param convertedColor defines the Color4 object where to store the linear space version
  16337. * @returns the unmodified Color4
  16338. */
  16339. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16340. /**
  16341. * Computes a new Color4 converted from the current one to gamma space
  16342. * @returns a new Color4 object
  16343. */
  16344. toGammaSpace(): Color4;
  16345. /**
  16346. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16347. * @param convertedColor defines the Color4 object where to store the gamma space version
  16348. * @returns the unmodified Color4
  16349. */
  16350. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16351. /**
  16352. * Creates a new Color4 from the string containing valid hexadecimal values
  16353. * @param hex defines a string containing valid hexadecimal values
  16354. * @returns a new Color4 object
  16355. */
  16356. static FromHexString(hex: string): Color4;
  16357. /**
  16358. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16359. * @param left defines the start value
  16360. * @param right defines the end value
  16361. * @param amount defines the gradient factor
  16362. * @returns a new Color4 object
  16363. */
  16364. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16365. /**
  16366. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16367. * @param left defines the start value
  16368. * @param right defines the end value
  16369. * @param amount defines the gradient factor
  16370. * @param result defines the Color4 object where to store data
  16371. */
  16372. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16373. /**
  16374. * Creates a new Color4 from the starting index element of the given array
  16375. * @param array defines the source array to read from
  16376. * @param offset defines the offset in the source array
  16377. * @returns a new Color4 object
  16378. */
  16379. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16380. /**
  16381. * Creates a new Color3 from integer values (< 256)
  16382. * @param r defines the red component to read from (value between 0 and 255)
  16383. * @param g defines the green component to read from (value between 0 and 255)
  16384. * @param b defines the blue component to read from (value between 0 and 255)
  16385. * @param a defines the alpha component to read from (value between 0 and 255)
  16386. * @returns a new Color3 object
  16387. */
  16388. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16389. /**
  16390. * Check the content of a given array and convert it to an array containing RGBA data
  16391. * If the original array was already containing count * 4 values then it is returned directly
  16392. * @param colors defines the array to check
  16393. * @param count defines the number of RGBA data to expect
  16394. * @returns an array containing count * 4 values (RGBA)
  16395. */
  16396. static CheckColors4(colors: number[], count: number): number[];
  16397. }
  16398. /**
  16399. * Class representing a vector containing 2 coordinates
  16400. */
  16401. class Vector2 {
  16402. /** defines the first coordinate */
  16403. x: number;
  16404. /** defines the second coordinate */
  16405. y: number;
  16406. /**
  16407. * Creates a new Vector2 from the given x and y coordinates
  16408. * @param x defines the first coordinate
  16409. * @param y defines the second coordinate
  16410. */
  16411. constructor(
  16412. /** defines the first coordinate */
  16413. x?: number,
  16414. /** defines the second coordinate */
  16415. y?: number);
  16416. /**
  16417. * Gets a string with the Vector2 coordinates
  16418. * @returns a string with the Vector2 coordinates
  16419. */
  16420. toString(): string;
  16421. /**
  16422. * Gets class name
  16423. * @returns the string "Vector2"
  16424. */
  16425. getClassName(): string;
  16426. /**
  16427. * Gets current vector hash code
  16428. * @returns the Vector2 hash code as a number
  16429. */
  16430. getHashCode(): number;
  16431. /**
  16432. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16433. * @param array defines the source array
  16434. * @param index defines the offset in source array
  16435. * @returns the current Vector2
  16436. */
  16437. toArray(array: FloatArray, index?: number): Vector2;
  16438. /**
  16439. * Copy the current vector to an array
  16440. * @returns a new array with 2 elements: the Vector2 coordinates.
  16441. */
  16442. asArray(): number[];
  16443. /**
  16444. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16445. * @param source defines the source Vector2
  16446. * @returns the current updated Vector2
  16447. */
  16448. copyFrom(source: Vector2): Vector2;
  16449. /**
  16450. * Sets the Vector2 coordinates with the given floats
  16451. * @param x defines the first coordinate
  16452. * @param y defines the second coordinate
  16453. * @returns the current updated Vector2
  16454. */
  16455. copyFromFloats(x: number, y: number): Vector2;
  16456. /**
  16457. * Sets the Vector2 coordinates with the given floats
  16458. * @param x defines the first coordinate
  16459. * @param y defines the second coordinate
  16460. * @returns the current updated Vector2
  16461. */
  16462. set(x: number, y: number): Vector2;
  16463. /**
  16464. * Add another vector with the current one
  16465. * @param otherVector defines the other vector
  16466. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16467. */
  16468. add(otherVector: Vector2): Vector2;
  16469. /**
  16470. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16471. * @param otherVector defines the other vector
  16472. * @param result defines the target vector
  16473. * @returns the unmodified current Vector2
  16474. */
  16475. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16476. /**
  16477. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16478. * @param otherVector defines the other vector
  16479. * @returns the current updated Vector2
  16480. */
  16481. addInPlace(otherVector: Vector2): Vector2;
  16482. /**
  16483. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16484. * @param otherVector defines the other vector
  16485. * @returns a new Vector2
  16486. */
  16487. addVector3(otherVector: Vector3): Vector2;
  16488. /**
  16489. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16490. * @param otherVector defines the other vector
  16491. * @returns a new Vector2
  16492. */
  16493. subtract(otherVector: Vector2): Vector2;
  16494. /**
  16495. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16496. * @param otherVector defines the other vector
  16497. * @param result defines the target vector
  16498. * @returns the unmodified current Vector2
  16499. */
  16500. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16501. /**
  16502. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16503. * @param otherVector defines the other vector
  16504. * @returns the current updated Vector2
  16505. */
  16506. subtractInPlace(otherVector: Vector2): Vector2;
  16507. /**
  16508. * Multiplies in place the current Vector2 coordinates by the given ones
  16509. * @param otherVector defines the other vector
  16510. * @returns the current updated Vector2
  16511. */
  16512. multiplyInPlace(otherVector: Vector2): Vector2;
  16513. /**
  16514. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16515. * @param otherVector defines the other vector
  16516. * @returns a new Vector2
  16517. */
  16518. multiply(otherVector: Vector2): Vector2;
  16519. /**
  16520. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16521. * @param otherVector defines the other vector
  16522. * @param result defines the target vector
  16523. * @returns the unmodified current Vector2
  16524. */
  16525. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16526. /**
  16527. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16528. * @param x defines the first coordinate
  16529. * @param y defines the second coordinate
  16530. * @returns a new Vector2
  16531. */
  16532. multiplyByFloats(x: number, y: number): Vector2;
  16533. /**
  16534. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16535. * @param otherVector defines the other vector
  16536. * @returns a new Vector2
  16537. */
  16538. divide(otherVector: Vector2): Vector2;
  16539. /**
  16540. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16541. * @param otherVector defines the other vector
  16542. * @param result defines the target vector
  16543. * @returns the unmodified current Vector2
  16544. */
  16545. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16546. /**
  16547. * Divides the current Vector2 coordinates by the given ones
  16548. * @param otherVector defines the other vector
  16549. * @returns the current updated Vector2
  16550. */
  16551. divideInPlace(otherVector: Vector2): Vector2;
  16552. /**
  16553. * Gets a new Vector2 with current Vector2 negated coordinates
  16554. * @returns a new Vector2
  16555. */
  16556. negate(): Vector2;
  16557. /**
  16558. * Multiply the Vector2 coordinates by scale
  16559. * @param scale defines the scaling factor
  16560. * @returns the current updated Vector2
  16561. */
  16562. scaleInPlace(scale: number): Vector2;
  16563. /**
  16564. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16565. * @param scale defines the scaling factor
  16566. * @returns a new Vector2
  16567. */
  16568. scale(scale: number): Vector2;
  16569. /**
  16570. * Scale the current Vector2 values by a factor to a given Vector2
  16571. * @param scale defines the scale factor
  16572. * @param result defines the Vector2 object where to store the result
  16573. * @returns the unmodified current Vector2
  16574. */
  16575. scaleToRef(scale: number, result: Vector2): Vector2;
  16576. /**
  16577. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16578. * @param scale defines the scale factor
  16579. * @param result defines the Vector2 object where to store the result
  16580. * @returns the unmodified current Vector2
  16581. */
  16582. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16583. /**
  16584. * Gets a boolean if two vectors are equals
  16585. * @param otherVector defines the other vector
  16586. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16587. */
  16588. equals(otherVector: Vector2): boolean;
  16589. /**
  16590. * Gets a boolean if two vectors are equals (using an epsilon value)
  16591. * @param otherVector defines the other vector
  16592. * @param epsilon defines the minimal distance to consider equality
  16593. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16594. */
  16595. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16596. /**
  16597. * Gets a new Vector2 from current Vector2 floored values
  16598. * @returns a new Vector2
  16599. */
  16600. floor(): Vector2;
  16601. /**
  16602. * Gets a new Vector2 from current Vector2 floored values
  16603. * @returns a new Vector2
  16604. */
  16605. fract(): Vector2;
  16606. /**
  16607. * Gets the length of the vector
  16608. * @returns the vector length (float)
  16609. */
  16610. length(): number;
  16611. /**
  16612. * Gets the vector squared length
  16613. * @returns the vector squared length (float)
  16614. */
  16615. lengthSquared(): number;
  16616. /**
  16617. * Normalize the vector
  16618. * @returns the current updated Vector2
  16619. */
  16620. normalize(): Vector2;
  16621. /**
  16622. * Gets a new Vector2 copied from the Vector2
  16623. * @returns a new Vector2
  16624. */
  16625. clone(): Vector2;
  16626. /**
  16627. * Gets a new Vector2(0, 0)
  16628. * @returns a new Vector2
  16629. */
  16630. static Zero(): Vector2;
  16631. /**
  16632. * Gets a new Vector2(1, 1)
  16633. * @returns a new Vector2
  16634. */
  16635. static One(): Vector2;
  16636. /**
  16637. * Gets a new Vector2 set from the given index element of the given array
  16638. * @param array defines the data source
  16639. * @param offset defines the offset in the data source
  16640. * @returns a new Vector2
  16641. */
  16642. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16643. /**
  16644. * Sets "result" from the given index element of the given array
  16645. * @param array defines the data source
  16646. * @param offset defines the offset in the data source
  16647. * @param result defines the target vector
  16648. */
  16649. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16650. /**
  16651. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16652. * @param value1 defines 1st point of control
  16653. * @param value2 defines 2nd point of control
  16654. * @param value3 defines 3rd point of control
  16655. * @param value4 defines 4th point of control
  16656. * @param amount defines the interpolation factor
  16657. * @returns a new Vector2
  16658. */
  16659. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16660. /**
  16661. * 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".
  16662. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16663. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16664. * @param value defines the value to clamp
  16665. * @param min defines the lower limit
  16666. * @param max defines the upper limit
  16667. * @returns a new Vector2
  16668. */
  16669. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16670. /**
  16671. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16672. * @param value1 defines the 1st control point
  16673. * @param tangent1 defines the outgoing tangent
  16674. * @param value2 defines the 2nd control point
  16675. * @param tangent2 defines the incoming tangent
  16676. * @param amount defines the interpolation factor
  16677. * @returns a new Vector2
  16678. */
  16679. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16680. /**
  16681. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16682. * @param start defines the start vector
  16683. * @param end defines the end vector
  16684. * @param amount defines the interpolation factor
  16685. * @returns a new Vector2
  16686. */
  16687. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16688. /**
  16689. * Gets the dot product of the vector "left" and the vector "right"
  16690. * @param left defines first vector
  16691. * @param right defines second vector
  16692. * @returns the dot product (float)
  16693. */
  16694. static Dot(left: Vector2, right: Vector2): number;
  16695. /**
  16696. * Returns a new Vector2 equal to the normalized given vector
  16697. * @param vector defines the vector to normalize
  16698. * @returns a new Vector2
  16699. */
  16700. static Normalize(vector: Vector2): Vector2;
  16701. /**
  16702. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16703. * @param left defines 1st vector
  16704. * @param right defines 2nd vector
  16705. * @returns a new Vector2
  16706. */
  16707. static Minimize(left: Vector2, right: Vector2): Vector2;
  16708. /**
  16709. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16710. * @param left defines 1st vector
  16711. * @param right defines 2nd vector
  16712. * @returns a new Vector2
  16713. */
  16714. static Maximize(left: Vector2, right: Vector2): Vector2;
  16715. /**
  16716. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16717. * @param vector defines the vector to transform
  16718. * @param transformation defines the matrix to apply
  16719. * @returns a new Vector2
  16720. */
  16721. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16722. /**
  16723. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16724. * @param vector defines the vector to transform
  16725. * @param transformation defines the matrix to apply
  16726. * @param result defines the target vector
  16727. */
  16728. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16729. /**
  16730. * Determines if a given vector is included in a triangle
  16731. * @param p defines the vector to test
  16732. * @param p0 defines 1st triangle point
  16733. * @param p1 defines 2nd triangle point
  16734. * @param p2 defines 3rd triangle point
  16735. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16736. */
  16737. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16738. /**
  16739. * Gets the distance between the vectors "value1" and "value2"
  16740. * @param value1 defines first vector
  16741. * @param value2 defines second vector
  16742. * @returns the distance between vectors
  16743. */
  16744. static Distance(value1: Vector2, value2: Vector2): number;
  16745. /**
  16746. * Returns the squared distance between the vectors "value1" and "value2"
  16747. * @param value1 defines first vector
  16748. * @param value2 defines second vector
  16749. * @returns the squared distance between vectors
  16750. */
  16751. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16752. /**
  16753. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16754. * @param value1 defines first vector
  16755. * @param value2 defines second vector
  16756. * @returns a new Vector2
  16757. */
  16758. static Center(value1: Vector2, value2: Vector2): Vector2;
  16759. /**
  16760. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16761. * @param p defines the middle point
  16762. * @param segA defines one point of the segment
  16763. * @param segB defines the other point of the segment
  16764. * @returns the shortest distance
  16765. */
  16766. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16767. }
  16768. /**
  16769. * Classed used to store (x,y,z) vector representation
  16770. * A Vector3 is the main object used in 3D geometry
  16771. * It can represent etiher the coordinates of a point the space, either a direction
  16772. * Reminder: Babylon.js uses a left handed forward facing system
  16773. */
  16774. class Vector3 {
  16775. /**
  16776. * Defines the first coordinates (on X axis)
  16777. */
  16778. x: number;
  16779. /**
  16780. * Defines the second coordinates (on Y axis)
  16781. */
  16782. y: number;
  16783. /**
  16784. * Defines the third coordinates (on Z axis)
  16785. */
  16786. z: number;
  16787. /**
  16788. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16789. * @param x defines the first coordinates (on X axis)
  16790. * @param y defines the second coordinates (on Y axis)
  16791. * @param z defines the third coordinates (on Z axis)
  16792. */
  16793. constructor(
  16794. /**
  16795. * Defines the first coordinates (on X axis)
  16796. */
  16797. x?: number,
  16798. /**
  16799. * Defines the second coordinates (on Y axis)
  16800. */
  16801. y?: number,
  16802. /**
  16803. * Defines the third coordinates (on Z axis)
  16804. */
  16805. z?: number);
  16806. /**
  16807. * Creates a string representation of the Vector3
  16808. * @returns a string with the Vector3 coordinates.
  16809. */
  16810. toString(): string;
  16811. /**
  16812. * Gets the class name
  16813. * @returns the string "Vector3"
  16814. */
  16815. getClassName(): string;
  16816. /**
  16817. * Creates the Vector3 hash code
  16818. * @returns a number which tends to be unique between Vector3 instances
  16819. */
  16820. getHashCode(): number;
  16821. /**
  16822. * Creates an array containing three elements : the coordinates of the Vector3
  16823. * @returns a new array of numbers
  16824. */
  16825. asArray(): number[];
  16826. /**
  16827. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16828. * @param array defines the destination array
  16829. * @param index defines the offset in the destination array
  16830. * @returns the current Vector3
  16831. */
  16832. toArray(array: FloatArray, index?: number): Vector3;
  16833. /**
  16834. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16835. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16836. */
  16837. toQuaternion(): Quaternion;
  16838. /**
  16839. * Adds the given vector to the current Vector3
  16840. * @param otherVector defines the second operand
  16841. * @returns the current updated Vector3
  16842. */
  16843. addInPlace(otherVector: Vector3): Vector3;
  16844. /**
  16845. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16846. * @param otherVector defines the second operand
  16847. * @returns the resulting Vector3
  16848. */
  16849. add(otherVector: Vector3): Vector3;
  16850. /**
  16851. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16852. * @param otherVector defines the second operand
  16853. * @param result defines the Vector3 object where to store the result
  16854. * @returns the current Vector3
  16855. */
  16856. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16857. /**
  16858. * Subtract the given vector from the current Vector3
  16859. * @param otherVector defines the second operand
  16860. * @returns the current updated Vector3
  16861. */
  16862. subtractInPlace(otherVector: Vector3): Vector3;
  16863. /**
  16864. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16865. * @param otherVector defines the second operand
  16866. * @returns the resulting Vector3
  16867. */
  16868. subtract(otherVector: Vector3): Vector3;
  16869. /**
  16870. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16871. * @param otherVector defines the second operand
  16872. * @param result defines the Vector3 object where to store the result
  16873. * @returns the current Vector3
  16874. */
  16875. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16876. /**
  16877. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16878. * @param x defines the x coordinate of the operand
  16879. * @param y defines the y coordinate of the operand
  16880. * @param z defines the z coordinate of the operand
  16881. * @returns the resulting Vector3
  16882. */
  16883. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16884. /**
  16885. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16886. * @param x defines the x coordinate of the operand
  16887. * @param y defines the y coordinate of the operand
  16888. * @param z defines the z coordinate of the operand
  16889. * @param result defines the Vector3 object where to store the result
  16890. * @returns the current Vector3
  16891. */
  16892. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16893. /**
  16894. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16895. * @returns a new Vector3
  16896. */
  16897. negate(): Vector3;
  16898. /**
  16899. * Multiplies the Vector3 coordinates by the float "scale"
  16900. * @param scale defines the multiplier factor
  16901. * @returns the current updated Vector3
  16902. */
  16903. scaleInPlace(scale: number): Vector3;
  16904. /**
  16905. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16906. * @param scale defines the multiplier factor
  16907. * @returns a new Vector3
  16908. */
  16909. scale(scale: number): Vector3;
  16910. /**
  16911. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16912. * @param scale defines the multiplier factor
  16913. * @param result defines the Vector3 object where to store the result
  16914. * @returns the current Vector3
  16915. */
  16916. scaleToRef(scale: number, result: Vector3): Vector3;
  16917. /**
  16918. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16919. * @param scale defines the scale factor
  16920. * @param result defines the Vector3 object where to store the result
  16921. * @returns the unmodified current Vector3
  16922. */
  16923. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16924. /**
  16925. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16926. * @param otherVector defines the second operand
  16927. * @returns true if both vectors are equals
  16928. */
  16929. equals(otherVector: Vector3): boolean;
  16930. /**
  16931. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16932. * @param otherVector defines the second operand
  16933. * @param epsilon defines the minimal distance to define values as equals
  16934. * @returns true if both vectors are distant less than epsilon
  16935. */
  16936. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16937. /**
  16938. * Returns true if the current Vector3 coordinates equals the given floats
  16939. * @param x defines the x coordinate of the operand
  16940. * @param y defines the y coordinate of the operand
  16941. * @param z defines the z coordinate of the operand
  16942. * @returns true if both vectors are equals
  16943. */
  16944. equalsToFloats(x: number, y: number, z: number): boolean;
  16945. /**
  16946. * Multiplies the current Vector3 coordinates by the given ones
  16947. * @param otherVector defines the second operand
  16948. * @returns the current updated Vector3
  16949. */
  16950. multiplyInPlace(otherVector: Vector3): Vector3;
  16951. /**
  16952. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16953. * @param otherVector defines the second operand
  16954. * @returns the new Vector3
  16955. */
  16956. multiply(otherVector: Vector3): Vector3;
  16957. /**
  16958. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16959. * @param otherVector defines the second operand
  16960. * @param result defines the Vector3 object where to store the result
  16961. * @returns the current Vector3
  16962. */
  16963. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16964. /**
  16965. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16966. * @param x defines the x coordinate of the operand
  16967. * @param y defines the y coordinate of the operand
  16968. * @param z defines the z coordinate of the operand
  16969. * @returns the new Vector3
  16970. */
  16971. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16972. /**
  16973. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16974. * @param otherVector defines the second operand
  16975. * @returns the new Vector3
  16976. */
  16977. divide(otherVector: Vector3): Vector3;
  16978. /**
  16979. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16980. * @param otherVector defines the second operand
  16981. * @param result defines the Vector3 object where to store the result
  16982. * @returns the current Vector3
  16983. */
  16984. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16985. /**
  16986. * Divides the current Vector3 coordinates by the given ones.
  16987. * @param otherVector defines the second operand
  16988. * @returns the current updated Vector3
  16989. */
  16990. divideInPlace(otherVector: Vector3): Vector3;
  16991. /**
  16992. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16993. * @param other defines the second operand
  16994. * @returns the current updated Vector3
  16995. */
  16996. minimizeInPlace(other: Vector3): Vector3;
  16997. /**
  16998. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16999. * @param other defines the second operand
  17000. * @returns the current updated Vector3
  17001. */
  17002. maximizeInPlace(other: Vector3): Vector3;
  17003. /**
  17004. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  17005. */
  17006. readonly isNonUniform: boolean;
  17007. /**
  17008. * Gets a new Vector3 from current Vector3 floored values
  17009. * @returns a new Vector3
  17010. */
  17011. floor(): Vector3;
  17012. /**
  17013. * Gets a new Vector3 from current Vector3 floored values
  17014. * @returns a new Vector3
  17015. */
  17016. fract(): Vector3;
  17017. /**
  17018. * Gets the length of the Vector3
  17019. * @returns the length of the Vecto3
  17020. */
  17021. length(): number;
  17022. /**
  17023. * Gets the squared length of the Vector3
  17024. * @returns squared length of the Vector3
  17025. */
  17026. lengthSquared(): number;
  17027. /**
  17028. * Normalize the current Vector3.
  17029. * Please note that this is an in place operation.
  17030. * @returns the current updated Vector3
  17031. */
  17032. normalize(): Vector3;
  17033. /**
  17034. * Normalize the current Vector3 to a new vector
  17035. * @returns the new Vector3
  17036. */
  17037. normalizeToNew(): Vector3;
  17038. /**
  17039. * Normalize the current Vector3 to the reference
  17040. * @param reference define the Vector3 to update
  17041. * @returns the updated Vector3
  17042. */
  17043. normalizeToRef(reference: Vector3): Vector3;
  17044. /**
  17045. * Creates a new Vector3 copied from the current Vector3
  17046. * @returns the new Vector3
  17047. */
  17048. clone(): Vector3;
  17049. /**
  17050. * Copies the given vector coordinates to the current Vector3 ones
  17051. * @param source defines the source Vector3
  17052. * @returns the current updated Vector3
  17053. */
  17054. copyFrom(source: Vector3): Vector3;
  17055. /**
  17056. * Copies the given floats to the current Vector3 coordinates
  17057. * @param x defines the x coordinate of the operand
  17058. * @param y defines the y coordinate of the operand
  17059. * @param z defines the z coordinate of the operand
  17060. * @returns the current updated Vector3
  17061. */
  17062. copyFromFloats(x: number, y: number, z: number): Vector3;
  17063. /**
  17064. * Copies the given floats to the current Vector3 coordinates
  17065. * @param x defines the x coordinate of the operand
  17066. * @param y defines the y coordinate of the operand
  17067. * @param z defines the z coordinate of the operand
  17068. * @returns the current updated Vector3
  17069. */
  17070. set(x: number, y: number, z: number): Vector3;
  17071. /**
  17072. * Get the clip factor between two vectors
  17073. * @param vector0 defines the first operand
  17074. * @param vector1 defines the second operand
  17075. * @param axis defines the axis to use
  17076. * @param size defines the size along the axis
  17077. * @returns the clip factor
  17078. */
  17079. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  17080. /**
  17081. * Get angle between two vectors
  17082. * @param vector0 angle between vector0 and vector1
  17083. * @param vector1 angle between vector0 and vector1
  17084. * @param normal direction of the normal
  17085. * @return the angle between vector0 and vector1
  17086. */
  17087. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  17088. /**
  17089. * Returns a new Vector3 set from the index "offset" of the given array
  17090. * @param array defines the source array
  17091. * @param offset defines the offset in the source array
  17092. * @returns the new Vector3
  17093. */
  17094. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  17095. /**
  17096. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  17097. * This function is deprecated. Use FromArray instead
  17098. * @param array defines the source array
  17099. * @param offset defines the offset in the source array
  17100. * @returns the new Vector3
  17101. */
  17102. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  17103. /**
  17104. * Sets the given vector "result" with the element values from the index "offset" of the given array
  17105. * @param array defines the source array
  17106. * @param offset defines the offset in the source array
  17107. * @param result defines the Vector3 where to store the result
  17108. */
  17109. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  17110. /**
  17111. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  17112. * This function is deprecated. Use FromArrayToRef instead.
  17113. * @param array defines the source array
  17114. * @param offset defines the offset in the source array
  17115. * @param result defines the Vector3 where to store the result
  17116. */
  17117. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  17118. /**
  17119. * Sets the given vector "result" with the given floats.
  17120. * @param x defines the x coordinate of the source
  17121. * @param y defines the y coordinate of the source
  17122. * @param z defines the z coordinate of the source
  17123. * @param result defines the Vector3 where to store the result
  17124. */
  17125. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  17126. /**
  17127. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  17128. * @returns a new empty Vector3
  17129. */
  17130. static Zero(): Vector3;
  17131. /**
  17132. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  17133. * @returns a new unit Vector3
  17134. */
  17135. static One(): Vector3;
  17136. /**
  17137. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  17138. * @returns a new up Vector3
  17139. */
  17140. static Up(): Vector3;
  17141. /**
  17142. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  17143. * @returns a new down Vector3
  17144. */
  17145. static Down(): Vector3;
  17146. /**
  17147. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  17148. * @returns a new forward Vector3
  17149. */
  17150. static Forward(): Vector3;
  17151. /**
  17152. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  17153. * @returns a new right Vector3
  17154. */
  17155. static Right(): Vector3;
  17156. /**
  17157. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  17158. * @returns a new left Vector3
  17159. */
  17160. static Left(): Vector3;
  17161. /**
  17162. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  17163. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17164. * @param vector defines the Vector3 to transform
  17165. * @param transformation defines the transformation matrix
  17166. * @returns the transformed Vector3
  17167. */
  17168. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  17169. /**
  17170. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  17171. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17172. * @param vector defines the Vector3 to transform
  17173. * @param transformation defines the transformation matrix
  17174. * @param result defines the Vector3 where to store the result
  17175. */
  17176. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17177. /**
  17178. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  17179. * This method computes tranformed coordinates only, not transformed direction vectors
  17180. * @param x define the x coordinate of the source vector
  17181. * @param y define the y coordinate of the source vector
  17182. * @param z define the z coordinate of the source vector
  17183. * @param transformation defines the transformation matrix
  17184. * @param result defines the Vector3 where to store the result
  17185. */
  17186. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17187. /**
  17188. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  17189. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17190. * @param vector defines the Vector3 to transform
  17191. * @param transformation defines the transformation matrix
  17192. * @returns the new Vector3
  17193. */
  17194. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  17195. /**
  17196. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  17197. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17198. * @param vector defines the Vector3 to transform
  17199. * @param transformation defines the transformation matrix
  17200. * @param result defines the Vector3 where to store the result
  17201. */
  17202. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17203. /**
  17204. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  17205. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17206. * @param x define the x coordinate of the source vector
  17207. * @param y define the y coordinate of the source vector
  17208. * @param z define the z coordinate of the source vector
  17209. * @param transformation defines the transformation matrix
  17210. * @param result defines the Vector3 where to store the result
  17211. */
  17212. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17213. /**
  17214. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  17215. * @param value1 defines the first control point
  17216. * @param value2 defines the second control point
  17217. * @param value3 defines the third control point
  17218. * @param value4 defines the fourth control point
  17219. * @param amount defines the amount on the spline to use
  17220. * @returns the new Vector3
  17221. */
  17222. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  17223. /**
  17224. * 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"
  17225. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17226. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17227. * @param value defines the current value
  17228. * @param min defines the lower range value
  17229. * @param max defines the upper range value
  17230. * @returns the new Vector3
  17231. */
  17232. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17233. /**
  17234. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17235. * @param value1 defines the first control point
  17236. * @param tangent1 defines the first tangent vector
  17237. * @param value2 defines the second control point
  17238. * @param tangent2 defines the second tangent vector
  17239. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17240. * @returns the new Vector3
  17241. */
  17242. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17243. /**
  17244. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17245. * @param start defines the start value
  17246. * @param end defines the end value
  17247. * @param amount max defines amount between both (between 0 and 1)
  17248. * @returns the new Vector3
  17249. */
  17250. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17251. /**
  17252. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17253. * @param start defines the start value
  17254. * @param end defines the end value
  17255. * @param amount max defines amount between both (between 0 and 1)
  17256. * @param result defines the Vector3 where to store the result
  17257. */
  17258. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17259. /**
  17260. * Returns the dot product (float) between the vectors "left" and "right"
  17261. * @param left defines the left operand
  17262. * @param right defines the right operand
  17263. * @returns the dot product
  17264. */
  17265. static Dot(left: Vector3, right: Vector3): number;
  17266. /**
  17267. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17268. * The cross product is then orthogonal to both "left" and "right"
  17269. * @param left defines the left operand
  17270. * @param right defines the right operand
  17271. * @returns the cross product
  17272. */
  17273. static Cross(left: Vector3, right: Vector3): Vector3;
  17274. /**
  17275. * Sets the given vector "result" with the cross product of "left" and "right"
  17276. * The cross product is then orthogonal to both "left" and "right"
  17277. * @param left defines the left operand
  17278. * @param right defines the right operand
  17279. * @param result defines the Vector3 where to store the result
  17280. */
  17281. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17282. /**
  17283. * Returns a new Vector3 as the normalization of the given vector
  17284. * @param vector defines the Vector3 to normalize
  17285. * @returns the new Vector3
  17286. */
  17287. static Normalize(vector: Vector3): Vector3;
  17288. /**
  17289. * Sets the given vector "result" with the normalization of the given first vector
  17290. * @param vector defines the Vector3 to normalize
  17291. * @param result defines the Vector3 where to store the result
  17292. */
  17293. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17294. private static _viewportMatrixCache;
  17295. /**
  17296. * Project a Vector3 onto screen space
  17297. * @param vector defines the Vector3 to project
  17298. * @param world defines the world matrix to use
  17299. * @param transform defines the transform (view x projection) matrix to use
  17300. * @param viewport defines the screen viewport to use
  17301. * @returns the new Vector3
  17302. */
  17303. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17304. /**
  17305. * Unproject from screen space to object space
  17306. * @param source defines the screen space Vector3 to use
  17307. * @param viewportWidth defines the current width of the viewport
  17308. * @param viewportHeight defines the current height of the viewport
  17309. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17310. * @param transform defines the transform (view x projection) matrix to use
  17311. * @returns the new Vector3
  17312. */
  17313. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17314. /**
  17315. * Unproject from screen space to object space
  17316. * @param source defines the screen space Vector3 to use
  17317. * @param viewportWidth defines the current width of the viewport
  17318. * @param viewportHeight defines the current height of the viewport
  17319. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17320. * @param view defines the view matrix to use
  17321. * @param projection defines the projection matrix to use
  17322. * @returns the new Vector3
  17323. */
  17324. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17325. /**
  17326. * Unproject from screen space to object space
  17327. * @param source defines the screen space Vector3 to use
  17328. * @param viewportWidth defines the current width of the viewport
  17329. * @param viewportHeight defines the current height of the viewport
  17330. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17331. * @param view defines the view matrix to use
  17332. * @param projection defines the projection matrix to use
  17333. * @param result defines the Vector3 where to store the result
  17334. */
  17335. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17336. /**
  17337. * Unproject from screen space to object space
  17338. * @param sourceX defines the screen space x coordinate to use
  17339. * @param sourceY defines the screen space y coordinate to use
  17340. * @param sourceZ defines the screen space z coordinate to use
  17341. * @param viewportWidth defines the current width of the viewport
  17342. * @param viewportHeight defines the current height of the viewport
  17343. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17344. * @param view defines the view matrix to use
  17345. * @param projection defines the projection matrix to use
  17346. * @param result defines the Vector3 where to store the result
  17347. */
  17348. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17349. /**
  17350. * Gets the minimal coordinate values between two Vector3
  17351. * @param left defines the first operand
  17352. * @param right defines the second operand
  17353. * @returns the new Vector3
  17354. */
  17355. static Minimize(left: Vector3, right: Vector3): Vector3;
  17356. /**
  17357. * Gets the maximal coordinate values between two Vector3
  17358. * @param left defines the first operand
  17359. * @param right defines the second operand
  17360. * @returns the new Vector3
  17361. */
  17362. static Maximize(left: Vector3, right: Vector3): Vector3;
  17363. /**
  17364. * Returns the distance between the vectors "value1" and "value2"
  17365. * @param value1 defines the first operand
  17366. * @param value2 defines the second operand
  17367. * @returns the distance
  17368. */
  17369. static Distance(value1: Vector3, value2: Vector3): number;
  17370. /**
  17371. * Returns the squared distance between the vectors "value1" and "value2"
  17372. * @param value1 defines the first operand
  17373. * @param value2 defines the second operand
  17374. * @returns the squared distance
  17375. */
  17376. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17377. /**
  17378. * Returns a new Vector3 located at the center between "value1" and "value2"
  17379. * @param value1 defines the first operand
  17380. * @param value2 defines the second operand
  17381. * @returns the new Vector3
  17382. */
  17383. static Center(value1: Vector3, value2: Vector3): Vector3;
  17384. /**
  17385. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17386. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17387. * to something in order to rotate it from its local system to the given target system
  17388. * Note: axis1, axis2 and axis3 are normalized during this operation
  17389. * @param axis1 defines the first axis
  17390. * @param axis2 defines the second axis
  17391. * @param axis3 defines the third axis
  17392. * @returns a new Vector3
  17393. */
  17394. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17395. /**
  17396. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17397. * @param axis1 defines the first axis
  17398. * @param axis2 defines the second axis
  17399. * @param axis3 defines the third axis
  17400. * @param ref defines the Vector3 where to store the result
  17401. */
  17402. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17403. }
  17404. class Vector4 {
  17405. x: number;
  17406. y: number;
  17407. z: number;
  17408. w: number;
  17409. /**
  17410. * Creates a Vector4 object from the given floats.
  17411. */
  17412. constructor(x: number, y: number, z: number, w: number);
  17413. /**
  17414. * Returns the string with the Vector4 coordinates.
  17415. */
  17416. toString(): string;
  17417. /**
  17418. * Returns the string "Vector4".
  17419. */
  17420. getClassName(): string;
  17421. /**
  17422. * Returns the Vector4 hash code.
  17423. */
  17424. getHashCode(): number;
  17425. /**
  17426. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17427. */
  17428. asArray(): number[];
  17429. /**
  17430. * Populates the given array from the given index with the Vector4 coordinates.
  17431. * Returns the Vector4.
  17432. */
  17433. toArray(array: FloatArray, index?: number): Vector4;
  17434. /**
  17435. * Adds the given vector to the current Vector4.
  17436. * Returns the updated Vector4.
  17437. */
  17438. addInPlace(otherVector: Vector4): Vector4;
  17439. /**
  17440. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17441. */
  17442. add(otherVector: Vector4): Vector4;
  17443. /**
  17444. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17445. * Returns the current Vector4.
  17446. */
  17447. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17448. /**
  17449. * Subtract in place the given vector from the current Vector4.
  17450. * Returns the updated Vector4.
  17451. */
  17452. subtractInPlace(otherVector: Vector4): Vector4;
  17453. /**
  17454. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17455. */
  17456. subtract(otherVector: Vector4): Vector4;
  17457. /**
  17458. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17459. * Returns the current Vector4.
  17460. */
  17461. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17462. /**
  17463. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17464. */
  17465. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17466. /**
  17467. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17468. * Returns the current Vector4.
  17469. */
  17470. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17471. /**
  17472. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17473. */
  17474. negate(): Vector4;
  17475. /**
  17476. * Multiplies the current Vector4 coordinates by scale (float).
  17477. * Returns the updated Vector4.
  17478. */
  17479. scaleInPlace(scale: number): Vector4;
  17480. /**
  17481. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17482. */
  17483. scale(scale: number): Vector4;
  17484. /**
  17485. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17486. * Returns the current Vector4.
  17487. */
  17488. scaleToRef(scale: number, result: Vector4): Vector4;
  17489. /**
  17490. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17491. * @param scale defines the scale factor
  17492. * @param result defines the Vector4 object where to store the result
  17493. * @returns the unmodified current Vector4
  17494. */
  17495. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17496. /**
  17497. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17498. */
  17499. equals(otherVector: Vector4): boolean;
  17500. /**
  17501. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17502. */
  17503. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17504. /**
  17505. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17506. */
  17507. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17508. /**
  17509. * Multiplies in place the current Vector4 by the given one.
  17510. * Returns the updated Vector4.
  17511. */
  17512. multiplyInPlace(otherVector: Vector4): Vector4;
  17513. /**
  17514. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17515. */
  17516. multiply(otherVector: Vector4): Vector4;
  17517. /**
  17518. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17519. * Returns the current Vector4.
  17520. */
  17521. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17522. /**
  17523. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17524. */
  17525. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17526. /**
  17527. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17528. */
  17529. divide(otherVector: Vector4): Vector4;
  17530. /**
  17531. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17532. * Returns the current Vector4.
  17533. */
  17534. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17535. /**
  17536. * Divides the current Vector3 coordinates by the given ones.
  17537. * @returns the updated Vector3.
  17538. */
  17539. divideInPlace(otherVector: Vector4): Vector4;
  17540. /**
  17541. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17542. * @param other defines the second operand
  17543. * @returns the current updated Vector4
  17544. */
  17545. minimizeInPlace(other: Vector4): Vector4;
  17546. /**
  17547. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17548. * @param other defines the second operand
  17549. * @returns the current updated Vector4
  17550. */
  17551. maximizeInPlace(other: Vector4): Vector4;
  17552. /**
  17553. * Gets a new Vector4 from current Vector4 floored values
  17554. * @returns a new Vector4
  17555. */
  17556. floor(): Vector4;
  17557. /**
  17558. * Gets a new Vector4 from current Vector3 floored values
  17559. * @returns a new Vector4
  17560. */
  17561. fract(): Vector4;
  17562. /**
  17563. * Returns the Vector4 length (float).
  17564. */
  17565. length(): number;
  17566. /**
  17567. * Returns the Vector4 squared length (float).
  17568. */
  17569. lengthSquared(): number;
  17570. /**
  17571. * Normalizes in place the Vector4.
  17572. * Returns the updated Vector4.
  17573. */
  17574. normalize(): Vector4;
  17575. /**
  17576. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17577. */
  17578. toVector3(): Vector3;
  17579. /**
  17580. * Returns a new Vector4 copied from the current one.
  17581. */
  17582. clone(): Vector4;
  17583. /**
  17584. * Updates the current Vector4 with the given one coordinates.
  17585. * Returns the updated Vector4.
  17586. */
  17587. copyFrom(source: Vector4): Vector4;
  17588. /**
  17589. * Updates the current Vector4 coordinates with the given floats.
  17590. * Returns the updated Vector4.
  17591. */
  17592. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17593. /**
  17594. * Updates the current Vector4 coordinates with the given floats.
  17595. * Returns the updated Vector4.
  17596. */
  17597. set(x: number, y: number, z: number, w: number): Vector4;
  17598. /**
  17599. * Returns a new Vector4 set from the starting index of the given array.
  17600. */
  17601. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17602. /**
  17603. * Updates the given vector "result" from the starting index of the given array.
  17604. */
  17605. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17606. /**
  17607. * Updates the given vector "result" from the starting index of the given Float32Array.
  17608. */
  17609. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17610. /**
  17611. * Updates the given vector "result" coordinates from the given floats.
  17612. */
  17613. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17614. /**
  17615. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17616. */
  17617. static Zero(): Vector4;
  17618. /**
  17619. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17620. */
  17621. static One(): Vector4;
  17622. /**
  17623. * Returns a new normalized Vector4 from the given one.
  17624. */
  17625. static Normalize(vector: Vector4): Vector4;
  17626. /**
  17627. * Updates the given vector "result" from the normalization of the given one.
  17628. */
  17629. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17630. static Minimize(left: Vector4, right: Vector4): Vector4;
  17631. static Maximize(left: Vector4, right: Vector4): Vector4;
  17632. /**
  17633. * Returns the distance (float) between the vectors "value1" and "value2".
  17634. */
  17635. static Distance(value1: Vector4, value2: Vector4): number;
  17636. /**
  17637. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17638. */
  17639. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17640. /**
  17641. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17642. */
  17643. static Center(value1: Vector4, value2: Vector4): Vector4;
  17644. /**
  17645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17646. * This methods computes transformed normalized direction vectors only.
  17647. */
  17648. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17649. /**
  17650. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17651. * This methods computes transformed normalized direction vectors only.
  17652. */
  17653. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17654. /**
  17655. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17656. * This methods computes transformed normalized direction vectors only.
  17657. */
  17658. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17659. }
  17660. interface ISize {
  17661. width: number;
  17662. height: number;
  17663. }
  17664. class Size implements ISize {
  17665. width: number;
  17666. height: number;
  17667. /**
  17668. * Creates a Size object from the given width and height (floats).
  17669. */
  17670. constructor(width: number, height: number);
  17671. toString(): string;
  17672. /**
  17673. * Returns the string "Size"
  17674. */
  17675. getClassName(): string;
  17676. /**
  17677. * Returns the Size hash code.
  17678. */
  17679. getHashCode(): number;
  17680. /**
  17681. * Updates the current size from the given one.
  17682. * Returns the updated Size.
  17683. */
  17684. copyFrom(src: Size): void;
  17685. /**
  17686. * Updates in place the current Size from the given floats.
  17687. * Returns the updated Size.
  17688. */
  17689. copyFromFloats(width: number, height: number): Size;
  17690. /**
  17691. * Updates in place the current Size from the given floats.
  17692. * Returns the updated Size.
  17693. */
  17694. set(width: number, height: number): Size;
  17695. /**
  17696. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17697. */
  17698. multiplyByFloats(w: number, h: number): Size;
  17699. /**
  17700. * Returns a new Size copied from the given one.
  17701. */
  17702. clone(): Size;
  17703. /**
  17704. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17705. */
  17706. equals(other: Size): boolean;
  17707. /**
  17708. * Returns the surface of the Size : width * height (float).
  17709. */
  17710. readonly surface: number;
  17711. /**
  17712. * Returns a new Size set to (0.0, 0.0)
  17713. */
  17714. static Zero(): Size;
  17715. /**
  17716. * Returns a new Size set as the addition result of the current Size and the given one.
  17717. */
  17718. add(otherSize: Size): Size;
  17719. /**
  17720. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17721. */
  17722. subtract(otherSize: Size): Size;
  17723. /**
  17724. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17725. */
  17726. static Lerp(start: Size, end: Size, amount: number): Size;
  17727. }
  17728. /**
  17729. * Class used to store quaternion data
  17730. * @see https://en.wikipedia.org/wiki/Quaternion
  17731. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17732. */
  17733. class Quaternion {
  17734. /** defines the first component (0 by default) */
  17735. x: number;
  17736. /** defines the second component (0 by default) */
  17737. y: number;
  17738. /** defines the third component (0 by default) */
  17739. z: number;
  17740. /** defines the fourth component (1.0 by default) */
  17741. w: number;
  17742. /**
  17743. * Creates a new Quaternion from the given floats
  17744. * @param x defines the first component (0 by default)
  17745. * @param y defines the second component (0 by default)
  17746. * @param z defines the third component (0 by default)
  17747. * @param w defines the fourth component (1.0 by default)
  17748. */
  17749. constructor(
  17750. /** defines the first component (0 by default) */
  17751. x?: number,
  17752. /** defines the second component (0 by default) */
  17753. y?: number,
  17754. /** defines the third component (0 by default) */
  17755. z?: number,
  17756. /** defines the fourth component (1.0 by default) */
  17757. w?: number);
  17758. /**
  17759. * Gets a string representation for the current quaternion
  17760. * @returns a string with the Quaternion coordinates
  17761. */
  17762. toString(): string;
  17763. /**
  17764. * Gets the class name of the quaternion
  17765. * @returns the string "Quaternion"
  17766. */
  17767. getClassName(): string;
  17768. /**
  17769. * Gets a hash code for this quaternion
  17770. * @returns the quaternion hash code
  17771. */
  17772. getHashCode(): number;
  17773. /**
  17774. * Copy the quaternion to an array
  17775. * @returns a new array populated with 4 elements from the quaternion coordinates
  17776. */
  17777. asArray(): number[];
  17778. /**
  17779. * Check if two quaternions are equals
  17780. * @param otherQuaternion defines the second operand
  17781. * @return true if the current quaternion and the given one coordinates are strictly equals
  17782. */
  17783. equals(otherQuaternion: Quaternion): boolean;
  17784. /**
  17785. * Clone the current quaternion
  17786. * @returns a new quaternion copied from the current one
  17787. */
  17788. clone(): Quaternion;
  17789. /**
  17790. * Copy a quaternion to the current one
  17791. * @param other defines the other quaternion
  17792. * @returns the updated current quaternion
  17793. */
  17794. copyFrom(other: Quaternion): Quaternion;
  17795. /**
  17796. * Updates the current quaternion with the given float coordinates
  17797. * @param x defines the x coordinate
  17798. * @param y defines the y coordinate
  17799. * @param z defines the z coordinate
  17800. * @param w defines the w coordinate
  17801. * @returns the updated current quaternion
  17802. */
  17803. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17804. /**
  17805. * Updates the current quaternion from the given float coordinates
  17806. * @param x defines the x coordinate
  17807. * @param y defines the y coordinate
  17808. * @param z defines the z coordinate
  17809. * @param w defines the w coordinate
  17810. * @returns the updated current quaternion
  17811. */
  17812. set(x: number, y: number, z: number, w: number): Quaternion;
  17813. /**
  17814. * Adds two quaternions
  17815. * @param other defines the second operand
  17816. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17817. */
  17818. add(other: Quaternion): Quaternion;
  17819. /**
  17820. * Add a quaternion to the current one
  17821. * @param other defines the quaternion to add
  17822. * @returns the current quaternion
  17823. */
  17824. addInPlace(other: Quaternion): Quaternion;
  17825. /**
  17826. * Subtract two quaternions
  17827. * @param other defines the second operand
  17828. * @returns a new quaternion as the subtraction result of the given one from the current one
  17829. */
  17830. subtract(other: Quaternion): Quaternion;
  17831. /**
  17832. * Multiplies the current quaternion by a scale factor
  17833. * @param value defines the scale factor
  17834. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17835. */
  17836. scale(value: number): Quaternion;
  17837. /**
  17838. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17839. * @param scale defines the scale factor
  17840. * @param result defines the Quaternion object where to store the result
  17841. * @returns the unmodified current quaternion
  17842. */
  17843. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17844. /**
  17845. * Multiplies in place the current quaternion by a scale factor
  17846. * @param value defines the scale factor
  17847. * @returns the current modified quaternion
  17848. */
  17849. scaleInPlace(value: number): Quaternion;
  17850. /**
  17851. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17852. * @param scale defines the scale factor
  17853. * @param result defines the Quaternion object where to store the result
  17854. * @returns the unmodified current quaternion
  17855. */
  17856. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17857. /**
  17858. * Multiplies two quaternions
  17859. * @param q1 defines the second operand
  17860. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17861. */
  17862. multiply(q1: Quaternion): Quaternion;
  17863. /**
  17864. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17865. * @param q1 defines the second operand
  17866. * @param result defines the target quaternion
  17867. * @returns the current quaternion
  17868. */
  17869. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17870. /**
  17871. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17872. * @param q1 defines the second operand
  17873. * @returns the currentupdated quaternion
  17874. */
  17875. multiplyInPlace(q1: Quaternion): Quaternion;
  17876. /**
  17877. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17878. * @param ref defines the target quaternion
  17879. * @returns the current quaternion
  17880. */
  17881. conjugateToRef(ref: Quaternion): Quaternion;
  17882. /**
  17883. * Conjugates in place (1-q) the current quaternion
  17884. * @returns the current updated quaternion
  17885. */
  17886. conjugateInPlace(): Quaternion;
  17887. /**
  17888. * Conjugates in place (1-q) the current quaternion
  17889. * @returns a new quaternion
  17890. */
  17891. conjugate(): Quaternion;
  17892. /**
  17893. * Gets length of current quaternion
  17894. * @returns the quaternion length (float)
  17895. */
  17896. length(): number;
  17897. /**
  17898. * Normalize in place the current quaternion
  17899. * @returns the current updated quaternion
  17900. */
  17901. normalize(): Quaternion;
  17902. /**
  17903. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17904. * @param order is a reserved parameter and is ignore for now
  17905. * @returns a new Vector3 containing the Euler angles
  17906. */
  17907. toEulerAngles(order?: string): Vector3;
  17908. /**
  17909. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17910. * @param result defines the vector which will be filled with the Euler angles
  17911. * @param order is a reserved parameter and is ignore for now
  17912. * @returns the current unchanged quaternion
  17913. */
  17914. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17915. /**
  17916. * Updates the given rotation matrix with the current quaternion values
  17917. * @param result defines the target matrix
  17918. * @returns the current unchanged quaternion
  17919. */
  17920. toRotationMatrix(result: Matrix): Quaternion;
  17921. /**
  17922. * Updates the current quaternion from the given rotation matrix values
  17923. * @param matrix defines the source matrix
  17924. * @returns the current updated quaternion
  17925. */
  17926. fromRotationMatrix(matrix: Matrix): Quaternion;
  17927. /**
  17928. * Creates a new quaternion from a rotation matrix
  17929. * @param matrix defines the source matrix
  17930. * @returns a new quaternion created from the given rotation matrix values
  17931. */
  17932. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17933. /**
  17934. * Updates the given quaternion with the given rotation matrix values
  17935. * @param matrix defines the source matrix
  17936. * @param result defines the target quaternion
  17937. */
  17938. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17939. /**
  17940. * Returns the dot product (float) between the quaternions "left" and "right"
  17941. * @param left defines the left operand
  17942. * @param right defines the right operand
  17943. * @returns the dot product
  17944. */
  17945. static Dot(left: Quaternion, right: Quaternion): number;
  17946. /**
  17947. * Checks if the two quaternions are close to each other
  17948. * @param quat0 defines the first quaternion to check
  17949. * @param quat1 defines the second quaternion to check
  17950. * @returns true if the two quaternions are close to each other
  17951. */
  17952. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17953. /**
  17954. * Creates an empty quaternion
  17955. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17956. */
  17957. static Zero(): Quaternion;
  17958. /**
  17959. * Inverse a given quaternion
  17960. * @param q defines the source quaternion
  17961. * @returns a new quaternion as the inverted current quaternion
  17962. */
  17963. static Inverse(q: Quaternion): Quaternion;
  17964. /**
  17965. * Creates an identity quaternion
  17966. * @returns the identity quaternion
  17967. */
  17968. static Identity(): Quaternion;
  17969. /**
  17970. * Gets a boolean indicating if the given quaternion is identity
  17971. * @param quaternion defines the quaternion to check
  17972. * @returns true if the quaternion is identity
  17973. */
  17974. static IsIdentity(quaternion: Quaternion): boolean;
  17975. /**
  17976. * Creates a quaternion from a rotation around an axis
  17977. * @param axis defines the axis to use
  17978. * @param angle defines the angle to use
  17979. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17980. */
  17981. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17982. /**
  17983. * Creates a rotation around an axis and stores it into the given quaternion
  17984. * @param axis defines the axis to use
  17985. * @param angle defines the angle to use
  17986. * @param result defines the target quaternion
  17987. * @returns the target quaternion
  17988. */
  17989. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17990. /**
  17991. * Creates a new quaternion from data stored into an array
  17992. * @param array defines the data source
  17993. * @param offset defines the offset in the source array where the data starts
  17994. * @returns a new quaternion
  17995. */
  17996. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17997. /**
  17998. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17999. * @param yaw defines the rotation around Y axis
  18000. * @param pitch defines the rotation around X axis
  18001. * @param roll defines the rotation around Z axis
  18002. * @returns the new quaternion
  18003. */
  18004. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  18005. /**
  18006. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  18007. * @param yaw defines the rotation around Y axis
  18008. * @param pitch defines the rotation around X axis
  18009. * @param roll defines the rotation around Z axis
  18010. * @param result defines the target quaternion
  18011. */
  18012. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  18013. /**
  18014. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  18015. * @param alpha defines the rotation around first axis
  18016. * @param beta defines the rotation around second axis
  18017. * @param gamma defines the rotation around third axis
  18018. * @returns the new quaternion
  18019. */
  18020. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  18021. /**
  18022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  18023. * @param alpha defines the rotation around first axis
  18024. * @param beta defines the rotation around second axis
  18025. * @param gamma defines the rotation around third axis
  18026. * @param result defines the target quaternion
  18027. */
  18028. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  18029. /**
  18030. * 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)
  18031. * @param axis1 defines the first axis
  18032. * @param axis2 defines the second axis
  18033. * @param axis3 defines the third axis
  18034. * @returns the new quaternion
  18035. */
  18036. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  18037. /**
  18038. * 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
  18039. * @param axis1 defines the first axis
  18040. * @param axis2 defines the second axis
  18041. * @param axis3 defines the third axis
  18042. * @param ref defines the target quaternion
  18043. */
  18044. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  18045. /**
  18046. * Interpolates between two quaternions
  18047. * @param left defines first quaternion
  18048. * @param right defines second quaternion
  18049. * @param amount defines the gradient to use
  18050. * @returns the new interpolated quaternion
  18051. */
  18052. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  18053. /**
  18054. * Interpolates between two quaternions and stores it into a target quaternion
  18055. * @param left defines first quaternion
  18056. * @param right defines second quaternion
  18057. * @param amount defines the gradient to use
  18058. * @param result defines the target quaternion
  18059. */
  18060. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  18061. /**
  18062. * Interpolate between two quaternions using Hermite interpolation
  18063. * @param value1 defines first quaternion
  18064. * @param tangent1 defines the incoming tangent
  18065. * @param value2 defines second quaternion
  18066. * @param tangent2 defines the outgoing tangent
  18067. * @param amount defines the target quaternion
  18068. * @returns the new interpolated quaternion
  18069. */
  18070. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  18071. }
  18072. /**
  18073. * Class used to store matrix data (4x4)
  18074. */
  18075. class Matrix {
  18076. private static _tempQuaternion;
  18077. private static _xAxis;
  18078. private static _yAxis;
  18079. private static _zAxis;
  18080. private static _updateFlagSeed;
  18081. private static _identityReadOnly;
  18082. private _isIdentity;
  18083. private _isIdentityDirty;
  18084. /**
  18085. * Gets the update flag of the matrix which is an unique number for the matrix.
  18086. * It will be incremented every time the matrix data change.
  18087. * You can use it to speed the comparison between two versions of the same matrix.
  18088. */
  18089. updateFlag: number;
  18090. /**
  18091. * Gets or sets the internal data of the matrix
  18092. */
  18093. m: Float32Array;
  18094. /** @hidden */
  18095. _markAsUpdated(): void;
  18096. /**
  18097. * Creates an empty matrix (filled with zeros)
  18098. */
  18099. constructor();
  18100. /**
  18101. * Check if the current matrix is indentity
  18102. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  18103. * @returns true is the matrix is the identity matrix
  18104. */
  18105. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  18106. /**
  18107. * Gets the determinant of the matrix
  18108. * @returns the matrix determinant
  18109. */
  18110. determinant(): number;
  18111. /**
  18112. * Returns the matrix as a Float32Array
  18113. * @returns the matrix underlying array
  18114. */
  18115. toArray(): Float32Array;
  18116. /**
  18117. * Returns the matrix as a Float32Array
  18118. * @returns the matrix underlying array.
  18119. */
  18120. asArray(): Float32Array;
  18121. /**
  18122. * Inverts the current matrix in place
  18123. * @returns the current inverted matrix
  18124. */
  18125. invert(): Matrix;
  18126. /**
  18127. * Sets all the matrix elements to zero
  18128. * @returns the current matrix
  18129. */
  18130. reset(): Matrix;
  18131. /**
  18132. * Adds the current matrix with a second one
  18133. * @param other defines the matrix to add
  18134. * @returns a new matrix as the addition of the current matrix and the given one
  18135. */
  18136. add(other: Matrix): Matrix;
  18137. /**
  18138. * Sets the given matrix "result" to the addition of the current matrix and the given one
  18139. * @param other defines the matrix to add
  18140. * @param result defines the target matrix
  18141. * @returns the current matrix
  18142. */
  18143. addToRef(other: Matrix, result: Matrix): Matrix;
  18144. /**
  18145. * Adds in place the given matrix to the current matrix
  18146. * @param other defines the second operand
  18147. * @returns the current updated matrix
  18148. */
  18149. addToSelf(other: Matrix): Matrix;
  18150. /**
  18151. * Sets the given matrix to the current inverted Matrix
  18152. * @param other defines the target matrix
  18153. * @returns the unmodified current matrix
  18154. */
  18155. invertToRef(other: Matrix): Matrix;
  18156. /**
  18157. * Inserts the translation vector (using 3 floats) in the current matrix
  18158. * @param x defines the 1st component of the translation
  18159. * @param y defines the 2nd component of the translation
  18160. * @param z defines the 3rd component of the translation
  18161. * @returns the current updated matrix
  18162. */
  18163. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  18164. /**
  18165. * Inserts the translation vector in the current matrix
  18166. * @param vector3 defines the translation to insert
  18167. * @returns the current updated matrix
  18168. */
  18169. setTranslation(vector3: Vector3): Matrix;
  18170. /**
  18171. * Gets the translation value of the current matrix
  18172. * @returns a new Vector3 as the extracted translation from the matrix
  18173. */
  18174. getTranslation(): Vector3;
  18175. /**
  18176. * Fill a Vector3 with the extracted translation from the matrix
  18177. * @param result defines the Vector3 where to store the translation
  18178. * @returns the current matrix
  18179. */
  18180. getTranslationToRef(result: Vector3): Matrix;
  18181. /**
  18182. * Remove rotation and scaling part from the matrix
  18183. * @returns the updated matrix
  18184. */
  18185. removeRotationAndScaling(): Matrix;
  18186. /**
  18187. * Multiply two matrices
  18188. * @param other defines the second operand
  18189. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  18190. */
  18191. multiply(other: Matrix): Matrix;
  18192. /**
  18193. * Copy the current matrix from the given one
  18194. * @param other defines the source matrix
  18195. * @returns the current updated matrix
  18196. */
  18197. copyFrom(other: Matrix): Matrix;
  18198. /**
  18199. * Populates the given array from the starting index with the current matrix values
  18200. * @param array defines the target array
  18201. * @param offset defines the offset in the target array where to start storing values
  18202. * @returns the current matrix
  18203. */
  18204. copyToArray(array: Float32Array, offset?: number): Matrix;
  18205. /**
  18206. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  18207. * @param other defines the second operand
  18208. * @param result defines the matrix where to store the multiplication
  18209. * @returns the current matrix
  18210. */
  18211. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  18212. /**
  18213. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  18214. * @param other defines the second operand
  18215. * @param result defines the array where to store the multiplication
  18216. * @param offset defines the offset in the target array where to start storing values
  18217. * @returns the current matrix
  18218. */
  18219. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  18220. /**
  18221. * Check equality between this matrix and a second one
  18222. * @param value defines the second matrix to compare
  18223. * @returns true is the current matrix and the given one values are strictly equal
  18224. */
  18225. equals(value: Matrix): boolean;
  18226. /**
  18227. * Clone the current matrix
  18228. * @returns a new matrix from the current matrix
  18229. */
  18230. clone(): Matrix;
  18231. /**
  18232. * Returns the name of the current matrix class
  18233. * @returns the string "Matrix"
  18234. */
  18235. getClassName(): string;
  18236. /**
  18237. * Gets the hash code of the current matrix
  18238. * @returns the hash code
  18239. */
  18240. getHashCode(): number;
  18241. /**
  18242. * Decomposes the current Matrix into a translation, rotation and scaling components
  18243. * @param scale defines the scale vector3 given as a reference to update
  18244. * @param rotation defines the rotation quaternion given as a reference to update
  18245. * @param translation defines the translation vector3 given as a reference to update
  18246. * @returns true if operation was successful
  18247. */
  18248. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18249. /**
  18250. * Gets specific row of the matrix
  18251. * @param index defines the number of the row to get
  18252. * @returns the index-th row of the current matrix as a new Vector4
  18253. */
  18254. getRow(index: number): Nullable<Vector4>;
  18255. /**
  18256. * Sets the index-th row of the current matrix to the vector4 values
  18257. * @param index defines the number of the row to set
  18258. * @param row defines the target vector4
  18259. * @returns the updated current matrix
  18260. */
  18261. setRow(index: number, row: Vector4): Matrix;
  18262. /**
  18263. * Compute the transpose of the matrix
  18264. * @returns the new transposed matrix
  18265. */
  18266. transpose(): Matrix;
  18267. /**
  18268. * Compute the transpose of the matrix and store it in a given matrix
  18269. * @param result defines the target matrix
  18270. * @returns the current matrix
  18271. */
  18272. transposeToRef(result: Matrix): Matrix;
  18273. /**
  18274. * Sets the index-th row of the current matrix with the given 4 x float values
  18275. * @param index defines the row index
  18276. * @param x defines the x component to set
  18277. * @param y defines the y component to set
  18278. * @param z defines the z component to set
  18279. * @param w defines the w component to set
  18280. * @returns the updated current matrix
  18281. */
  18282. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18283. /**
  18284. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18285. * @param scale defines the scale factor
  18286. * @returns a new matrix
  18287. */
  18288. scale(scale: number): Matrix;
  18289. /**
  18290. * Scale the current matrix values by a factor to a given result matrix
  18291. * @param scale defines the scale factor
  18292. * @param result defines the matrix to store the result
  18293. * @returns the current matrix
  18294. */
  18295. scaleToRef(scale: number, result: Matrix): Matrix;
  18296. /**
  18297. * Scale the current matrix values by a factor and add the result to a given matrix
  18298. * @param scale defines the scale factor
  18299. * @param result defines the Matrix to store the result
  18300. * @returns the current matrix
  18301. */
  18302. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18303. /**
  18304. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18305. * @param ref matrix to store the result
  18306. */
  18307. toNormalMatrix(ref: Matrix): void;
  18308. /**
  18309. * Gets only rotation part of the current matrix
  18310. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18311. */
  18312. getRotationMatrix(): Matrix;
  18313. /**
  18314. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18315. * @param result defines the target matrix to store data to
  18316. * @returns the current matrix
  18317. */
  18318. getRotationMatrixToRef(result: Matrix): Matrix;
  18319. /**
  18320. * Creates a matrix from an array
  18321. * @param array defines the source array
  18322. * @param offset defines an offset in the source array
  18323. * @returns a new Matrix set from the starting index of the given array
  18324. */
  18325. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18326. /**
  18327. * Copy the content of an array into a given matrix
  18328. * @param array defines the source array
  18329. * @param offset defines an offset in the source array
  18330. * @param result defines the target matrix
  18331. */
  18332. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18333. /**
  18334. * Stores an array into a matrix after having multiplied each component by a given factor
  18335. * @param array defines the source array
  18336. * @param offset defines the offset in the source array
  18337. * @param scale defines the scaling factor
  18338. * @param result defines the target matrix
  18339. */
  18340. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18341. /**
  18342. * Stores a list of values (16) inside a given matrix
  18343. * @param initialM11 defines 1st value of 1st row
  18344. * @param initialM12 defines 2nd value of 1st row
  18345. * @param initialM13 defines 3rd value of 1st row
  18346. * @param initialM14 defines 4th value of 1st row
  18347. * @param initialM21 defines 1st value of 2nd row
  18348. * @param initialM22 defines 2nd value of 2nd row
  18349. * @param initialM23 defines 3rd value of 2nd row
  18350. * @param initialM24 defines 4th value of 2nd row
  18351. * @param initialM31 defines 1st value of 3rd row
  18352. * @param initialM32 defines 2nd value of 3rd row
  18353. * @param initialM33 defines 3rd value of 3rd row
  18354. * @param initialM34 defines 4th value of 3rd row
  18355. * @param initialM41 defines 1st value of 4th row
  18356. * @param initialM42 defines 2nd value of 4th row
  18357. * @param initialM43 defines 3rd value of 4th row
  18358. * @param initialM44 defines 4th value of 4th row
  18359. * @param result defines the target matrix
  18360. */
  18361. 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;
  18362. /**
  18363. * Gets an identity matrix that must not be updated
  18364. */
  18365. static readonly IdentityReadOnly: Matrix;
  18366. /**
  18367. * Creates new matrix from a list of values (16)
  18368. * @param initialM11 defines 1st value of 1st row
  18369. * @param initialM12 defines 2nd value of 1st row
  18370. * @param initialM13 defines 3rd value of 1st row
  18371. * @param initialM14 defines 4th value of 1st row
  18372. * @param initialM21 defines 1st value of 2nd row
  18373. * @param initialM22 defines 2nd value of 2nd row
  18374. * @param initialM23 defines 3rd value of 2nd row
  18375. * @param initialM24 defines 4th value of 2nd row
  18376. * @param initialM31 defines 1st value of 3rd row
  18377. * @param initialM32 defines 2nd value of 3rd row
  18378. * @param initialM33 defines 3rd value of 3rd row
  18379. * @param initialM34 defines 4th value of 3rd row
  18380. * @param initialM41 defines 1st value of 4th row
  18381. * @param initialM42 defines 2nd value of 4th row
  18382. * @param initialM43 defines 3rd value of 4th row
  18383. * @param initialM44 defines 4th value of 4th row
  18384. * @returns the new matrix
  18385. */
  18386. 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;
  18387. /**
  18388. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18389. * @param scale defines the scale vector3
  18390. * @param rotation defines the rotation quaternion
  18391. * @param translation defines the translation vector3
  18392. * @returns a new matrix
  18393. */
  18394. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18395. /**
  18396. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18397. * @param scale defines the scale vector3
  18398. * @param rotation defines the rotation quaternion
  18399. * @param translation defines the translation vector3
  18400. * @param result defines the target matrix
  18401. */
  18402. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18403. /**
  18404. * Creates a new identity matrix
  18405. * @returns a new identity matrix
  18406. */
  18407. static Identity(): Matrix;
  18408. /**
  18409. * Creates a new identity matrix and stores the result in a given matrix
  18410. * @param result defines the target matrix
  18411. */
  18412. static IdentityToRef(result: Matrix): void;
  18413. /**
  18414. * Creates a new zero matrix
  18415. * @returns a new zero matrix
  18416. */
  18417. static Zero(): Matrix;
  18418. /**
  18419. * Creates a new rotation matrix for "angle" radians around the X axis
  18420. * @param angle defines the angle (in radians) to use
  18421. * @return the new matrix
  18422. */
  18423. static RotationX(angle: number): Matrix;
  18424. /**
  18425. * Creates a new matrix as the invert of a given matrix
  18426. * @param source defines the source matrix
  18427. * @returns the new matrix
  18428. */
  18429. static Invert(source: Matrix): Matrix;
  18430. /**
  18431. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18432. * @param angle defines the angle (in radians) to use
  18433. * @param result defines the target matrix
  18434. */
  18435. static RotationXToRef(angle: number, result: Matrix): void;
  18436. /**
  18437. * Creates a new rotation matrix for "angle" radians around the Y axis
  18438. * @param angle defines the angle (in radians) to use
  18439. * @return the new matrix
  18440. */
  18441. static RotationY(angle: number): Matrix;
  18442. /**
  18443. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18444. * @param angle defines the angle (in radians) to use
  18445. * @param result defines the target matrix
  18446. */
  18447. static RotationYToRef(angle: number, result: Matrix): void;
  18448. /**
  18449. * Creates a new rotation matrix for "angle" radians around the Z axis
  18450. * @param angle defines the angle (in radians) to use
  18451. * @return the new matrix
  18452. */
  18453. static RotationZ(angle: number): Matrix;
  18454. /**
  18455. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18456. * @param angle defines the angle (in radians) to use
  18457. * @param result defines the target matrix
  18458. */
  18459. static RotationZToRef(angle: number, result: Matrix): void;
  18460. /**
  18461. * Creates a new rotation matrix for "angle" radians around the given axis
  18462. * @param axis defines the axis to use
  18463. * @param angle defines the angle (in radians) to use
  18464. * @return the new matrix
  18465. */
  18466. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18467. /**
  18468. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18469. * @param axis defines the axis to use
  18470. * @param angle defines the angle (in radians) to use
  18471. * @param result defines the target matrix
  18472. */
  18473. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18474. /**
  18475. * Creates a rotation matrix
  18476. * @param yaw defines the yaw angle in radians (Y axis)
  18477. * @param pitch defines the pitch angle in radians (X axis)
  18478. * @param roll defines the roll angle in radians (X axis)
  18479. * @returns the new rotation matrix
  18480. */
  18481. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18482. /**
  18483. * Creates a rotation matrix and stores it in a given matrix
  18484. * @param yaw defines the yaw angle in radians (Y axis)
  18485. * @param pitch defines the pitch angle in radians (X axis)
  18486. * @param roll defines the roll angle in radians (X axis)
  18487. * @param result defines the target matrix
  18488. */
  18489. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18490. /**
  18491. * Creates a scaling matrix
  18492. * @param x defines the scale factor on X axis
  18493. * @param y defines the scale factor on Y axis
  18494. * @param z defines the scale factor on Z axis
  18495. * @returns the new matrix
  18496. */
  18497. static Scaling(x: number, y: number, z: number): Matrix;
  18498. /**
  18499. * Creates a scaling matrix and stores it in a given matrix
  18500. * @param x defines the scale factor on X axis
  18501. * @param y defines the scale factor on Y axis
  18502. * @param z defines the scale factor on Z axis
  18503. * @param result defines the target matrix
  18504. */
  18505. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18506. /**
  18507. * Creates a translation matrix
  18508. * @param x defines the translation on X axis
  18509. * @param y defines the translation on Y axis
  18510. * @param z defines the translationon Z axis
  18511. * @returns the new matrix
  18512. */
  18513. static Translation(x: number, y: number, z: number): Matrix;
  18514. /**
  18515. * Creates a translation matrix and stores it in a given matrix
  18516. * @param x defines the translation on X axis
  18517. * @param y defines the translation on Y axis
  18518. * @param z defines the translationon Z axis
  18519. * @param result defines the target matrix
  18520. */
  18521. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18522. /**
  18523. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18524. * @param startValue defines the start value
  18525. * @param endValue defines the end value
  18526. * @param gradient defines the gradient factor
  18527. * @returns the new matrix
  18528. */
  18529. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18530. /**
  18531. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18532. * @param startValue defines the start value
  18533. * @param endValue defines the end value
  18534. * @param gradient defines the gradient factor
  18535. * @param result defines the Matrix object where to store data
  18536. */
  18537. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18538. /**
  18539. * Builds a new matrix whose values are computed by:
  18540. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18541. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18542. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18543. * @param startValue defines the first matrix
  18544. * @param endValue defines the second matrix
  18545. * @param gradient defines the gradient between the two matrices
  18546. * @returns the new matrix
  18547. */
  18548. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18549. /**
  18550. * Update a matrix to values which are computed by:
  18551. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18552. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18553. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18554. * @param startValue defines the first matrix
  18555. * @param endValue defines the second matrix
  18556. * @param gradient defines the gradient between the two matrices
  18557. * @param result defines the target matrix
  18558. */
  18559. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18560. /**
  18561. * 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"
  18562. * This function works in left handed mode
  18563. * @param eye defines the final position of the entity
  18564. * @param target defines where the entity should look at
  18565. * @param up defines the up vector for the entity
  18566. * @returns the new matrix
  18567. */
  18568. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18569. /**
  18570. * 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".
  18571. * This function works in left handed mode
  18572. * @param eye defines the final position of the entity
  18573. * @param target defines where the entity should look at
  18574. * @param up defines the up vector for the entity
  18575. * @param result defines the target matrix
  18576. */
  18577. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18578. /**
  18579. * 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"
  18580. * This function works in right handed mode
  18581. * @param eye defines the final position of the entity
  18582. * @param target defines where the entity should look at
  18583. * @param up defines the up vector for the entity
  18584. * @returns the new matrix
  18585. */
  18586. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18587. /**
  18588. * 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".
  18589. * This function works in right handed mode
  18590. * @param eye defines the final position of the entity
  18591. * @param target defines where the entity should look at
  18592. * @param up defines the up vector for the entity
  18593. * @param result defines the target matrix
  18594. */
  18595. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18596. /**
  18597. * Create a left-handed orthographic projection matrix
  18598. * @param width defines the viewport width
  18599. * @param height defines the viewport height
  18600. * @param znear defines the near clip plane
  18601. * @param zfar defines the far clip plane
  18602. * @returns a new matrix as a left-handed orthographic projection matrix
  18603. */
  18604. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18605. /**
  18606. * Store a left-handed orthographic projection to a given matrix
  18607. * @param width defines the viewport width
  18608. * @param height defines the viewport height
  18609. * @param znear defines the near clip plane
  18610. * @param zfar defines the far clip plane
  18611. * @param result defines the target matrix
  18612. */
  18613. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18614. /**
  18615. * Create a left-handed orthographic projection matrix
  18616. * @param left defines the viewport left coordinate
  18617. * @param right defines the viewport right coordinate
  18618. * @param bottom defines the viewport bottom coordinate
  18619. * @param top defines the viewport top coordinate
  18620. * @param znear defines the near clip plane
  18621. * @param zfar defines the far clip plane
  18622. * @returns a new matrix as a left-handed orthographic projection matrix
  18623. */
  18624. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18625. /**
  18626. * Stores a left-handed orthographic projection into a given matrix
  18627. * @param left defines the viewport left coordinate
  18628. * @param right defines the viewport right coordinate
  18629. * @param bottom defines the viewport bottom coordinate
  18630. * @param top defines the viewport top coordinate
  18631. * @param znear defines the near clip plane
  18632. * @param zfar defines the far clip plane
  18633. * @param result defines the target matrix
  18634. */
  18635. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18636. /**
  18637. * Creates a right-handed orthographic projection matrix
  18638. * @param left defines the viewport left coordinate
  18639. * @param right defines the viewport right coordinate
  18640. * @param bottom defines the viewport bottom coordinate
  18641. * @param top defines the viewport top coordinate
  18642. * @param znear defines the near clip plane
  18643. * @param zfar defines the far clip plane
  18644. * @returns a new matrix as a right-handed orthographic projection matrix
  18645. */
  18646. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18647. /**
  18648. * Stores a right-handed orthographic projection into a given matrix
  18649. * @param left defines the viewport left coordinate
  18650. * @param right defines the viewport right coordinate
  18651. * @param bottom defines the viewport bottom coordinate
  18652. * @param top defines the viewport top coordinate
  18653. * @param znear defines the near clip plane
  18654. * @param zfar defines the far clip plane
  18655. * @param result defines the target matrix
  18656. */
  18657. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18658. /**
  18659. * Creates a left-handed perspective projection matrix
  18660. * @param width defines the viewport width
  18661. * @param height defines the viewport height
  18662. * @param znear defines the near clip plane
  18663. * @param zfar defines the far clip plane
  18664. * @returns a new matrix as a left-handed perspective projection matrix
  18665. */
  18666. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18667. /**
  18668. * Creates a left-handed perspective projection matrix
  18669. * @param fov defines the horizontal field of view
  18670. * @param aspect defines the aspect ratio
  18671. * @param znear defines the near clip plane
  18672. * @param zfar defines the far clip plane
  18673. * @returns a new matrix as a left-handed perspective projection matrix
  18674. */
  18675. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18676. /**
  18677. * Stores a left-handed perspective projection into a given matrix
  18678. * @param fov defines the horizontal field of view
  18679. * @param aspect defines the aspect ratio
  18680. * @param znear defines the near clip plane
  18681. * @param zfar defines the far clip plane
  18682. * @param result defines the target matrix
  18683. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18684. */
  18685. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18686. /**
  18687. * Creates a right-handed perspective projection matrix
  18688. * @param fov defines the horizontal field of view
  18689. * @param aspect defines the aspect ratio
  18690. * @param znear defines the near clip plane
  18691. * @param zfar defines the far clip plane
  18692. * @returns a new matrix as a right-handed perspective projection matrix
  18693. */
  18694. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18695. /**
  18696. * Stores a right-handed perspective projection into a given matrix
  18697. * @param fov defines the horizontal field of view
  18698. * @param aspect defines the aspect ratio
  18699. * @param znear defines the near clip plane
  18700. * @param zfar defines the far clip plane
  18701. * @param result defines the target matrix
  18702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18703. */
  18704. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18705. /**
  18706. * Stores a perspective projection for WebVR info a given matrix
  18707. * @param fov defines the field of view
  18708. * @param znear defines the near clip plane
  18709. * @param zfar defines the far clip plane
  18710. * @param result defines the target matrix
  18711. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18712. */
  18713. static PerspectiveFovWebVRToRef(fov: {
  18714. upDegrees: number;
  18715. downDegrees: number;
  18716. leftDegrees: number;
  18717. rightDegrees: number;
  18718. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18719. /**
  18720. * Computes a complete transformation matrix
  18721. * @param viewport defines the viewport to use
  18722. * @param world defines the world matrix
  18723. * @param view defines the view matrix
  18724. * @param projection defines the projection matrix
  18725. * @param zmin defines the near clip plane
  18726. * @param zmax defines the far clip plane
  18727. * @returns the transformation matrix
  18728. */
  18729. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18730. /**
  18731. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18732. * @param matrix defines the matrix to use
  18733. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18734. */
  18735. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18736. /**
  18737. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18738. * @param matrix defines the matrix to use
  18739. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18740. */
  18741. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18742. /**
  18743. * Compute the transpose of a given matrix
  18744. * @param matrix defines the matrix to transpose
  18745. * @returns the new matrix
  18746. */
  18747. static Transpose(matrix: Matrix): Matrix;
  18748. /**
  18749. * Compute the transpose of a matrix and store it in a target matrix
  18750. * @param matrix defines the matrix to transpose
  18751. * @param result defines the target matrix
  18752. */
  18753. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18754. /**
  18755. * Computes a reflection matrix from a plane
  18756. * @param plane defines the reflection plane
  18757. * @returns a new matrix
  18758. */
  18759. static Reflection(plane: Plane): Matrix;
  18760. /**
  18761. * Computes a reflection matrix from a plane
  18762. * @param plane defines the reflection plane
  18763. * @param result defines the target matrix
  18764. */
  18765. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18766. /**
  18767. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18768. * @param xaxis defines the value of the 1st axis
  18769. * @param yaxis defines the value of the 2nd axis
  18770. * @param zaxis defines the value of the 3rd axis
  18771. * @param result defines the target matrix
  18772. */
  18773. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18774. /**
  18775. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18776. * @param quat defines the quaternion to use
  18777. * @param result defines the target matrix
  18778. */
  18779. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18780. }
  18781. class Plane {
  18782. normal: Vector3;
  18783. d: number;
  18784. /**
  18785. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18786. */
  18787. constructor(a: number, b: number, c: number, d: number);
  18788. /**
  18789. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18790. */
  18791. asArray(): number[];
  18792. /**
  18793. * Returns a new plane copied from the current Plane.
  18794. */
  18795. clone(): Plane;
  18796. /**
  18797. * Returns the string "Plane".
  18798. */
  18799. getClassName(): string;
  18800. /**
  18801. * Returns the Plane hash code.
  18802. */
  18803. getHashCode(): number;
  18804. /**
  18805. * Normalize the current Plane in place.
  18806. * Returns the updated Plane.
  18807. */
  18808. normalize(): Plane;
  18809. /**
  18810. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18811. */
  18812. transform(transformation: Matrix): Plane;
  18813. /**
  18814. * Returns the dot product (float) of the point coordinates and the plane normal.
  18815. */
  18816. dotCoordinate(point: Vector3): number;
  18817. /**
  18818. * Updates the current Plane from the plane defined by the three given points.
  18819. * Returns the updated Plane.
  18820. */
  18821. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18822. /**
  18823. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18824. */
  18825. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18826. /**
  18827. * Returns the signed distance (float) from the given point to the Plane.
  18828. */
  18829. signedDistanceTo(point: Vector3): number;
  18830. /**
  18831. * Returns a new Plane from the given array.
  18832. */
  18833. static FromArray(array: ArrayLike<number>): Plane;
  18834. /**
  18835. * Returns a new Plane defined by the three given points.
  18836. */
  18837. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18838. /**
  18839. * Returns a new Plane the normal vector to this plane at the given origin point.
  18840. * Note : the vector "normal" is updated because normalized.
  18841. */
  18842. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18843. /**
  18844. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18845. */
  18846. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18847. }
  18848. class Viewport {
  18849. x: number;
  18850. y: number;
  18851. width: number;
  18852. height: number;
  18853. /**
  18854. * Creates a Viewport object located at (x, y) and sized (width, height).
  18855. */
  18856. constructor(x: number, y: number, width: number, height: number);
  18857. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18858. /**
  18859. * Returns a new Viewport copied from the current one.
  18860. */
  18861. clone(): Viewport;
  18862. }
  18863. class Frustum {
  18864. /**
  18865. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18866. */
  18867. static GetPlanes(transform: Matrix): Plane[];
  18868. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18869. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18870. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18871. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18872. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18873. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18874. /**
  18875. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18876. */
  18877. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18878. }
  18879. /** Defines supported spaces */
  18880. enum Space {
  18881. /** Local (object) space */
  18882. LOCAL = 0,
  18883. /** World space */
  18884. WORLD = 1,
  18885. /** Bone space */
  18886. BONE = 2
  18887. }
  18888. /** Defines the 3 main axes */
  18889. class Axis {
  18890. /** X axis */
  18891. static X: Vector3;
  18892. /** Y axis */
  18893. static Y: Vector3;
  18894. /** Z axis */
  18895. static Z: Vector3;
  18896. }
  18897. class BezierCurve {
  18898. /**
  18899. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18900. */
  18901. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18902. }
  18903. /**
  18904. * Defines potential orientation for back face culling
  18905. */
  18906. enum Orientation {
  18907. /**
  18908. * Clockwise
  18909. */
  18910. CW = 0,
  18911. /** Counter clockwise */
  18912. CCW = 1
  18913. }
  18914. /**
  18915. * Defines angle representation
  18916. */
  18917. class Angle {
  18918. private _radians;
  18919. /**
  18920. * Creates an Angle object of "radians" radians (float).
  18921. */
  18922. constructor(radians: number);
  18923. /**
  18924. * Get value in degrees
  18925. * @returns the Angle value in degrees (float)
  18926. */
  18927. degrees(): number;
  18928. /**
  18929. * Get value in radians
  18930. * @returns the Angle value in radians (float)
  18931. */
  18932. radians(): number;
  18933. /**
  18934. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18935. * @param a defines first vector
  18936. * @param b defines second vector
  18937. * @returns a new Angle
  18938. */
  18939. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18940. /**
  18941. * Gets a new Angle object from the given float in radians
  18942. * @param radians defines the angle value in radians
  18943. * @returns a new Angle
  18944. */
  18945. static FromRadians(radians: number): Angle;
  18946. /**
  18947. * Gets a new Angle object from the given float in degrees
  18948. * @param degrees defines the angle value in degrees
  18949. * @returns a new Angle
  18950. */
  18951. static FromDegrees(degrees: number): Angle;
  18952. }
  18953. class Arc2 {
  18954. startPoint: Vector2;
  18955. midPoint: Vector2;
  18956. endPoint: Vector2;
  18957. centerPoint: Vector2;
  18958. radius: number;
  18959. angle: Angle;
  18960. startAngle: Angle;
  18961. orientation: Orientation;
  18962. /**
  18963. * Creates an Arc object from the three given points : start, middle and end.
  18964. */
  18965. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18966. }
  18967. class Path2 {
  18968. private _points;
  18969. private _length;
  18970. closed: boolean;
  18971. /**
  18972. * Creates a Path2 object from the starting 2D coordinates x and y.
  18973. */
  18974. constructor(x: number, y: number);
  18975. /**
  18976. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18977. * Returns the updated Path2.
  18978. */
  18979. addLineTo(x: number, y: number): Path2;
  18980. /**
  18981. * 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.
  18982. * Returns the updated Path2.
  18983. */
  18984. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18985. /**
  18986. * Closes the Path2.
  18987. * Returns the Path2.
  18988. */
  18989. close(): Path2;
  18990. /**
  18991. * Returns the Path2 total length (float).
  18992. */
  18993. length(): number;
  18994. /**
  18995. * Returns the Path2 internal array of points.
  18996. */
  18997. getPoints(): Vector2[];
  18998. /**
  18999. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  19000. */
  19001. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  19002. /**
  19003. * Returns a new Path2 starting at the coordinates (x, y).
  19004. */
  19005. static StartingAt(x: number, y: number): Path2;
  19006. }
  19007. class Path3D {
  19008. path: Vector3[];
  19009. private _curve;
  19010. private _distances;
  19011. private _tangents;
  19012. private _normals;
  19013. private _binormals;
  19014. private _raw;
  19015. /**
  19016. * new Path3D(path, normal, raw)
  19017. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  19018. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  19019. * path : an array of Vector3, the curve axis of the Path3D
  19020. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  19021. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  19022. */
  19023. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  19024. /**
  19025. * Returns the Path3D array of successive Vector3 designing its curve.
  19026. */
  19027. getCurve(): Vector3[];
  19028. /**
  19029. * Returns an array populated with tangent vectors on each Path3D curve point.
  19030. */
  19031. getTangents(): Vector3[];
  19032. /**
  19033. * Returns an array populated with normal vectors on each Path3D curve point.
  19034. */
  19035. getNormals(): Vector3[];
  19036. /**
  19037. * Returns an array populated with binormal vectors on each Path3D curve point.
  19038. */
  19039. getBinormals(): Vector3[];
  19040. /**
  19041. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  19042. */
  19043. getDistances(): number[];
  19044. /**
  19045. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  19046. * Returns the same object updated.
  19047. */
  19048. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  19049. private _compute;
  19050. private _getFirstNonNullVector;
  19051. private _getLastNonNullVector;
  19052. private _normalVector;
  19053. }
  19054. class Curve3 {
  19055. private _points;
  19056. private _length;
  19057. /**
  19058. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  19059. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  19060. * @param v1 (Vector3) the control point
  19061. * @param v2 (Vector3) the end point of the Quadratic Bezier
  19062. * @param nbPoints (integer) the wanted number of points in the curve
  19063. */
  19064. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  19065. /**
  19066. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  19067. * @param v0 (Vector3) the origin point of the Cubic Bezier
  19068. * @param v1 (Vector3) the first control point
  19069. * @param v2 (Vector3) the second control point
  19070. * @param v3 (Vector3) the end point of the Cubic Bezier
  19071. * @param nbPoints (integer) the wanted number of points in the curve
  19072. */
  19073. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  19074. /**
  19075. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  19076. * @param p1 (Vector3) the origin point of the Hermite Spline
  19077. * @param t1 (Vector3) the tangent vector at the origin point
  19078. * @param p2 (Vector3) the end point of the Hermite Spline
  19079. * @param t2 (Vector3) the tangent vector at the end point
  19080. * @param nbPoints (integer) the wanted number of points in the curve
  19081. */
  19082. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  19083. /**
  19084. * Returns a Curve3 object along a CatmullRom Spline curve :
  19085. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  19086. * @param nbPoints (integer) the wanted number of points between each curve control points
  19087. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  19088. */
  19089. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  19090. /**
  19091. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  19092. * A Curve3 is designed from a series of successive Vector3.
  19093. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  19094. */
  19095. constructor(points: Vector3[]);
  19096. /**
  19097. * Returns the Curve3 stored array of successive Vector3
  19098. */
  19099. getPoints(): Vector3[];
  19100. /**
  19101. * Returns the computed length (float) of the curve.
  19102. */
  19103. length(): number;
  19104. /**
  19105. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  19106. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  19107. * curveA and curveB keep unchanged.
  19108. */
  19109. continue(curve: Curve3): Curve3;
  19110. private _computeLength;
  19111. }
  19112. class PositionNormalVertex {
  19113. position: Vector3;
  19114. normal: Vector3;
  19115. constructor(position?: Vector3, normal?: Vector3);
  19116. clone(): PositionNormalVertex;
  19117. }
  19118. class PositionNormalTextureVertex {
  19119. position: Vector3;
  19120. normal: Vector3;
  19121. uv: Vector2;
  19122. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  19123. clone(): PositionNormalTextureVertex;
  19124. }
  19125. class Tmp {
  19126. static Color3: Color3[];
  19127. static Color4: Color4[];
  19128. static Vector2: Vector2[];
  19129. static Vector3: Vector3[];
  19130. static Vector4: Vector4[];
  19131. static Quaternion: Quaternion[];
  19132. static Matrix: Matrix[];
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * Class representing spherical polynomial coefficients to the 3rd degree
  19138. */
  19139. class SphericalPolynomial {
  19140. /**
  19141. * The x coefficients of the spherical polynomial
  19142. */
  19143. x: Vector3;
  19144. /**
  19145. * The y coefficients of the spherical polynomial
  19146. */
  19147. y: Vector3;
  19148. /**
  19149. * The z coefficients of the spherical polynomial
  19150. */
  19151. z: Vector3;
  19152. /**
  19153. * The xx coefficients of the spherical polynomial
  19154. */
  19155. xx: Vector3;
  19156. /**
  19157. * The yy coefficients of the spherical polynomial
  19158. */
  19159. yy: Vector3;
  19160. /**
  19161. * The zz coefficients of the spherical polynomial
  19162. */
  19163. zz: Vector3;
  19164. /**
  19165. * The xy coefficients of the spherical polynomial
  19166. */
  19167. xy: Vector3;
  19168. /**
  19169. * The yz coefficients of the spherical polynomial
  19170. */
  19171. yz: Vector3;
  19172. /**
  19173. * The zx coefficients of the spherical polynomial
  19174. */
  19175. zx: Vector3;
  19176. /**
  19177. * Adds an ambient color to the spherical polynomial
  19178. * @param color the color to add
  19179. */
  19180. addAmbient(color: Color3): void;
  19181. /**
  19182. * Scales the spherical polynomial by the given amount
  19183. * @param scale the amount to scale
  19184. */
  19185. scale(scale: number): void;
  19186. /**
  19187. * Gets the spherical polynomial from harmonics
  19188. * @param harmonics the spherical harmonics
  19189. * @returns the spherical polynomial
  19190. */
  19191. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  19192. /**
  19193. * Constructs a spherical polynomial from an array.
  19194. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  19195. * @returns the spherical polynomial
  19196. */
  19197. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  19198. }
  19199. /**
  19200. * Class representing spherical harmonics coefficients to the 3rd degree
  19201. */
  19202. class SphericalHarmonics {
  19203. /**
  19204. * The l0,0 coefficients of the spherical harmonics
  19205. */
  19206. l00: Vector3;
  19207. /**
  19208. * The l1,-1 coefficients of the spherical harmonics
  19209. */
  19210. l1_1: Vector3;
  19211. /**
  19212. * The l1,0 coefficients of the spherical harmonics
  19213. */
  19214. l10: Vector3;
  19215. /**
  19216. * The l1,1 coefficients of the spherical harmonics
  19217. */
  19218. l11: Vector3;
  19219. /**
  19220. * The l2,-2 coefficients of the spherical harmonics
  19221. */
  19222. l2_2: Vector3;
  19223. /**
  19224. * The l2,-1 coefficients of the spherical harmonics
  19225. */
  19226. l2_1: Vector3;
  19227. /**
  19228. * The l2,0 coefficients of the spherical harmonics
  19229. */
  19230. l20: Vector3;
  19231. /**
  19232. * The l2,1 coefficients of the spherical harmonics
  19233. */
  19234. l21: Vector3;
  19235. /**
  19236. * The l2,2 coefficients of the spherical harmonics
  19237. */
  19238. lL22: Vector3;
  19239. /**
  19240. * Adds a light to the spherical harmonics
  19241. * @param direction the direction of the light
  19242. * @param color the color of the light
  19243. * @param deltaSolidAngle the delta solid angle of the light
  19244. */
  19245. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19246. /**
  19247. * Scales the spherical harmonics by the given amount
  19248. * @param scale the amount to scale
  19249. */
  19250. scale(scale: number): void;
  19251. /**
  19252. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19253. *
  19254. * ```
  19255. * E_lm = A_l * L_lm
  19256. * ```
  19257. *
  19258. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19259. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19260. * the scaling factors are given in equation 9.
  19261. */
  19262. convertIncidentRadianceToIrradiance(): void;
  19263. /**
  19264. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19265. *
  19266. * ```
  19267. * L = (1/pi) * E * rho
  19268. * ```
  19269. *
  19270. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19271. */
  19272. convertIrradianceToLambertianRadiance(): void;
  19273. /**
  19274. * Gets the spherical harmonics from polynomial
  19275. * @param polynomial the spherical polynomial
  19276. * @returns the spherical harmonics
  19277. */
  19278. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19279. /**
  19280. * Constructs a spherical harmonics from an array.
  19281. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19282. * @returns the spherical harmonics
  19283. */
  19284. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19285. }
  19286. }
  19287. declare module BABYLON {
  19288. /**
  19289. * Class used to store all common mesh properties
  19290. */
  19291. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19292. /** No occlusion */
  19293. static OCCLUSION_TYPE_NONE: number;
  19294. /** Occlusion set to optimisitic */
  19295. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19296. /** Occlusion set to strict */
  19297. static OCCLUSION_TYPE_STRICT: number;
  19298. /** Use an accurante occlusion algorithm */
  19299. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19300. /** Use a conservative occlusion algorithm */
  19301. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19302. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19303. static readonly CULLINGSTRATEGY_STANDARD: number;
  19304. /** Culling strategy with bounding sphere only and then frustum culling */
  19305. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19306. /**
  19307. * No billboard
  19308. */
  19309. static readonly BILLBOARDMODE_NONE: number;
  19310. /** Billboard on X axis */
  19311. static readonly BILLBOARDMODE_X: number;
  19312. /** Billboard on Y axis */
  19313. static readonly BILLBOARDMODE_Y: number;
  19314. /** Billboard on Z axis */
  19315. static readonly BILLBOARDMODE_Z: number;
  19316. /** Billboard on all axes */
  19317. static readonly BILLBOARDMODE_ALL: number;
  19318. private _facetPositions;
  19319. private _facetNormals;
  19320. private _facetPartitioning;
  19321. private _facetNb;
  19322. private _partitioningSubdivisions;
  19323. private _partitioningBBoxRatio;
  19324. private _facetDataEnabled;
  19325. private _facetParameters;
  19326. private _bbSize;
  19327. private _subDiv;
  19328. private _facetDepthSort;
  19329. private _facetDepthSortEnabled;
  19330. private _depthSortedIndices;
  19331. private _depthSortedFacets;
  19332. private _facetDepthSortFunction;
  19333. private _facetDepthSortFrom;
  19334. private _facetDepthSortOrigin;
  19335. private _invertedMatrix;
  19336. /** Gets ot sets the culling strategy to use to find visible meshes */
  19337. cullingStrategy: number;
  19338. /**
  19339. * Gets the number of facets in the mesh
  19340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19341. */
  19342. readonly facetNb: number;
  19343. /**
  19344. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19346. */
  19347. partitioningSubdivisions: number;
  19348. /**
  19349. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19350. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19352. */
  19353. partitioningBBoxRatio: number;
  19354. /**
  19355. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19356. * Works only for updatable meshes.
  19357. * Doesn't work with multi-materials
  19358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19359. */
  19360. mustDepthSortFacets: boolean;
  19361. /**
  19362. * The location (Vector3) where the facet depth sort must be computed from.
  19363. * By default, the active camera position.
  19364. * Used only when facet depth sort is enabled
  19365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19366. */
  19367. facetDepthSortFrom: Vector3;
  19368. /**
  19369. * gets a boolean indicating if facetData is enabled
  19370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19371. */
  19372. readonly isFacetDataEnabled: boolean;
  19373. /** @hidden */
  19374. _updateNonUniformScalingState(value: boolean): boolean;
  19375. /**
  19376. * An event triggered when this mesh collides with another one
  19377. */
  19378. onCollideObservable: Observable<AbstractMesh>;
  19379. private _onCollideObserver;
  19380. /** Set a function to call when this mesh collides with another one */
  19381. onCollide: () => void;
  19382. /**
  19383. * An event triggered when the collision's position changes
  19384. */
  19385. onCollisionPositionChangeObservable: Observable<Vector3>;
  19386. private _onCollisionPositionChangeObserver;
  19387. /** Set a function to call when the collision's position changes */
  19388. onCollisionPositionChange: () => void;
  19389. /**
  19390. * An event triggered when material is changed
  19391. */
  19392. onMaterialChangedObservable: Observable<AbstractMesh>;
  19393. /**
  19394. * Gets or sets the orientation for POV movement & rotation
  19395. */
  19396. definedFacingForward: boolean;
  19397. /**
  19398. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19399. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19400. * * 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.
  19401. * @see http://doc.babylonjs.com/features/occlusionquery
  19402. */
  19403. occlusionQueryAlgorithmType: number;
  19404. /**
  19405. * 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:
  19406. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19407. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19408. * * 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.
  19409. * @see http://doc.babylonjs.com/features/occlusionquery
  19410. */
  19411. occlusionType: number;
  19412. /**
  19413. * 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.
  19414. * The default value is -1 which means don't break the query and wait till the result
  19415. * @see http://doc.babylonjs.com/features/occlusionquery
  19416. */
  19417. occlusionRetryCount: number;
  19418. /** @hidden */
  19419. _occlusionInternalRetryCounter: number;
  19420. /** @hidden */
  19421. _isOccluded: boolean;
  19422. /**
  19423. * 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
  19424. * @see http://doc.babylonjs.com/features/occlusionquery
  19425. */
  19426. isOccluded: boolean;
  19427. /** @hidden */
  19428. _isOcclusionQueryInProgress: boolean;
  19429. /**
  19430. * Flag to check the progress status of the query
  19431. * @see http://doc.babylonjs.com/features/occlusionquery
  19432. */
  19433. readonly isOcclusionQueryInProgress: boolean;
  19434. /** @hidden */
  19435. _occlusionQuery: Nullable<WebGLQuery>;
  19436. private _visibility;
  19437. /**
  19438. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19439. */
  19440. /**
  19441. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19442. */
  19443. visibility: number;
  19444. /** Gets or sets the alpha index used to sort transparent meshes
  19445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19446. */
  19447. alphaIndex: number;
  19448. /**
  19449. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19450. */
  19451. isVisible: boolean;
  19452. /**
  19453. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19454. */
  19455. isPickable: boolean;
  19456. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19457. showSubMeshesBoundingBox: boolean;
  19458. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19459. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19460. */
  19461. isBlocker: boolean;
  19462. /**
  19463. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19464. */
  19465. enablePointerMoveEvents: boolean;
  19466. /**
  19467. * Specifies the rendering group id for this mesh (0 by default)
  19468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19469. */
  19470. renderingGroupId: number;
  19471. private _material;
  19472. /** Gets or sets current material */
  19473. material: Nullable<Material>;
  19474. private _receiveShadows;
  19475. /**
  19476. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19477. * @see http://doc.babylonjs.com/babylon101/shadows
  19478. */
  19479. receiveShadows: boolean;
  19480. /**
  19481. * Gets or sets a boolean indicating if the outline must be rendered as well
  19482. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19483. */
  19484. renderOutline: boolean;
  19485. /** Defines color to use when rendering outline */
  19486. outlineColor: Color3;
  19487. /** Define width to use when rendering outline */
  19488. outlineWidth: number;
  19489. /**
  19490. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19491. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19492. */
  19493. renderOverlay: boolean;
  19494. /** Defines color to use when rendering overlay */
  19495. overlayColor: Color3;
  19496. /** Defines alpha to use when rendering overlay */
  19497. overlayAlpha: number;
  19498. private _hasVertexAlpha;
  19499. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19500. hasVertexAlpha: boolean;
  19501. private _useVertexColors;
  19502. /** 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) */
  19503. useVertexColors: boolean;
  19504. private _computeBonesUsingShaders;
  19505. /**
  19506. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19507. */
  19508. computeBonesUsingShaders: boolean;
  19509. private _numBoneInfluencers;
  19510. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19511. numBoneInfluencers: number;
  19512. private _applyFog;
  19513. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19514. applyFog: boolean;
  19515. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19516. useOctreeForRenderingSelection: boolean;
  19517. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19518. useOctreeForPicking: boolean;
  19519. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19520. useOctreeForCollisions: boolean;
  19521. private _layerMask;
  19522. /**
  19523. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19524. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19525. */
  19526. layerMask: number;
  19527. /**
  19528. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19529. */
  19530. alwaysSelectAsActiveMesh: boolean;
  19531. /**
  19532. * Gets or sets the current action manager
  19533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19534. */
  19535. actionManager: Nullable<ActionManager>;
  19536. /**
  19537. * Gets or sets impostor used for physic simulation
  19538. * @see http://doc.babylonjs.com/features/physics_engine
  19539. */
  19540. physicsImpostor: Nullable<PhysicsImpostor>;
  19541. private _checkCollisions;
  19542. private _collisionMask;
  19543. private _collisionGroup;
  19544. /**
  19545. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19546. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19547. */
  19548. ellipsoid: Vector3;
  19549. /**
  19550. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19552. */
  19553. ellipsoidOffset: Vector3;
  19554. private _collider;
  19555. private _oldPositionForCollisions;
  19556. private _diffPositionForCollisions;
  19557. /**
  19558. * Gets or sets a collision mask used to mask collisions (default is -1).
  19559. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19560. */
  19561. collisionMask: number;
  19562. /**
  19563. * Gets or sets the current collision group mask (-1 by default).
  19564. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19565. */
  19566. collisionGroup: number;
  19567. /**
  19568. * Defines edge width used when edgesRenderer is enabled
  19569. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19570. */
  19571. edgesWidth: number;
  19572. /**
  19573. * Defines edge color used when edgesRenderer is enabled
  19574. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19575. */
  19576. edgesColor: Color4;
  19577. /** @hidden */
  19578. _edgesRenderer: Nullable<EdgesRenderer>;
  19579. private _collisionsTransformMatrix;
  19580. private _collisionsScalingMatrix;
  19581. /** @hidden */
  19582. _masterMesh: Nullable<AbstractMesh>;
  19583. /** @hidden */
  19584. _boundingInfo: Nullable<BoundingInfo>;
  19585. /** @hidden */
  19586. _renderId: number;
  19587. /**
  19588. * Gets or sets the list of subMeshes
  19589. * @see http://doc.babylonjs.com/how_to/multi_materials
  19590. */
  19591. subMeshes: SubMesh[];
  19592. /** @hidden */
  19593. _submeshesOctree: Octree<SubMesh>;
  19594. /** @hidden */
  19595. _intersectionsInProgress: AbstractMesh[];
  19596. /** @hidden */
  19597. _unIndexed: boolean;
  19598. /** @hidden */
  19599. _lightSources: Light[];
  19600. /** @hidden */
  19601. readonly _positions: Nullable<Vector3[]>;
  19602. /** @hidden */
  19603. _waitingActions: any;
  19604. /** @hidden */
  19605. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19606. private _skeleton;
  19607. /** @hidden */
  19608. _bonesTransformMatrices: Nullable<Float32Array>;
  19609. /**
  19610. * Gets or sets a skeleton to apply skining transformations
  19611. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19612. */
  19613. skeleton: Nullable<Skeleton>;
  19614. /**
  19615. * Creates a new AbstractMesh
  19616. * @param name defines the name of the mesh
  19617. * @param scene defines the hosting scene
  19618. */
  19619. constructor(name: string, scene?: Nullable<Scene>);
  19620. /**
  19621. * Returns the string "AbstractMesh"
  19622. * @returns "AbstractMesh"
  19623. */
  19624. getClassName(): string;
  19625. /**
  19626. * Gets a string representation of the current mesh
  19627. * @param fullDetails defines a boolean indicating if full details must be included
  19628. * @returns a string representation of the current mesh
  19629. */
  19630. toString(fullDetails?: boolean): string;
  19631. /** @hidden */
  19632. _rebuild(): void;
  19633. /** @hidden */
  19634. _resyncLightSources(): void;
  19635. /** @hidden */
  19636. _resyncLighSource(light: Light): void;
  19637. /** @hidden */
  19638. _unBindEffect(): void;
  19639. /** @hidden */
  19640. _removeLightSource(light: Light): void;
  19641. private _markSubMeshesAsDirty;
  19642. /** @hidden */
  19643. _markSubMeshesAsLightDirty(): void;
  19644. /** @hidden */
  19645. _markSubMeshesAsAttributesDirty(): void;
  19646. /** @hidden */
  19647. _markSubMeshesAsMiscDirty(): void;
  19648. /**
  19649. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19650. */
  19651. scaling: Vector3;
  19652. /**
  19653. * Disables the mesh edge rendering mode
  19654. * @returns the currentAbstractMesh
  19655. */
  19656. disableEdgesRendering(): AbstractMesh;
  19657. /**
  19658. * Enables the edge rendering mode on the mesh.
  19659. * This mode makes the mesh edges visible
  19660. * @param epsilon defines the maximal distance between two angles to detect a face
  19661. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19662. * @returns the currentAbstractMesh
  19663. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19664. */
  19665. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19666. /**
  19667. * Gets the edgesRenderer associated with the mesh
  19668. */
  19669. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19670. /**
  19671. * Returns true if the mesh is blocked. Implemented by child classes
  19672. */
  19673. readonly isBlocked: boolean;
  19674. /**
  19675. * Returns the mesh itself by default. Implemented by child classes
  19676. * @param camera defines the camera to use to pick the right LOD level
  19677. * @returns the currentAbstractMesh
  19678. */
  19679. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19680. /**
  19681. * Returns 0 by default. Implemented by child classes
  19682. * @returns an integer
  19683. */
  19684. getTotalVertices(): number;
  19685. /**
  19686. * Returns null by default. Implemented by child classes
  19687. * @returns null
  19688. */
  19689. getIndices(): Nullable<IndicesArray>;
  19690. /**
  19691. * Returns the array of the requested vertex data kind. Implemented by child classes
  19692. * @param kind defines the vertex data kind to use
  19693. * @returns null
  19694. */
  19695. getVerticesData(kind: string): Nullable<FloatArray>;
  19696. /**
  19697. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19698. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19699. * Note that a new underlying VertexBuffer object is created each call.
  19700. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19701. * @param kind defines vertex data kind:
  19702. * * BABYLON.VertexBuffer.PositionKind
  19703. * * BABYLON.VertexBuffer.UVKind
  19704. * * BABYLON.VertexBuffer.UV2Kind
  19705. * * BABYLON.VertexBuffer.UV3Kind
  19706. * * BABYLON.VertexBuffer.UV4Kind
  19707. * * BABYLON.VertexBuffer.UV5Kind
  19708. * * BABYLON.VertexBuffer.UV6Kind
  19709. * * BABYLON.VertexBuffer.ColorKind
  19710. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19711. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19712. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19713. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19714. * @param data defines the data source
  19715. * @param updatable defines if the data must be flagged as updatable (or static)
  19716. * @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
  19717. * @returns the current mesh
  19718. */
  19719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19720. /**
  19721. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19722. * If the mesh has no geometry, it is simply returned as it is.
  19723. * @param kind defines vertex data kind:
  19724. * * BABYLON.VertexBuffer.PositionKind
  19725. * * BABYLON.VertexBuffer.UVKind
  19726. * * BABYLON.VertexBuffer.UV2Kind
  19727. * * BABYLON.VertexBuffer.UV3Kind
  19728. * * BABYLON.VertexBuffer.UV4Kind
  19729. * * BABYLON.VertexBuffer.UV5Kind
  19730. * * BABYLON.VertexBuffer.UV6Kind
  19731. * * BABYLON.VertexBuffer.ColorKind
  19732. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19733. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19734. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19735. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19736. * @param data defines the data source
  19737. * @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
  19738. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19739. * @returns the current mesh
  19740. */
  19741. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19742. /**
  19743. * Sets the mesh indices,
  19744. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19745. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19746. * @param totalVertices Defines the total number of vertices
  19747. * @returns the current mesh
  19748. */
  19749. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19750. /**
  19751. * Gets a boolean indicating if specific vertex data is present
  19752. * @param kind defines the vertex data kind to use
  19753. * @returns true is data kind is present
  19754. */
  19755. isVerticesDataPresent(kind: string): boolean;
  19756. /**
  19757. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19758. * @returns a BoundingInfo
  19759. */
  19760. getBoundingInfo(): BoundingInfo;
  19761. /**
  19762. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19763. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19764. * @returns the current mesh
  19765. */
  19766. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19767. /**
  19768. * Overwrite the current bounding info
  19769. * @param boundingInfo defines the new bounding info
  19770. * @returns the current mesh
  19771. */
  19772. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19773. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19774. readonly useBones: boolean;
  19775. /** @hidden */
  19776. _preActivate(): void;
  19777. /** @hidden */
  19778. _preActivateForIntermediateRendering(renderId: number): void;
  19779. /** @hidden */
  19780. _activate(renderId: number): void;
  19781. /**
  19782. * Gets the current world matrix
  19783. * @returns a Matrix
  19784. */
  19785. getWorldMatrix(): Matrix;
  19786. /** @hidden */
  19787. _getWorldMatrixDeterminant(): number;
  19788. /**
  19789. * Perform relative position change from the point of view of behind the front of the mesh.
  19790. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19791. * Supports definition of mesh facing forward or backward
  19792. * @param amountRight defines the distance on the right axis
  19793. * @param amountUp defines the distance on the up axis
  19794. * @param amountForward defines the distance on the forward axis
  19795. * @returns the current mesh
  19796. */
  19797. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19798. /**
  19799. * Calculate relative position change from the point of view of behind the front of the mesh.
  19800. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19801. * Supports definition of mesh facing forward or backward
  19802. * @param amountRight defines the distance on the right axis
  19803. * @param amountUp defines the distance on the up axis
  19804. * @param amountForward defines the distance on the forward axis
  19805. * @returns the new displacement vector
  19806. */
  19807. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19808. /**
  19809. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19810. * Supports definition of mesh facing forward or backward
  19811. * @param flipBack defines the flip
  19812. * @param twirlClockwise defines the twirl
  19813. * @param tiltRight defines the tilt
  19814. * @returns the current mesh
  19815. */
  19816. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19817. /**
  19818. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19819. * Supports definition of mesh facing forward or backward.
  19820. * @param flipBack defines the flip
  19821. * @param twirlClockwise defines the twirl
  19822. * @param tiltRight defines the tilt
  19823. * @returns the new rotation vector
  19824. */
  19825. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19826. /**
  19827. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19828. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19829. * @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
  19830. * @returns the new bounding vectors
  19831. */
  19832. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19833. min: Vector3;
  19834. max: Vector3;
  19835. };
  19836. /** @hidden */
  19837. _updateBoundingInfo(): AbstractMesh;
  19838. /** @hidden */
  19839. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19840. /** @hidden */
  19841. protected _afterComputeWorldMatrix(): void;
  19842. /**
  19843. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19844. * A mesh is in the frustum if its bounding box intersects the frustum
  19845. * @param frustumPlanes defines the frustum to test
  19846. * @returns true if the mesh is in the frustum planes
  19847. */
  19848. isInFrustum(frustumPlanes: Plane[]): boolean;
  19849. /**
  19850. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19851. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19852. * @param frustumPlanes defines the frustum to test
  19853. * @returns true if the mesh is completely in the frustum planes
  19854. */
  19855. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19856. /**
  19857. * True if the mesh intersects another mesh or a SolidParticle object
  19858. * @param mesh defines a target mesh or SolidParticle to test
  19859. * @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)
  19860. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19861. * @returns true if there is an intersection
  19862. */
  19863. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19864. /**
  19865. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19866. * @param point defines the point to test
  19867. * @returns true if there is an intersection
  19868. */
  19869. intersectsPoint(point: Vector3): boolean;
  19870. /**
  19871. * Gets the current physics impostor
  19872. * @see http://doc.babylonjs.com/features/physics_engine
  19873. * @returns a physics impostor or null
  19874. */
  19875. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19876. /**
  19877. * Gets the position of the current mesh in camera space
  19878. * @param camera defines the camera to use
  19879. * @returns a position
  19880. */
  19881. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19882. /**
  19883. * Returns the distance from the mesh to the active camera
  19884. * @param camera defines the camera to use
  19885. * @returns the distance
  19886. */
  19887. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19888. /**
  19889. * Apply a physic impulse to the mesh
  19890. * @param force defines the force to apply
  19891. * @param contactPoint defines where to apply the force
  19892. * @returns the current mesh
  19893. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19894. */
  19895. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19896. /**
  19897. * Creates a physic joint between two meshes
  19898. * @param otherMesh defines the other mesh to use
  19899. * @param pivot1 defines the pivot to use on this mesh
  19900. * @param pivot2 defines the pivot to use on the other mesh
  19901. * @param options defines additional options (can be plugin dependent)
  19902. * @returns the current mesh
  19903. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19904. */
  19905. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19906. /**
  19907. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19909. */
  19910. checkCollisions: boolean;
  19911. /**
  19912. * Gets Collider object used to compute collisions (not physics)
  19913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19914. */
  19915. readonly collider: Collider;
  19916. /**
  19917. * Move the mesh using collision engine
  19918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19919. * @param displacement defines the requested displacement vector
  19920. * @returns the current mesh
  19921. */
  19922. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19923. private _onCollisionPositionChange;
  19924. /**
  19925. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19926. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19927. * @param maxCapacity defines the maximum size of each block (64 by default)
  19928. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19929. * @returns the new octree
  19930. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19932. */
  19933. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19934. /** @hidden */
  19935. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19936. /** @hidden */
  19937. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19938. /** @hidden */
  19939. _checkCollision(collider: Collider): AbstractMesh;
  19940. /** @hidden */
  19941. _generatePointsArray(): boolean;
  19942. /**
  19943. * Checks if the passed Ray intersects with the mesh
  19944. * @param ray defines the ray to use
  19945. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19946. * @returns the picking info
  19947. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19948. */
  19949. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19950. /**
  19951. * Clones the current mesh
  19952. * @param name defines the mesh name
  19953. * @param newParent defines the new mesh parent
  19954. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19955. * @returns the new mesh
  19956. */
  19957. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19958. /**
  19959. * Disposes all the submeshes of the current meshnp
  19960. * @returns the current mesh
  19961. */
  19962. releaseSubMeshes(): AbstractMesh;
  19963. /**
  19964. * Releases resources associated with this abstract mesh.
  19965. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19966. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19967. */
  19968. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19969. /**
  19970. * Adds the passed mesh as a child to the current mesh
  19971. * @param mesh defines the child mesh
  19972. * @returns the current mesh
  19973. */
  19974. addChild(mesh: AbstractMesh): AbstractMesh;
  19975. /**
  19976. * Removes the passed mesh from the current mesh children list
  19977. * @param mesh defines the child mesh
  19978. * @returns the current mesh
  19979. */
  19980. removeChild(mesh: AbstractMesh): AbstractMesh;
  19981. /** @hidden */
  19982. private _initFacetData;
  19983. /**
  19984. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19985. * This method can be called within the render loop.
  19986. * 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
  19987. * @returns the current mesh
  19988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19989. */
  19990. updateFacetData(): AbstractMesh;
  19991. /**
  19992. * Returns the facetLocalNormals array.
  19993. * The normals are expressed in the mesh local spac
  19994. * @returns an array of Vector3
  19995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19996. */
  19997. getFacetLocalNormals(): Vector3[];
  19998. /**
  19999. * Returns the facetLocalPositions array.
  20000. * The facet positions are expressed in the mesh local space
  20001. * @returns an array of Vector3
  20002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20003. */
  20004. getFacetLocalPositions(): Vector3[];
  20005. /**
  20006. * Returns the facetLocalPartioning array
  20007. * @returns an array of array of numbers
  20008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20009. */
  20010. getFacetLocalPartitioning(): number[][];
  20011. /**
  20012. * Returns the i-th facet position in the world system.
  20013. * This method allocates a new Vector3 per call
  20014. * @param i defines the facet index
  20015. * @returns a new Vector3
  20016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20017. */
  20018. getFacetPosition(i: number): Vector3;
  20019. /**
  20020. * Sets the reference Vector3 with the i-th facet position in the world system
  20021. * @param i defines the facet index
  20022. * @param ref defines the target vector
  20023. * @returns the current mesh
  20024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20025. */
  20026. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20027. /**
  20028. * Returns the i-th facet normal in the world system.
  20029. * This method allocates a new Vector3 per call
  20030. * @param i defines the facet index
  20031. * @returns a new Vector3
  20032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20033. */
  20034. getFacetNormal(i: number): Vector3;
  20035. /**
  20036. * Sets the reference Vector3 with the i-th facet normal in the world system
  20037. * @param i defines the facet index
  20038. * @param ref defines the target vector
  20039. * @returns the current mesh
  20040. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20041. */
  20042. getFacetNormalToRef(i: number, ref: Vector3): this;
  20043. /**
  20044. * 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)
  20045. * @param x defines x coordinate
  20046. * @param y defines y coordinate
  20047. * @param z defines z coordinate
  20048. * @returns the array of facet indexes
  20049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20050. */
  20051. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20052. /**
  20053. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20054. * @param projected sets as the (x,y,z) world projection on the facet
  20055. * @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
  20056. * @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
  20057. * @param x defines x coordinate
  20058. * @param y defines y coordinate
  20059. * @param z defines z coordinate
  20060. * @returns the face index if found (or null instead)
  20061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20062. */
  20063. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20064. /**
  20065. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20066. * @param projected sets as the (x,y,z) local projection on the facet
  20067. * @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
  20068. * @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
  20069. * @param x defines x coordinate
  20070. * @param y defines y coordinate
  20071. * @param z defines z coordinate
  20072. * @returns the face index if found (or null instead)
  20073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20074. */
  20075. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20076. /**
  20077. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20078. * @returns the parameters
  20079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20080. */
  20081. getFacetDataParameters(): any;
  20082. /**
  20083. * Disables the feature FacetData and frees the related memory
  20084. * @returns the current mesh
  20085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20086. */
  20087. disableFacetData(): AbstractMesh;
  20088. /**
  20089. * Updates the AbstractMesh indices array
  20090. * @param indices defines the data source
  20091. * @returns the current mesh
  20092. */
  20093. updateIndices(indices: IndicesArray): AbstractMesh;
  20094. /**
  20095. * Creates new normals data for the mesh
  20096. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20097. * @returns the current mesh
  20098. */
  20099. createNormals(updatable: boolean): AbstractMesh;
  20100. /**
  20101. * Align the mesh with a normal
  20102. * @param normal defines the normal to use
  20103. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20104. * @returns the current mesh
  20105. */
  20106. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20107. /** @hidden */
  20108. _checkOcclusionQuery(): void;
  20109. }
  20110. }
  20111. declare module BABYLON {
  20112. class Buffer {
  20113. private _engine;
  20114. private _buffer;
  20115. /** @hidden */
  20116. _data: Nullable<DataArray>;
  20117. private _updatable;
  20118. private _instanced;
  20119. /**
  20120. * Gets the byte stride.
  20121. */
  20122. readonly byteStride: number;
  20123. /**
  20124. * Constructor
  20125. * @param engine the engine
  20126. * @param data the data to use for this buffer
  20127. * @param updatable whether the data is updatable
  20128. * @param stride the stride (optional)
  20129. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20130. * @param instanced whether the buffer is instanced (optional)
  20131. * @param useBytes set to true if the stride in in bytes (optional)
  20132. */
  20133. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20134. /**
  20135. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20136. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20137. * @param offset defines offset in the buffer (0 by default)
  20138. * @param size defines the size in floats of attributes (position is 3 for instance)
  20139. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20140. * @param instanced defines if the vertex buffer contains indexed data
  20141. * @param useBytes defines if the offset and stride are in bytes
  20142. * @returns the new vertex buffer
  20143. */
  20144. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20145. isUpdatable(): boolean;
  20146. getData(): Nullable<DataArray>;
  20147. getBuffer(): Nullable<WebGLBuffer>;
  20148. /**
  20149. * Gets the stride in float32 units (i.e. byte stride / 4).
  20150. * May not be an integer if the byte stride is not divisible by 4.
  20151. * DEPRECATED. Use byteStride instead.
  20152. * @returns the stride in float32 units
  20153. */
  20154. getStrideSize(): number;
  20155. create(data?: Nullable<DataArray>): void;
  20156. /** @hidden */
  20157. _rebuild(): void;
  20158. update(data: DataArray): void;
  20159. /**
  20160. * Updates the data directly.
  20161. * @param data the new data
  20162. * @param offset the new offset
  20163. * @param vertexCount the vertex count (optional)
  20164. * @param useBytes set to true if the offset is in bytes
  20165. */
  20166. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20167. dispose(): void;
  20168. }
  20169. }
  20170. declare module BABYLON {
  20171. class CSG {
  20172. private polygons;
  20173. matrix: Matrix;
  20174. position: Vector3;
  20175. rotation: Vector3;
  20176. rotationQuaternion: Nullable<Quaternion>;
  20177. scaling: Vector3;
  20178. static FromMesh(mesh: Mesh): CSG;
  20179. private static FromPolygons;
  20180. clone(): CSG;
  20181. union(csg: CSG): CSG;
  20182. unionInPlace(csg: CSG): void;
  20183. subtract(csg: CSG): CSG;
  20184. subtractInPlace(csg: CSG): void;
  20185. intersect(csg: CSG): CSG;
  20186. intersectInPlace(csg: CSG): void;
  20187. inverse(): CSG;
  20188. inverseInPlace(): void;
  20189. copyTransformAttributes(csg: CSG): CSG;
  20190. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20191. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20192. }
  20193. }
  20194. declare module BABYLON {
  20195. /**
  20196. * Class used to store geometry data (vertex buffers + index buffer)
  20197. */
  20198. class Geometry implements IGetSetVerticesData {
  20199. /**
  20200. * Gets or sets the unique ID of the geometry
  20201. */
  20202. id: string;
  20203. /**
  20204. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20205. */
  20206. delayLoadState: number;
  20207. /**
  20208. * Gets the file containing the data to load when running in delay load state
  20209. */
  20210. delayLoadingFile: Nullable<string>;
  20211. /**
  20212. * Callback called when the geometry is updated
  20213. */
  20214. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20215. private _scene;
  20216. private _engine;
  20217. private _meshes;
  20218. private _totalVertices;
  20219. /** @hidden */
  20220. _indices: IndicesArray;
  20221. /** @hidden */
  20222. _vertexBuffers: {
  20223. [key: string]: VertexBuffer;
  20224. };
  20225. private _isDisposed;
  20226. private _extend;
  20227. private _boundingBias;
  20228. /** @hidden */
  20229. _delayInfo: Array<string>;
  20230. private _indexBuffer;
  20231. private _indexBufferIsUpdatable;
  20232. /** @hidden */
  20233. _boundingInfo: Nullable<BoundingInfo>;
  20234. /** @hidden */
  20235. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20236. /** @hidden */
  20237. _softwareSkinningRenderId: number;
  20238. private _vertexArrayObjects;
  20239. private _updatable;
  20240. /** @hidden */
  20241. _positions: Nullable<Vector3[]>;
  20242. /**
  20243. * 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
  20244. */
  20245. /**
  20246. * 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
  20247. */
  20248. boundingBias: Vector2;
  20249. /**
  20250. * Static function used to attach a new empty geometry to a mesh
  20251. * @param mesh defines the mesh to attach the geometry to
  20252. * @returns the new {BABYLON.Geometry}
  20253. */
  20254. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20255. /**
  20256. * Creates a new geometry
  20257. * @param id defines the unique ID
  20258. * @param scene defines the hosting scene
  20259. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20260. * @param updatable defines if geometry must be updatable (false by default)
  20261. * @param mesh defines the mesh that will be associated with the geometry
  20262. */
  20263. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20264. /**
  20265. * Gets the current extend of the geometry
  20266. */
  20267. readonly extend: {
  20268. minimum: Vector3;
  20269. maximum: Vector3;
  20270. };
  20271. /**
  20272. * Gets the hosting scene
  20273. * @returns the hosting {BABYLON.Scene}
  20274. */
  20275. getScene(): Scene;
  20276. /**
  20277. * Gets the hosting engine
  20278. * @returns the hosting {BABYLON.Engine}
  20279. */
  20280. getEngine(): Engine;
  20281. /**
  20282. * Defines if the geometry is ready to use
  20283. * @returns true if the geometry is ready to be used
  20284. */
  20285. isReady(): boolean;
  20286. /**
  20287. * Gets a value indicating that the geometry should not be serialized
  20288. */
  20289. readonly doNotSerialize: boolean;
  20290. /** @hidden */
  20291. _rebuild(): void;
  20292. /**
  20293. * Affects all geometry data in one call
  20294. * @param vertexData defines the geometry data
  20295. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20296. */
  20297. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20298. /**
  20299. * Set specific vertex data
  20300. * @param kind defines the data kind (Position, normal, etc...)
  20301. * @param data defines the vertex data to use
  20302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20304. */
  20305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20306. /**
  20307. * Removes a specific vertex data
  20308. * @param kind defines the data kind (Position, normal, etc...)
  20309. */
  20310. removeVerticesData(kind: string): void;
  20311. /**
  20312. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20313. * @param buffer defines the vertex buffer to use
  20314. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20315. */
  20316. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20317. /**
  20318. * Update a specific vertex buffer
  20319. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20320. * It will do nothing if the buffer is not updatable
  20321. * @param kind defines the data kind (Position, normal, etc...)
  20322. * @param data defines the data to use
  20323. * @param offset defines the offset in the target buffer where to store the data
  20324. * @param useBytes set to true if the offset is in bytes
  20325. */
  20326. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20327. /**
  20328. * Update a specific vertex buffer
  20329. * This function will create a new buffer if the current one is not updatable
  20330. * @param kind defines the data kind (Position, normal, etc...)
  20331. * @param data defines the data to use
  20332. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20333. */
  20334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20335. private _updateBoundingInfo;
  20336. /** @hidden */
  20337. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20338. /**
  20339. * Gets total number of vertices
  20340. * @returns the total number of vertices
  20341. */
  20342. getTotalVertices(): number;
  20343. /**
  20344. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20345. * @param kind defines the data kind (Position, normal, etc...)
  20346. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20348. * @returns a float array containing vertex data
  20349. */
  20350. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20351. /**
  20352. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20353. * @param kind defines the data kind (Position, normal, etc...)
  20354. * @returns true if the vertex buffer with the specified kind is updatable
  20355. */
  20356. isVertexBufferUpdatable(kind: string): boolean;
  20357. /**
  20358. * Gets a specific vertex buffer
  20359. * @param kind defines the data kind (Position, normal, etc...)
  20360. * @returns a {BABYLON.VertexBuffer}
  20361. */
  20362. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20363. /**
  20364. * Returns all vertex buffers
  20365. * @return an object holding all vertex buffers indexed by kind
  20366. */
  20367. getVertexBuffers(): Nullable<{
  20368. [key: string]: VertexBuffer;
  20369. }>;
  20370. /**
  20371. * Gets a boolean indicating if specific vertex buffer is present
  20372. * @param kind defines the data kind (Position, normal, etc...)
  20373. * @returns true if data is present
  20374. */
  20375. isVerticesDataPresent(kind: string): boolean;
  20376. /**
  20377. * Gets a list of all attached data kinds (Position, normal, etc...)
  20378. * @returns a list of string containing all kinds
  20379. */
  20380. getVerticesDataKinds(): string[];
  20381. /**
  20382. * Update index buffer
  20383. * @param indices defines the indices to store in the index buffer
  20384. * @param offset defines the offset in the target buffer where to store the data
  20385. */
  20386. updateIndices(indices: IndicesArray, offset?: number): void;
  20387. /**
  20388. * Creates a new index buffer
  20389. * @param indices defines the indices to store in the index buffer
  20390. * @param totalVertices defines the total number of vertices (could be null)
  20391. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20392. */
  20393. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20394. /**
  20395. * Return the total number of indices
  20396. * @returns the total number of indices
  20397. */
  20398. getTotalIndices(): number;
  20399. /**
  20400. * Gets the index buffer array
  20401. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20402. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20403. * @returns the index buffer array
  20404. */
  20405. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20406. /**
  20407. * Gets the index buffer
  20408. * @return the index buffer
  20409. */
  20410. getIndexBuffer(): Nullable<WebGLBuffer>;
  20411. /** @hidden */
  20412. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20413. /**
  20414. * Release the associated resources for a specific mesh
  20415. * @param mesh defines the source mesh
  20416. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20417. */
  20418. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20419. /**
  20420. * Apply current geometry to a given mesh
  20421. * @param mesh defines the mesh to apply geometry to
  20422. */
  20423. applyToMesh(mesh: Mesh): void;
  20424. private _updateExtend;
  20425. private _applyToMesh;
  20426. private notifyUpdate;
  20427. /**
  20428. * Load the geometry if it was flagged as delay loaded
  20429. * @param scene defines the hosting scene
  20430. * @param onLoaded defines a callback called when the geometry is loaded
  20431. */
  20432. load(scene: Scene, onLoaded?: () => void): void;
  20433. private _queueLoad;
  20434. /**
  20435. * Invert the geometry to move from a right handed system to a left handed one.
  20436. */
  20437. toLeftHanded(): void;
  20438. /** @hidden */
  20439. _resetPointsArrayCache(): void;
  20440. /** @hidden */
  20441. _generatePointsArray(): boolean;
  20442. /**
  20443. * Gets a value indicating if the geometry is disposed
  20444. * @returns true if the geometry was disposed
  20445. */
  20446. isDisposed(): boolean;
  20447. private _disposeVertexArrayObjects;
  20448. /**
  20449. * Free all associated resources
  20450. */
  20451. dispose(): void;
  20452. /**
  20453. * Clone the current geometry into a new geometry
  20454. * @param id defines the unique ID of the new geometry
  20455. * @returns a new geometry object
  20456. */
  20457. copy(id: string): Geometry;
  20458. /**
  20459. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20460. * @return a JSON representation of the current geometry data (without the vertices data)
  20461. */
  20462. serialize(): any;
  20463. private toNumberArray;
  20464. /**
  20465. * Serialize all vertices data into a JSON oject
  20466. * @returns a JSON representation of the current geometry data
  20467. */
  20468. serializeVerticeData(): any;
  20469. /**
  20470. * Extracts a clone of a mesh geometry
  20471. * @param mesh defines the source mesh
  20472. * @param id defines the unique ID of the new geometry object
  20473. * @returns the new geometry object
  20474. */
  20475. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20476. /**
  20477. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20478. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20479. * Be aware Math.random() could cause collisions, but:
  20480. * "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"
  20481. * @returns a string containing a new GUID
  20482. */
  20483. static RandomId(): string;
  20484. /** @hidden */
  20485. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20486. private static _CleanMatricesWeights;
  20487. /**
  20488. * Create a new geometry from persisted data (Using .babylon file format)
  20489. * @param parsedVertexData defines the persisted data
  20490. * @param scene defines the hosting scene
  20491. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20492. * @returns the new geometry object
  20493. */
  20494. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20495. }
  20496. /**
  20497. * Abstract class used to provide common services for all typed geometries
  20498. * @hidden
  20499. */
  20500. class _PrimitiveGeometry extends Geometry {
  20501. private _canBeRegenerated;
  20502. private _beingRegenerated;
  20503. /**
  20504. * Creates a new typed geometry
  20505. * @param id defines the unique ID of the geometry
  20506. * @param scene defines the hosting scene
  20507. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20508. * @param mesh defines the hosting mesh (can be null)
  20509. */
  20510. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20511. /**
  20512. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20513. * @returns true if the geometry can be regenerated
  20514. */
  20515. canBeRegenerated(): boolean;
  20516. /**
  20517. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20518. */
  20519. regenerate(): void;
  20520. /**
  20521. * Clone the geometry
  20522. * @param id defines the unique ID of the new geometry
  20523. * @returns the new geometry
  20524. */
  20525. asNewGeometry(id: string): Geometry;
  20526. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20527. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20528. /** @hidden */
  20529. _regenerateVertexData(): VertexData;
  20530. copy(id: string): Geometry;
  20531. serialize(): any;
  20532. }
  20533. /**
  20534. * Creates a ribbon geometry
  20535. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20536. */
  20537. class RibbonGeometry extends _PrimitiveGeometry {
  20538. /**
  20539. * Defines the array of paths to use
  20540. */
  20541. pathArray: Vector3[][];
  20542. /**
  20543. * Defines if the last and first points of each path in your pathArray must be joined
  20544. */
  20545. closeArray: boolean;
  20546. /**
  20547. * Defines if the last and first points of each path in your pathArray must be joined
  20548. */
  20549. closePath: boolean;
  20550. /**
  20551. * Defines the offset between points
  20552. */
  20553. offset: number;
  20554. /**
  20555. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20556. */
  20557. side: number;
  20558. /**
  20559. * Creates a ribbon geometry
  20560. * @param id defines the unique ID of the geometry
  20561. * @param scene defines the hosting scene
  20562. * @param pathArray defines the array of paths to use
  20563. * @param closeArray defines if the last path and the first path must be joined
  20564. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20565. * @param offset defines the offset between points
  20566. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20567. * @param mesh defines the hosting mesh (can be null)
  20568. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20569. */
  20570. constructor(id: string, scene: Scene,
  20571. /**
  20572. * Defines the array of paths to use
  20573. */
  20574. pathArray: Vector3[][],
  20575. /**
  20576. * Defines if the last and first points of each path in your pathArray must be joined
  20577. */
  20578. closeArray: boolean,
  20579. /**
  20580. * Defines if the last and first points of each path in your pathArray must be joined
  20581. */
  20582. closePath: boolean,
  20583. /**
  20584. * Defines the offset between points
  20585. */
  20586. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20587. /**
  20588. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20589. */
  20590. side?: number);
  20591. /** @hidden */
  20592. _regenerateVertexData(): VertexData;
  20593. copy(id: string): Geometry;
  20594. }
  20595. /**
  20596. * Creates a box geometry
  20597. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20598. */
  20599. class BoxGeometry extends _PrimitiveGeometry {
  20600. /**
  20601. * Defines the zise of the box (width, height and depth are the same)
  20602. */
  20603. size: number;
  20604. /**
  20605. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20606. */
  20607. side: number;
  20608. /**
  20609. * Creates a box geometry
  20610. * @param id defines the unique ID of the geometry
  20611. * @param scene defines the hosting scene
  20612. * @param size defines the zise of the box (width, height and depth are the same)
  20613. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20614. * @param mesh defines the hosting mesh (can be null)
  20615. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20616. */
  20617. constructor(id: string, scene: Scene,
  20618. /**
  20619. * Defines the zise of the box (width, height and depth are the same)
  20620. */
  20621. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20622. /**
  20623. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20624. */
  20625. side?: number);
  20626. /** @hidden */
  20627. _regenerateVertexData(): VertexData;
  20628. copy(id: string): Geometry;
  20629. serialize(): any;
  20630. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20631. }
  20632. /**
  20633. * Creates a sphere geometry
  20634. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20635. */
  20636. class SphereGeometry extends _PrimitiveGeometry {
  20637. /**
  20638. * Defines the number of segments to use to create the sphere
  20639. */
  20640. segments: number;
  20641. /**
  20642. * Defines the diameter of the sphere
  20643. */
  20644. diameter: number;
  20645. /**
  20646. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20647. */
  20648. side: number;
  20649. /**
  20650. * Create a new sphere geometry
  20651. * @param id defines the unique ID of the geometry
  20652. * @param scene defines the hosting scene
  20653. * @param segments defines the number of segments to use to create the sphere
  20654. * @param diameter defines the diameter of the sphere
  20655. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20656. * @param mesh defines the hosting mesh (can be null)
  20657. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20658. */
  20659. constructor(id: string, scene: Scene,
  20660. /**
  20661. * Defines the number of segments to use to create the sphere
  20662. */
  20663. segments: number,
  20664. /**
  20665. * Defines the diameter of the sphere
  20666. */
  20667. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20668. /**
  20669. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20670. */
  20671. side?: number);
  20672. /** @hidden */
  20673. _regenerateVertexData(): VertexData;
  20674. copy(id: string): Geometry;
  20675. serialize(): any;
  20676. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20677. }
  20678. /**
  20679. * Creates a disc geometry
  20680. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20681. */
  20682. class DiscGeometry extends _PrimitiveGeometry {
  20683. /**
  20684. * Defines the radius of the disc
  20685. */
  20686. radius: number;
  20687. /**
  20688. * Defines the tesselation factor to apply to the disc
  20689. */
  20690. tessellation: number;
  20691. /**
  20692. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20693. */
  20694. side: number;
  20695. /**
  20696. * Creates a new disc geometry
  20697. * @param id defines the unique ID of the geometry
  20698. * @param scene defines the hosting scene
  20699. * @param radius defines the radius of the disc
  20700. * @param tessellation defines the tesselation factor to apply to the disc
  20701. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20702. * @param mesh defines the hosting mesh (can be null)
  20703. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20704. */
  20705. constructor(id: string, scene: Scene,
  20706. /**
  20707. * Defines the radius of the disc
  20708. */
  20709. radius: number,
  20710. /**
  20711. * Defines the tesselation factor to apply to the disc
  20712. */
  20713. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20714. /**
  20715. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20716. */
  20717. side?: number);
  20718. /** @hidden */
  20719. _regenerateVertexData(): VertexData;
  20720. copy(id: string): Geometry;
  20721. }
  20722. /**
  20723. * Creates a new cylinder geometry
  20724. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20725. */
  20726. class CylinderGeometry extends _PrimitiveGeometry {
  20727. /**
  20728. * Defines the height of the cylinder
  20729. */
  20730. height: number;
  20731. /**
  20732. * Defines the diameter of the cylinder's top cap
  20733. */
  20734. diameterTop: number;
  20735. /**
  20736. * Defines the diameter of the cylinder's bottom cap
  20737. */
  20738. diameterBottom: number;
  20739. /**
  20740. * Defines the tessellation factor to apply to the cylinder
  20741. */
  20742. tessellation: number;
  20743. /**
  20744. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20745. */
  20746. subdivisions: number;
  20747. /**
  20748. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20749. */
  20750. side: number;
  20751. /**
  20752. * Creates a new cylinder geometry
  20753. * @param id defines the unique ID of the geometry
  20754. * @param scene defines the hosting scene
  20755. * @param height defines the height of the cylinder
  20756. * @param diameterTop defines the diameter of the cylinder's top cap
  20757. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20758. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20759. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20760. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20761. * @param mesh defines the hosting mesh (can be null)
  20762. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20763. */
  20764. constructor(id: string, scene: Scene,
  20765. /**
  20766. * Defines the height of the cylinder
  20767. */
  20768. height: number,
  20769. /**
  20770. * Defines the diameter of the cylinder's top cap
  20771. */
  20772. diameterTop: number,
  20773. /**
  20774. * Defines the diameter of the cylinder's bottom cap
  20775. */
  20776. diameterBottom: number,
  20777. /**
  20778. * Defines the tessellation factor to apply to the cylinder
  20779. */
  20780. tessellation: number,
  20781. /**
  20782. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20783. */
  20784. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20785. /**
  20786. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20787. */
  20788. side?: number);
  20789. /** @hidden */
  20790. _regenerateVertexData(): VertexData;
  20791. copy(id: string): Geometry;
  20792. serialize(): any;
  20793. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20794. }
  20795. /**
  20796. * Creates a new torus geometry
  20797. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20798. */
  20799. class TorusGeometry extends _PrimitiveGeometry {
  20800. /**
  20801. * Defines the diameter of the torus
  20802. */
  20803. diameter: number;
  20804. /**
  20805. * Defines the thickness of the torus (ie. internal diameter)
  20806. */
  20807. thickness: number;
  20808. /**
  20809. * Defines the tesselation factor to apply to the torus
  20810. */
  20811. tessellation: number;
  20812. /**
  20813. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20814. */
  20815. side: number;
  20816. /**
  20817. * Creates a new torus geometry
  20818. * @param id defines the unique ID of the geometry
  20819. * @param scene defines the hosting scene
  20820. * @param diameter defines the diameter of the torus
  20821. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20822. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20823. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20824. * @param mesh defines the hosting mesh (can be null)
  20825. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20826. */
  20827. constructor(id: string, scene: Scene,
  20828. /**
  20829. * Defines the diameter of the torus
  20830. */
  20831. diameter: number,
  20832. /**
  20833. * Defines the thickness of the torus (ie. internal diameter)
  20834. */
  20835. thickness: number,
  20836. /**
  20837. * Defines the tesselation factor to apply to the torus
  20838. */
  20839. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20840. /**
  20841. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20842. */
  20843. side?: number);
  20844. /** @hidden */
  20845. _regenerateVertexData(): VertexData;
  20846. copy(id: string): Geometry;
  20847. serialize(): any;
  20848. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20849. }
  20850. /**
  20851. * Creates a new ground geometry
  20852. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20853. */
  20854. class GroundGeometry extends _PrimitiveGeometry {
  20855. /**
  20856. * Defines the width of the ground
  20857. */
  20858. width: number;
  20859. /**
  20860. * Defines the height of the ground
  20861. */
  20862. height: number;
  20863. /**
  20864. * Defines the subdivisions to apply to the ground
  20865. */
  20866. subdivisions: number;
  20867. /**
  20868. * Creates a new ground geometry
  20869. * @param id defines the unique ID of the geometry
  20870. * @param scene defines the hosting scene
  20871. * @param width defines the width of the ground
  20872. * @param height defines the height of the ground
  20873. * @param subdivisions defines the subdivisions to apply to the ground
  20874. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20875. * @param mesh defines the hosting mesh (can be null)
  20876. */
  20877. constructor(id: string, scene: Scene,
  20878. /**
  20879. * Defines the width of the ground
  20880. */
  20881. width: number,
  20882. /**
  20883. * Defines the height of the ground
  20884. */
  20885. height: number,
  20886. /**
  20887. * Defines the subdivisions to apply to the ground
  20888. */
  20889. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20890. /** @hidden */
  20891. _regenerateVertexData(): VertexData;
  20892. copy(id: string): Geometry;
  20893. serialize(): any;
  20894. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20895. }
  20896. /**
  20897. * Creates a tiled ground geometry
  20898. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20899. */
  20900. class TiledGroundGeometry extends _PrimitiveGeometry {
  20901. /**
  20902. * Defines the minimum value on X axis
  20903. */
  20904. xmin: number;
  20905. /**
  20906. * Defines the minimum value on Z axis
  20907. */
  20908. zmin: number;
  20909. /**
  20910. * Defines the maximum value on X axis
  20911. */
  20912. xmax: number;
  20913. /**
  20914. * Defines the maximum value on Z axis
  20915. */
  20916. zmax: number;
  20917. /**
  20918. * Defines the subdivisions to apply to the ground
  20919. */
  20920. subdivisions: {
  20921. w: number;
  20922. h: number;
  20923. };
  20924. /**
  20925. * Defines the precision to use when computing the tiles
  20926. */
  20927. precision: {
  20928. w: number;
  20929. h: number;
  20930. };
  20931. /**
  20932. * Creates a tiled ground geometry
  20933. * @param id defines the unique ID of the geometry
  20934. * @param scene defines the hosting scene
  20935. * @param xmin defines the minimum value on X axis
  20936. * @param zmin defines the minimum value on Z axis
  20937. * @param xmax defines the maximum value on X axis
  20938. * @param zmax defines the maximum value on Z axis
  20939. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20940. * @param precision defines the precision to use when computing the tiles
  20941. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20942. * @param mesh defines the hosting mesh (can be null)
  20943. */
  20944. constructor(id: string, scene: Scene,
  20945. /**
  20946. * Defines the minimum value on X axis
  20947. */
  20948. xmin: number,
  20949. /**
  20950. * Defines the minimum value on Z axis
  20951. */
  20952. zmin: number,
  20953. /**
  20954. * Defines the maximum value on X axis
  20955. */
  20956. xmax: number,
  20957. /**
  20958. * Defines the maximum value on Z axis
  20959. */
  20960. zmax: number,
  20961. /**
  20962. * Defines the subdivisions to apply to the ground
  20963. */
  20964. subdivisions: {
  20965. w: number;
  20966. h: number;
  20967. },
  20968. /**
  20969. * Defines the precision to use when computing the tiles
  20970. */
  20971. precision: {
  20972. w: number;
  20973. h: number;
  20974. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20975. /** @hidden */
  20976. _regenerateVertexData(): VertexData;
  20977. copy(id: string): Geometry;
  20978. }
  20979. /**
  20980. * Creates a plane geometry
  20981. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20982. */
  20983. class PlaneGeometry extends _PrimitiveGeometry {
  20984. /**
  20985. * Defines the size of the plane (width === height)
  20986. */
  20987. size: number;
  20988. /**
  20989. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20990. */
  20991. side: number;
  20992. /**
  20993. * Creates a plane geometry
  20994. * @param id defines the unique ID of the geometry
  20995. * @param scene defines the hosting scene
  20996. * @param size defines the size of the plane (width === height)
  20997. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20998. * @param mesh defines the hosting mesh (can be null)
  20999. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21000. */
  21001. constructor(id: string, scene: Scene,
  21002. /**
  21003. * Defines the size of the plane (width === height)
  21004. */
  21005. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21006. /**
  21007. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21008. */
  21009. side?: number);
  21010. /** @hidden */
  21011. _regenerateVertexData(): VertexData;
  21012. copy(id: string): Geometry;
  21013. serialize(): any;
  21014. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21015. }
  21016. /**
  21017. * Creates a torus knot geometry
  21018. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21019. */
  21020. class TorusKnotGeometry extends _PrimitiveGeometry {
  21021. /**
  21022. * Defines the radius of the torus knot
  21023. */
  21024. radius: number;
  21025. /**
  21026. * Defines the thickness of the torus knot tube
  21027. */
  21028. tube: number;
  21029. /**
  21030. * Defines the number of radial segments
  21031. */
  21032. radialSegments: number;
  21033. /**
  21034. * Defines the number of tubular segments
  21035. */
  21036. tubularSegments: number;
  21037. /**
  21038. * Defines the first number of windings
  21039. */
  21040. p: number;
  21041. /**
  21042. * Defines the second number of windings
  21043. */
  21044. q: number;
  21045. /**
  21046. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21047. */
  21048. side: number;
  21049. /**
  21050. * Creates a torus knot geometry
  21051. * @param id defines the unique ID of the geometry
  21052. * @param scene defines the hosting scene
  21053. * @param radius defines the radius of the torus knot
  21054. * @param tube defines the thickness of the torus knot tube
  21055. * @param radialSegments defines the number of radial segments
  21056. * @param tubularSegments defines the number of tubular segments
  21057. * @param p defines the first number of windings
  21058. * @param q defines the second number of windings
  21059. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21060. * @param mesh defines the hosting mesh (can be null)
  21061. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21062. */
  21063. constructor(id: string, scene: Scene,
  21064. /**
  21065. * Defines the radius of the torus knot
  21066. */
  21067. radius: number,
  21068. /**
  21069. * Defines the thickness of the torus knot tube
  21070. */
  21071. tube: number,
  21072. /**
  21073. * Defines the number of radial segments
  21074. */
  21075. radialSegments: number,
  21076. /**
  21077. * Defines the number of tubular segments
  21078. */
  21079. tubularSegments: number,
  21080. /**
  21081. * Defines the first number of windings
  21082. */
  21083. p: number,
  21084. /**
  21085. * Defines the second number of windings
  21086. */
  21087. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21088. /**
  21089. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21090. */
  21091. side?: number);
  21092. /** @hidden */
  21093. _regenerateVertexData(): VertexData;
  21094. copy(id: string): Geometry;
  21095. serialize(): any;
  21096. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21097. }
  21098. }
  21099. declare module BABYLON {
  21100. class GroundMesh extends Mesh {
  21101. generateOctree: boolean;
  21102. private _heightQuads;
  21103. /** @hidden */
  21104. _subdivisionsX: number;
  21105. /** @hidden */
  21106. _subdivisionsY: number;
  21107. /** @hidden */
  21108. _width: number;
  21109. /** @hidden */
  21110. _height: number;
  21111. /** @hidden */
  21112. _minX: number;
  21113. /** @hidden */
  21114. _maxX: number;
  21115. /** @hidden */
  21116. _minZ: number;
  21117. /** @hidden */
  21118. _maxZ: number;
  21119. constructor(name: string, scene: Scene);
  21120. getClassName(): string;
  21121. readonly subdivisions: number;
  21122. readonly subdivisionsX: number;
  21123. readonly subdivisionsY: number;
  21124. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21125. /**
  21126. * Returns a height (y) value in the Worl system :
  21127. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21128. * Returns the ground y position if (x, z) are outside the ground surface.
  21129. */
  21130. getHeightAtCoordinates(x: number, z: number): number;
  21131. /**
  21132. * Returns a normalized vector (Vector3) orthogonal to the ground
  21133. * at the ground coordinates (x, z) expressed in the World system.
  21134. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21135. */
  21136. getNormalAtCoordinates(x: number, z: number): Vector3;
  21137. /**
  21138. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21139. * at the ground coordinates (x, z) expressed in the World system.
  21140. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21141. * Returns the GroundMesh.
  21142. */
  21143. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21144. /**
  21145. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21146. * if the ground has been updated.
  21147. * This can be used in the render loop.
  21148. * Returns the GroundMesh.
  21149. */
  21150. updateCoordinateHeights(): GroundMesh;
  21151. private _getFacetAt;
  21152. private _initHeightQuads;
  21153. private _computeHeightQuads;
  21154. serialize(serializationObject: any): void;
  21155. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21156. }
  21157. }
  21158. declare module BABYLON {
  21159. /**
  21160. * Creates an instance based on a source mesh.
  21161. */
  21162. class InstancedMesh extends AbstractMesh {
  21163. private _sourceMesh;
  21164. private _currentLOD;
  21165. constructor(name: string, source: Mesh);
  21166. /**
  21167. * Returns the string "InstancedMesh".
  21168. */
  21169. getClassName(): string;
  21170. readonly receiveShadows: boolean;
  21171. readonly material: Nullable<Material>;
  21172. readonly visibility: number;
  21173. readonly skeleton: Nullable<Skeleton>;
  21174. renderingGroupId: number;
  21175. /**
  21176. * Returns the total number of vertices (integer).
  21177. */
  21178. getTotalVertices(): number;
  21179. readonly sourceMesh: Mesh;
  21180. /**
  21181. * Is this node ready to be used/rendered
  21182. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21183. * @return {boolean} is it ready
  21184. */
  21185. isReady(completeCheck?: boolean): boolean;
  21186. /**
  21187. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21188. */
  21189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21190. /**
  21191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21193. * The `data` are either a numeric array either a Float32Array.
  21194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21195. * 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).
  21196. * Note that a new underlying VertexBuffer object is created each call.
  21197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21198. *
  21199. * Possible `kind` values :
  21200. * - BABYLON.VertexBuffer.PositionKind
  21201. * - BABYLON.VertexBuffer.UVKind
  21202. * - BABYLON.VertexBuffer.UV2Kind
  21203. * - BABYLON.VertexBuffer.UV3Kind
  21204. * - BABYLON.VertexBuffer.UV4Kind
  21205. * - BABYLON.VertexBuffer.UV5Kind
  21206. * - BABYLON.VertexBuffer.UV6Kind
  21207. * - BABYLON.VertexBuffer.ColorKind
  21208. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21209. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21210. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21211. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21212. *
  21213. * Returns the Mesh.
  21214. */
  21215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21216. /**
  21217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21218. * If the mesh has no geometry, it is simply returned as it is.
  21219. * The `data` are either a numeric array either a Float32Array.
  21220. * No new underlying VertexBuffer object is created.
  21221. * 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.
  21222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21223. *
  21224. * Possible `kind` values :
  21225. * - BABYLON.VertexBuffer.PositionKind
  21226. * - BABYLON.VertexBuffer.UVKind
  21227. * - BABYLON.VertexBuffer.UV2Kind
  21228. * - BABYLON.VertexBuffer.UV3Kind
  21229. * - BABYLON.VertexBuffer.UV4Kind
  21230. * - BABYLON.VertexBuffer.UV5Kind
  21231. * - BABYLON.VertexBuffer.UV6Kind
  21232. * - BABYLON.VertexBuffer.ColorKind
  21233. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21234. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21235. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21236. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21237. *
  21238. * Returns the Mesh.
  21239. */
  21240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21241. /**
  21242. * Sets the mesh indices.
  21243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21245. * This method creates a new index buffer each call.
  21246. * Returns the Mesh.
  21247. */
  21248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21249. /**
  21250. * Boolean : True if the mesh owns the requested kind of data.
  21251. */
  21252. isVerticesDataPresent(kind: string): boolean;
  21253. /**
  21254. * Returns an array of indices (IndicesArray).
  21255. */
  21256. getIndices(): Nullable<IndicesArray>;
  21257. readonly _positions: Nullable<Vector3[]>;
  21258. /**
  21259. * Sets a new updated BoundingInfo to the mesh.
  21260. * Returns the mesh.
  21261. */
  21262. refreshBoundingInfo(): InstancedMesh;
  21263. /** @hidden */
  21264. _preActivate(): InstancedMesh;
  21265. /** @hidden */
  21266. _activate(renderId: number): InstancedMesh;
  21267. /**
  21268. * Returns the current associated LOD AbstractMesh.
  21269. */
  21270. getLOD(camera: Camera): AbstractMesh;
  21271. /** @hidden */
  21272. _syncSubMeshes(): InstancedMesh;
  21273. /** @hidden */
  21274. _generatePointsArray(): boolean;
  21275. /**
  21276. * Creates a new InstancedMesh from the current mesh.
  21277. * - name (string) : the cloned mesh name
  21278. * - newParent (optional Node) : the optional Node to parent the clone to.
  21279. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21280. *
  21281. * Returns the clone.
  21282. */
  21283. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21284. /**
  21285. * Disposes the InstancedMesh.
  21286. * Returns nothing.
  21287. */
  21288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21289. }
  21290. }
  21291. declare module BABYLON {
  21292. class LinesMesh extends Mesh {
  21293. useVertexColor?: boolean | undefined;
  21294. useVertexAlpha?: boolean | undefined;
  21295. color: Color3;
  21296. alpha: number;
  21297. /**
  21298. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21299. * This margin is expressed in world space coordinates, so its value may vary.
  21300. * Default value is 0.1
  21301. * @returns the intersection Threshold value.
  21302. */
  21303. /**
  21304. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21305. * This margin is expressed in world space coordinates, so its value may vary.
  21306. * @param value the new threshold to apply
  21307. */
  21308. intersectionThreshold: number;
  21309. private _intersectionThreshold;
  21310. private _colorShader;
  21311. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21312. /**
  21313. * Returns the string "LineMesh"
  21314. */
  21315. getClassName(): string;
  21316. /**
  21317. * @hidden
  21318. */
  21319. /**
  21320. * @hidden
  21321. */
  21322. material: Material;
  21323. /**
  21324. * @hidden
  21325. */
  21326. readonly checkCollisions: boolean;
  21327. createInstance(name: string): InstancedMesh;
  21328. /** @hidden */
  21329. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21330. /** @hidden */
  21331. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21332. dispose(doNotRecurse?: boolean): void;
  21333. /**
  21334. * Returns a new LineMesh object cloned from the current one.
  21335. */
  21336. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21337. /**
  21338. * Enables the edge rendering mode on the mesh.
  21339. * This mode makes the mesh edges visible
  21340. * @param epsilon defines the maximal distance between two angles to detect a face
  21341. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21342. * @returns the currentAbstractMesh
  21343. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21344. */
  21345. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21346. }
  21347. }
  21348. declare module BABYLON {
  21349. /**
  21350. * @hidden
  21351. **/
  21352. class _InstancesBatch {
  21353. mustReturn: boolean;
  21354. visibleInstances: Nullable<InstancedMesh[]>[];
  21355. renderSelf: boolean[];
  21356. }
  21357. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21358. static _FRONTSIDE: number;
  21359. static _BACKSIDE: number;
  21360. static _DOUBLESIDE: number;
  21361. static _DEFAULTSIDE: number;
  21362. static _NO_CAP: number;
  21363. static _CAP_START: number;
  21364. static _CAP_END: number;
  21365. static _CAP_ALL: number;
  21366. /**
  21367. * Mesh side orientation : usually the external or front surface
  21368. */
  21369. static readonly FRONTSIDE: number;
  21370. /**
  21371. * Mesh side orientation : usually the internal or back surface
  21372. */
  21373. static readonly BACKSIDE: number;
  21374. /**
  21375. * Mesh side orientation : both internal and external or front and back surfaces
  21376. */
  21377. static readonly DOUBLESIDE: number;
  21378. /**
  21379. * Mesh side orientation : by default, `FRONTSIDE`
  21380. */
  21381. static readonly DEFAULTSIDE: number;
  21382. /**
  21383. * Mesh cap setting : no cap
  21384. */
  21385. static readonly NO_CAP: number;
  21386. /**
  21387. * Mesh cap setting : one cap at the beginning of the mesh
  21388. */
  21389. static readonly CAP_START: number;
  21390. /**
  21391. * Mesh cap setting : one cap at the end of the mesh
  21392. */
  21393. static readonly CAP_END: number;
  21394. /**
  21395. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21396. */
  21397. static readonly CAP_ALL: number;
  21398. private _onBeforeRenderObservable;
  21399. private _onAfterRenderObservable;
  21400. private _onBeforeDrawObservable;
  21401. /**
  21402. * An event triggered before rendering the mesh
  21403. */
  21404. readonly onBeforeRenderObservable: Observable<Mesh>;
  21405. /**
  21406. * An event triggered after rendering the mesh
  21407. */
  21408. readonly onAfterRenderObservable: Observable<Mesh>;
  21409. /**
  21410. * An event triggered before drawing the mesh
  21411. */
  21412. readonly onBeforeDrawObservable: Observable<Mesh>;
  21413. private _onBeforeDrawObserver;
  21414. onBeforeDraw: () => void;
  21415. delayLoadState: number;
  21416. instances: InstancedMesh[];
  21417. delayLoadingFile: string;
  21418. /** @hidden */
  21419. _binaryInfo: any;
  21420. private _LODLevels;
  21421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21422. private _morphTargetManager;
  21423. morphTargetManager: Nullable<MorphTargetManager>;
  21424. /** @hidden */
  21425. _geometry: Nullable<Geometry>;
  21426. /** @hidden */
  21427. _delayInfo: Array<string>;
  21428. /** @hidden */
  21429. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21430. /** @hidden */
  21431. _visibleInstances: any;
  21432. private _renderIdForInstances;
  21433. private _batchCache;
  21434. private _instancesBufferSize;
  21435. private _instancesBuffer;
  21436. private _instancesData;
  21437. private _overridenInstanceCount;
  21438. private _effectiveMaterial;
  21439. /** @hidden */
  21440. _shouldGenerateFlatShading: boolean;
  21441. private _preActivateId;
  21442. /** @hidden */
  21443. _originalBuilderSideOrientation: number;
  21444. overrideMaterialSideOrientation: Nullable<number>;
  21445. private _areNormalsFrozen;
  21446. private _sourcePositions;
  21447. private _sourceNormals;
  21448. private _source;
  21449. readonly source: Nullable<Mesh>;
  21450. isUnIndexed: boolean;
  21451. /**
  21452. * @constructor
  21453. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21454. * @param {Scene} scene The scene to add this mesh to.
  21455. * @param {Node} parent The parent of this mesh, if it has one
  21456. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21457. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21458. * When false, achieved by calling a clone(), also passing False.
  21459. * This will make creation of children, recursive.
  21460. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21461. */
  21462. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21463. /**
  21464. * Returns the string "Mesh".
  21465. */
  21466. getClassName(): string;
  21467. /**
  21468. * Returns a string.
  21469. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21470. */
  21471. toString(fullDetails?: boolean): string;
  21472. /** @hidden */
  21473. _unBindEffect(): void;
  21474. /**
  21475. * True if the mesh has some Levels Of Details (LOD).
  21476. * Returns a boolean.
  21477. */
  21478. readonly hasLODLevels: boolean;
  21479. /**
  21480. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21481. * @returns an array of {BABYLON.MeshLODLevel}
  21482. */
  21483. getLODLevels(): MeshLODLevel[];
  21484. private _sortLODLevels;
  21485. /**
  21486. * Add a mesh as LOD level triggered at the given distance.
  21487. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21488. * @param distance The distance from the center of the object to show this level
  21489. * @param mesh The mesh to be added as LOD level (can be null)
  21490. * @return This mesh (for chaining)
  21491. */
  21492. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21493. /**
  21494. * Returns the LOD level mesh at the passed distance or null if not found.
  21495. * It is related to the method `addLODLevel(distance, mesh)`.
  21496. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21497. * Returns an object Mesh or `null`.
  21498. */
  21499. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21500. /**
  21501. * Remove a mesh from the LOD array
  21502. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21503. * @param {Mesh} mesh The mesh to be removed.
  21504. * @return {Mesh} This mesh (for chaining)
  21505. */
  21506. removeLODLevel(mesh: Mesh): Mesh;
  21507. /**
  21508. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21509. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21510. */
  21511. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21512. /**
  21513. * Returns the mesh internal Geometry object.
  21514. */
  21515. readonly geometry: Nullable<Geometry>;
  21516. /**
  21517. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21518. */
  21519. getTotalVertices(): number;
  21520. /**
  21521. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21522. * 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.
  21523. * You can force the copy with forceCopy === true
  21524. * Returns null if the mesh has no geometry or no vertex buffer.
  21525. * Possible `kind` values :
  21526. * - BABYLON.VertexBuffer.PositionKind
  21527. * - BABYLON.VertexBuffer.UVKind
  21528. * - BABYLON.VertexBuffer.UV2Kind
  21529. * - BABYLON.VertexBuffer.UV3Kind
  21530. * - BABYLON.VertexBuffer.UV4Kind
  21531. * - BABYLON.VertexBuffer.UV5Kind
  21532. * - BABYLON.VertexBuffer.UV6Kind
  21533. * - BABYLON.VertexBuffer.ColorKind
  21534. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21535. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21536. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21537. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21538. */
  21539. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21540. /**
  21541. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21542. * Returns `null` if the mesh has no geometry.
  21543. * Possible `kind` values :
  21544. * - BABYLON.VertexBuffer.PositionKind
  21545. * - BABYLON.VertexBuffer.UVKind
  21546. * - BABYLON.VertexBuffer.UV2Kind
  21547. * - BABYLON.VertexBuffer.UV3Kind
  21548. * - BABYLON.VertexBuffer.UV4Kind
  21549. * - BABYLON.VertexBuffer.UV5Kind
  21550. * - BABYLON.VertexBuffer.UV6Kind
  21551. * - BABYLON.VertexBuffer.ColorKind
  21552. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21553. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21554. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21555. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21556. */
  21557. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21558. isVerticesDataPresent(kind: string): boolean;
  21559. /**
  21560. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21561. * Possible `kind` values :
  21562. * - BABYLON.VertexBuffer.PositionKind
  21563. * - BABYLON.VertexBuffer.UVKind
  21564. * - BABYLON.VertexBuffer.UV2Kind
  21565. * - BABYLON.VertexBuffer.UV3Kind
  21566. * - BABYLON.VertexBuffer.UV4Kind
  21567. * - BABYLON.VertexBuffer.UV5Kind
  21568. * - BABYLON.VertexBuffer.UV6Kind
  21569. * - BABYLON.VertexBuffer.ColorKind
  21570. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21571. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21572. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21573. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21574. */
  21575. isVertexBufferUpdatable(kind: string): boolean;
  21576. /**
  21577. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21578. * Possible `kind` values :
  21579. * - BABYLON.VertexBuffer.PositionKind
  21580. * - BABYLON.VertexBuffer.UVKind
  21581. * - BABYLON.VertexBuffer.UV2Kind
  21582. * - BABYLON.VertexBuffer.UV3Kind
  21583. * - BABYLON.VertexBuffer.UV4Kind
  21584. * - BABYLON.VertexBuffer.UV5Kind
  21585. * - BABYLON.VertexBuffer.UV6Kind
  21586. * - BABYLON.VertexBuffer.ColorKind
  21587. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21588. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21589. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21590. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21591. */
  21592. getVerticesDataKinds(): string[];
  21593. /**
  21594. * Returns a positive integer : the total number of indices in this mesh geometry.
  21595. * Returns zero if the mesh has no geometry.
  21596. */
  21597. getTotalIndices(): number;
  21598. /**
  21599. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21600. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21602. * @returns the indices array or an empty array if the mesh has no geometry
  21603. */
  21604. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21605. readonly isBlocked: boolean;
  21606. /**
  21607. * Determine if the current mesh is ready to be rendered
  21608. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21609. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21610. * @returns true if all associated assets are ready (material, textures, shaders)
  21611. */
  21612. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21613. /**
  21614. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21615. * This property is pertinent only for updatable parametric shapes.
  21616. */
  21617. readonly areNormalsFrozen: boolean;
  21618. /**
  21619. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21620. * It has no effect at all on other shapes.
  21621. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21622. * Returns the Mesh.
  21623. */
  21624. freezeNormals(): Mesh;
  21625. /**
  21626. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21627. * It has no effect at all on other shapes.
  21628. * It reactivates the mesh normals computation if it was previously frozen.
  21629. * Returns the Mesh.
  21630. */
  21631. unfreezeNormals(): Mesh;
  21632. /**
  21633. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21634. */
  21635. overridenInstanceCount: number;
  21636. /** @hidden */
  21637. _preActivate(): Mesh;
  21638. /** @hidden */
  21639. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21640. /** @hidden */
  21641. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21642. /**
  21643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21644. * This means the mesh underlying bounding box and sphere are recomputed.
  21645. * Returns the Mesh.
  21646. */
  21647. refreshBoundingInfo(): Mesh;
  21648. /** @hidden */
  21649. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21650. private _getPositionData;
  21651. /** @hidden */
  21652. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21653. subdivide(count: number): void;
  21654. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21655. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21656. /**
  21657. * Sets the mesh VertexBuffer.
  21658. * Returns the Mesh.
  21659. */
  21660. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21662. /**
  21663. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21664. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21665. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21666. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21667. * Returns the Mesh.
  21668. */
  21669. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21670. /**
  21671. * Creates a un-shared specific occurence of the geometry for the mesh.
  21672. * Returns the Mesh.
  21673. */
  21674. makeGeometryUnique(): Mesh;
  21675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21676. /**
  21677. * Update the current index buffer
  21678. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21679. * Returns the Mesh.
  21680. */
  21681. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21682. /**
  21683. * Invert the geometry to move from a right handed system to a left handed one.
  21684. * Returns the Mesh.
  21685. */
  21686. toLeftHanded(): Mesh;
  21687. /** @hidden */
  21688. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21689. /** @hidden */
  21690. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21691. /**
  21692. * Registers for this mesh a javascript function called just before the rendering process.
  21693. * This function is passed the current mesh.
  21694. * Return the Mesh.
  21695. */
  21696. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21697. /**
  21698. * Disposes a previously registered javascript function called before the rendering.
  21699. * This function is passed the current mesh.
  21700. * Returns the Mesh.
  21701. */
  21702. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21703. /**
  21704. * Registers for this mesh a javascript function called just after the rendering is complete.
  21705. * This function is passed the current mesh.
  21706. * Returns the Mesh.
  21707. */
  21708. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21709. /**
  21710. * Disposes a previously registered javascript function called after the rendering.
  21711. * This function is passed the current mesh.
  21712. * Return the Mesh.
  21713. */
  21714. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21715. /** @hidden */
  21716. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21717. /** @hidden */
  21718. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21719. /** @hidden */
  21720. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21721. /**
  21722. * 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
  21723. * @param subMesh defines the subMesh to render
  21724. * @param enableAlphaMode defines if alpha mode can be changed
  21725. * @returns the current mesh
  21726. */
  21727. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21728. private _onBeforeDraw;
  21729. /**
  21730. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21731. */
  21732. getEmittedParticleSystems(): IParticleSystem[];
  21733. /**
  21734. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21735. */
  21736. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21737. /**
  21738. * Normalize matrix weights so that all vertices have a total weight set to 1
  21739. */
  21740. cleanMatrixWeights(): void;
  21741. /** @hidden */
  21742. _checkDelayState(): Mesh;
  21743. private _queueLoad;
  21744. /**
  21745. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21746. * A mesh is in the frustum if its bounding box intersects the frustum
  21747. * @param frustumPlanes defines the frustum to test
  21748. * @returns true if the mesh is in the frustum planes
  21749. */
  21750. isInFrustum(frustumPlanes: Plane[]): boolean;
  21751. /**
  21752. * Sets the mesh material by the material or multiMaterial `id` property.
  21753. * The material `id` is a string identifying the material or the multiMaterial.
  21754. * This method returns the Mesh.
  21755. */
  21756. setMaterialByID(id: string): Mesh;
  21757. /**
  21758. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21759. */
  21760. getAnimatables(): IAnimatable[];
  21761. /**
  21762. * Modifies the mesh geometry according to the passed transformation matrix.
  21763. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21764. * The mesh normals are modified accordingly the same transformation.
  21765. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21766. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21767. * Returns the Mesh.
  21768. */
  21769. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21770. /**
  21771. * Modifies the mesh geometry according to its own current World Matrix.
  21772. * The mesh World Matrix is then reset.
  21773. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21774. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21775. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21776. * Returns the Mesh.
  21777. */
  21778. bakeCurrentTransformIntoVertices(): Mesh;
  21779. readonly _positions: Nullable<Vector3[]>;
  21780. /** @hidden */
  21781. _resetPointsArrayCache(): Mesh;
  21782. /** @hidden */
  21783. _generatePointsArray(): boolean;
  21784. /**
  21785. * Returns a new Mesh object generated from the current mesh properties.
  21786. * This method must not get confused with createInstance().
  21787. * The parameter `name` is a string, the name given to the new mesh.
  21788. * The optional parameter `newParent` can be any Node object (default `null`).
  21789. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21790. * 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.
  21791. */
  21792. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21793. /**
  21794. * Releases resources associated with this mesh.
  21795. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21796. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21797. */
  21798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21799. /**
  21800. * Modifies the mesh geometry according to a displacement map.
  21801. * 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.
  21802. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21803. * This method returns nothing.
  21804. * @param url is a string, the URL from the image file is to be downloaded.
  21805. * @param minHeight is the lower limit of the displacement.
  21806. * @param maxHeight is the upper limit of the displacement.
  21807. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21808. * @param uvOffset is an optional vector2 used to offset UV.
  21809. * @param uvScale is an optional vector2 used to scale UV.
  21810. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21811. * @returns the Mesh.
  21812. */
  21813. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21814. /**
  21815. * Modifies the mesh geometry according to a displacementMap buffer.
  21816. * 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.
  21817. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21818. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21819. * @param heightMapWidth is the width of the buffer image.
  21820. * @param heightMapHeight is the height of the buffer image.
  21821. * @param minHeight is the lower limit of the displacement.
  21822. * @param maxHeight is the upper limit of the displacement.
  21823. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21824. * @param uvOffset is an optional vector2 used to offset UV.
  21825. * @param uvScale is an optional vector2 used to scale UV.
  21826. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21827. * @returns the Mesh.
  21828. */
  21829. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21830. /**
  21831. * Modify the mesh to get a flat shading rendering.
  21832. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21833. * This method returns the Mesh.
  21834. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21835. */
  21836. convertToFlatShadedMesh(): Mesh;
  21837. /**
  21838. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21839. * In other words, more vertices, no more indices and a single bigger VBO.
  21840. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21841. * Returns the Mesh.
  21842. */
  21843. convertToUnIndexedMesh(): Mesh;
  21844. /**
  21845. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21846. * This method returns the Mesh.
  21847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21848. */
  21849. flipFaces(flipNormals?: boolean): Mesh;
  21850. /**
  21851. * Creates a new InstancedMesh object from the mesh model.
  21852. * An instance shares the same properties and the same material than its model.
  21853. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  21854. * Only these properties of each instance can then be set individually :
  21855. * - position
  21856. * - rotation
  21857. * - rotationQuaternion
  21858. * - setPivotMatrix
  21859. * - scaling
  21860. *
  21861. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21862. * Warning : this method is not supported for Line mesh and LineSystem
  21863. */
  21864. createInstance(name: string): InstancedMesh;
  21865. /**
  21866. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21867. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21868. * This method returns the Mesh.
  21869. */
  21870. synchronizeInstances(): Mesh;
  21871. /**
  21872. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21873. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21874. * This should be used together with the simplification to avoid disappearing triangles.
  21875. * Returns the Mesh.
  21876. * @param successCallback an optional success callback to be called after the optimization finished.
  21877. */
  21878. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21879. serialize(serializationObject: any): void;
  21880. /** @hidden */
  21881. _syncGeometryWithMorphTargetManager(): void;
  21882. /**
  21883. * Returns a new Mesh object parsed from the source provided.
  21884. * The parameter `parsedMesh` is the source.
  21885. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21886. */
  21887. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21888. /**
  21889. * Creates a ribbon mesh.
  21890. * Please consider using the same method from the MeshBuilder class instead.
  21891. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21892. *
  21893. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21894. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21895. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21896. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21897. * 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.
  21898. * 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.
  21899. * 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
  21900. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21901. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21902. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21903. */
  21904. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21905. /**
  21906. * Creates a plane polygonal mesh. By default, this is a disc.
  21907. * Please consider using the same method from the MeshBuilder class instead.
  21908. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21909. * 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.
  21910. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21911. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21912. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21913. */
  21914. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21915. /**
  21916. * Creates a box mesh.
  21917. * Please consider using the same method from the MeshBuilder class instead.
  21918. * The parameter `size` sets the size (float) of each box side (default 1).
  21919. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21920. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21921. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21922. */
  21923. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21924. /**
  21925. * Creates a sphere mesh.
  21926. * Please consider using the same method from the MeshBuilder class instead.
  21927. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21928. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21929. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21930. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21931. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21932. */
  21933. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21934. /**
  21935. * Creates a cylinder or a cone mesh.
  21936. * Please consider using the same method from the MeshBuilder class instead.
  21937. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21938. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21939. * 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.
  21940. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21941. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21942. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21943. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21944. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21945. */
  21946. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21947. /**
  21948. * Creates a torus mesh.
  21949. * Please consider using the same method from the MeshBuilder class instead.
  21950. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21951. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21952. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21953. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21954. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21955. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21956. */
  21957. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21958. /**
  21959. * Creates a torus knot mesh.
  21960. * Please consider using the same method from the MeshBuilder class instead.
  21961. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21962. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21963. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21964. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21965. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21966. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21967. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21968. */
  21969. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21970. /**
  21971. * Creates a line mesh.
  21972. * Please consider using the same method from the MeshBuilder class instead.
  21973. * 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.
  21974. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21975. * The parameter `points` is an array successive Vector3.
  21976. * 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
  21977. * When updating an instance, remember that only point positions can change, not the number of points.
  21978. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21979. */
  21980. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21981. /**
  21982. * Creates a dashed line mesh.
  21983. * Please consider using the same method from the MeshBuilder class instead.
  21984. * 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.
  21985. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21986. * The parameter `points` is an array successive Vector3.
  21987. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21988. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21989. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21990. * 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
  21991. * When updating an instance, remember that only point positions can change, not the number of points.
  21992. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21993. */
  21994. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21995. /**
  21996. * Creates a polygon mesh.
  21997. * Please consider using the same method from the MeshBuilder class instead.
  21998. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21999. * 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.
  22000. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22001. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22002. * Remember you can only change the shape positions, not their number when updating a polygon.
  22003. */
  22004. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22005. /**
  22006. * Creates an extruded polygon mesh, with depth in the Y direction.
  22007. * Please consider using the same method from the MeshBuilder class instead.
  22008. */
  22009. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22010. /**
  22011. * Creates an extruded shape mesh.
  22012. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22013. * Please consider using the same method from the MeshBuilder class instead.
  22014. *
  22015. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22016. * 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
  22017. * extruded along the Z axis.
  22018. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22019. * 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.
  22020. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22021. * 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
  22022. * 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
  22023. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22024. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22025. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22026. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22027. */
  22028. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22029. /**
  22030. * Creates an custom extruded shape mesh.
  22031. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22032. * Please consider using the same method from the MeshBuilder class instead.
  22033. *
  22034. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22035. * 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
  22036. * extruded along the Z axis.
  22037. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22038. * 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
  22039. * and the distance of this point from the begining of the path :
  22040. * ```javascript
  22041. * var rotationFunction = function(i, distance) {
  22042. * // do things
  22043. * return rotationValue; }
  22044. * ```
  22045. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22046. * 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
  22047. * and the distance of this point from the begining of the path :
  22048. * ```javascript
  22049. * var scaleFunction = function(i, distance) {
  22050. * // do things
  22051. * return scaleValue;}
  22052. * ```
  22053. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22054. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22055. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22056. * 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
  22057. * 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
  22058. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22059. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22060. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22061. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22062. */
  22063. 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;
  22064. /**
  22065. * Creates lathe mesh.
  22066. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22067. * Please consider using the same method from the MeshBuilder class instead.
  22068. * 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
  22069. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22070. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22071. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22072. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22073. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22074. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22075. */
  22076. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22077. /**
  22078. * Creates a plane mesh.
  22079. * Please consider using the same method from the MeshBuilder class instead.
  22080. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22081. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22082. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22083. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22084. */
  22085. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22086. /**
  22087. * Creates a ground mesh.
  22088. * Please consider using the same method from the MeshBuilder class instead.
  22089. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22090. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22092. */
  22093. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22094. /**
  22095. * Creates a tiled ground mesh.
  22096. * Please consider using the same method from the MeshBuilder class instead.
  22097. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22098. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22099. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22100. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22101. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22102. * numbers of subdivisions on the ground width and height of each tile.
  22103. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22104. */
  22105. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22106. w: number;
  22107. h: number;
  22108. }, precision: {
  22109. w: number;
  22110. h: number;
  22111. }, scene: Scene, updatable?: boolean): Mesh;
  22112. /**
  22113. * Creates a ground mesh from a height map.
  22114. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22115. * Please consider using the same method from the MeshBuilder class instead.
  22116. * The parameter `url` sets the URL of the height map image resource.
  22117. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22118. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22119. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22120. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22121. * 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).
  22122. * This function is passed the newly built mesh :
  22123. * ```javascript
  22124. * function(mesh) { // do things
  22125. * return; }
  22126. * ```
  22127. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22128. */
  22129. 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;
  22130. /**
  22131. * Creates a tube mesh.
  22132. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  22133. * Please consider using the same method from the MeshBuilder class instead.
  22134. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22135. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22136. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22137. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22138. * 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.
  22139. * It must return a radius value (positive float) :
  22140. * ```javascript
  22141. * var radiusFunction = function(i, distance) {
  22142. * // do things
  22143. * return radius; }
  22144. * ```
  22145. * 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
  22146. * 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
  22147. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22148. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22149. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22150. */
  22151. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22152. (i: number, distance: number): number;
  22153. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22154. /**
  22155. * Creates a polyhedron mesh.
  22156. * Please consider using the same method from the MeshBuilder class instead.
  22157. * 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
  22158. * to choose the wanted type.
  22159. * The parameter `size` (positive float, default 1) sets the polygon size.
  22160. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22161. * 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`.
  22162. * 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
  22163. * 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)`).
  22164. * 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
  22165. * 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.
  22166. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22167. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22168. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22169. */
  22170. static CreatePolyhedron(name: string, options: {
  22171. type?: number;
  22172. size?: number;
  22173. sizeX?: number;
  22174. sizeY?: number;
  22175. sizeZ?: number;
  22176. custom?: any;
  22177. faceUV?: Vector4[];
  22178. faceColors?: Color4[];
  22179. updatable?: boolean;
  22180. sideOrientation?: number;
  22181. }, scene: Scene): Mesh;
  22182. /**
  22183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22184. * Please consider using the same method from the MeshBuilder class instead.
  22185. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22186. * 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`).
  22187. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22188. * 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.
  22189. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22190. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22191. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22192. */
  22193. static CreateIcoSphere(name: string, options: {
  22194. radius?: number;
  22195. flat?: boolean;
  22196. subdivisions?: number;
  22197. sideOrientation?: number;
  22198. updatable?: boolean;
  22199. }, scene: Scene): Mesh;
  22200. /**
  22201. * Creates a decal mesh.
  22202. * Please consider using the same method from the MeshBuilder class instead.
  22203. * 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.
  22204. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22205. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22206. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22207. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22208. */
  22209. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22210. /**
  22211. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22212. */
  22213. setPositionsForCPUSkinning(): Float32Array;
  22214. /**
  22215. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22216. */
  22217. setNormalsForCPUSkinning(): Float32Array;
  22218. /**
  22219. * Updates the vertex buffer by applying transformation from the bones.
  22220. * Returns the Mesh.
  22221. *
  22222. * @param {skeleton} skeleton to apply
  22223. */
  22224. applySkeleton(skeleton: Skeleton): Mesh;
  22225. /**
  22226. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22227. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22228. */
  22229. static MinMax(meshes: AbstractMesh[]): {
  22230. min: Vector3;
  22231. max: Vector3;
  22232. };
  22233. /**
  22234. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22235. */
  22236. static Center(meshesOrMinMaxVector: {
  22237. min: Vector3;
  22238. max: Vector3;
  22239. } | AbstractMesh[]): Vector3;
  22240. /**
  22241. * Merge the array of meshes into a single mesh for performance reasons.
  22242. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22243. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22244. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22245. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22246. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22247. */
  22248. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22249. }
  22250. }
  22251. declare module BABYLON {
  22252. /**
  22253. * Define an interface for all classes that will get and set the data on vertices
  22254. */
  22255. interface IGetSetVerticesData {
  22256. isVerticesDataPresent(kind: string): boolean;
  22257. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22258. /**
  22259. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22260. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22262. * @returns the indices array or an empty array if the mesh has no geometry
  22263. */
  22264. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22265. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22266. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22267. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22268. }
  22269. /**
  22270. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22271. */
  22272. class VertexData {
  22273. /**
  22274. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22275. */
  22276. positions: Nullable<FloatArray>;
  22277. /**
  22278. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22279. */
  22280. normals: Nullable<FloatArray>;
  22281. /**
  22282. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22283. */
  22284. tangents: Nullable<FloatArray>;
  22285. /**
  22286. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22287. */
  22288. uvs: Nullable<FloatArray>;
  22289. /**
  22290. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22291. */
  22292. uvs2: Nullable<FloatArray>;
  22293. /**
  22294. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22295. */
  22296. uvs3: Nullable<FloatArray>;
  22297. /**
  22298. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22299. */
  22300. uvs4: Nullable<FloatArray>;
  22301. /**
  22302. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22303. */
  22304. uvs5: Nullable<FloatArray>;
  22305. /**
  22306. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22307. */
  22308. uvs6: Nullable<FloatArray>;
  22309. /**
  22310. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22311. */
  22312. colors: Nullable<FloatArray>;
  22313. /**
  22314. * 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).
  22315. */
  22316. matricesIndices: Nullable<FloatArray>;
  22317. /**
  22318. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22319. */
  22320. matricesWeights: Nullable<FloatArray>;
  22321. /**
  22322. * An array extending the number of possible indices
  22323. */
  22324. matricesIndicesExtra: Nullable<FloatArray>;
  22325. /**
  22326. * An array extending the number of possible weights when the number of indices is extended
  22327. */
  22328. matricesWeightsExtra: Nullable<FloatArray>;
  22329. /**
  22330. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22331. */
  22332. indices: Nullable<IndicesArray>;
  22333. /**
  22334. * Uses the passed data array to set the set the values for the specified kind of data
  22335. * @param data a linear array of floating numbers
  22336. * @param kind the type of data that is being set, eg positions, colors etc
  22337. */
  22338. set(data: FloatArray, kind: string): void;
  22339. /**
  22340. * Associates the vertexData to the passed Mesh.
  22341. * Sets it as updatable or not (default `false`)
  22342. * @param mesh the mesh the vertexData is applied to
  22343. * @param updatable when used and having the value true allows new data to update the vertexData
  22344. * @returns the VertexData
  22345. */
  22346. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22347. /**
  22348. * Associates the vertexData to the passed Geometry.
  22349. * Sets it as updatable or not (default `false`)
  22350. * @param geometry the geometry the vertexData is applied to
  22351. * @param updatable when used and having the value true allows new data to update the vertexData
  22352. * @returns VertexData
  22353. */
  22354. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22355. /**
  22356. * Updates the associated mesh
  22357. * @param mesh the mesh to be updated
  22358. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22359. * @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
  22360. * @returns VertexData
  22361. */
  22362. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22363. /**
  22364. * Updates the associated geometry
  22365. * @param geometry the geometry to be updated
  22366. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22367. * @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
  22368. * @returns VertexData.
  22369. */
  22370. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22371. private _applyTo;
  22372. private _update;
  22373. /**
  22374. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22375. * @param matrix the transforming matrix
  22376. * @returns the VertexData
  22377. */
  22378. transform(matrix: Matrix): VertexData;
  22379. /**
  22380. * Merges the passed VertexData into the current one
  22381. * @param other the VertexData to be merged into the current one
  22382. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22383. * @returns the modified VertexData
  22384. */
  22385. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22386. private _mergeElement;
  22387. private _validate;
  22388. /**
  22389. * Serializes the VertexData
  22390. * @returns a serialized object
  22391. */
  22392. serialize(): any;
  22393. /**
  22394. * Extracts the vertexData from a mesh
  22395. * @param mesh the mesh from which to extract the VertexData
  22396. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22397. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22398. * @returns the object VertexData associated to the passed mesh
  22399. */
  22400. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22401. /**
  22402. * Extracts the vertexData from the geometry
  22403. * @param geometry the geometry from which to extract the VertexData
  22404. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22405. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22406. * @returns the object VertexData associated to the passed mesh
  22407. */
  22408. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22409. private static _ExtractFrom;
  22410. /**
  22411. * Creates the VertexData for a Ribbon
  22412. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22413. * * pathArray array of paths, each of which an array of successive Vector3
  22414. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22415. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22416. * * 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
  22417. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22418. * * 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)
  22419. * * 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)
  22420. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22421. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22422. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22423. * @returns the VertexData of the ribbon
  22424. */
  22425. static CreateRibbon(options: {
  22426. pathArray: Vector3[][];
  22427. closeArray?: boolean;
  22428. closePath?: boolean;
  22429. offset?: number;
  22430. sideOrientation?: number;
  22431. frontUVs?: Vector4;
  22432. backUVs?: Vector4;
  22433. invertUV?: boolean;
  22434. uvs?: Vector2[];
  22435. colors?: Color4[];
  22436. }): VertexData;
  22437. /**
  22438. * Creates the VertexData for a box
  22439. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22440. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22441. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22442. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22443. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22444. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22445. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22446. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22447. * * 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)
  22448. * * 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)
  22449. * @returns the VertexData of the box
  22450. */
  22451. static CreateBox(options: {
  22452. size?: number;
  22453. width?: number;
  22454. height?: number;
  22455. depth?: number;
  22456. faceUV?: Vector4[];
  22457. faceColors?: Color4[];
  22458. sideOrientation?: number;
  22459. frontUVs?: Vector4;
  22460. backUVs?: Vector4;
  22461. }): VertexData;
  22462. /**
  22463. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22464. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22465. * * segments sets the number of horizontal strips optional, default 32
  22466. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22467. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22468. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22469. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22470. * * 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
  22471. * * 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
  22472. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22473. * * 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)
  22474. * * 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)
  22475. * @returns the VertexData of the ellipsoid
  22476. */
  22477. static CreateSphere(options: {
  22478. segments?: number;
  22479. diameter?: number;
  22480. diameterX?: number;
  22481. diameterY?: number;
  22482. diameterZ?: number;
  22483. arc?: number;
  22484. slice?: number;
  22485. sideOrientation?: number;
  22486. frontUVs?: Vector4;
  22487. backUVs?: Vector4;
  22488. }): VertexData;
  22489. /**
  22490. * Creates the VertexData for a cylinder, cone or prism
  22491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22492. * * height sets the height (y direction) of the cylinder, optional, default 2
  22493. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22494. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22495. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22496. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22497. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22498. * * 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
  22499. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22500. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22501. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22502. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22503. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * @returns the VertexData of the cylinder, cone or prism
  22507. */
  22508. static CreateCylinder(options: {
  22509. height?: number;
  22510. diameterTop?: number;
  22511. diameterBottom?: number;
  22512. diameter?: number;
  22513. tessellation?: number;
  22514. subdivisions?: number;
  22515. arc?: number;
  22516. faceColors?: Color4[];
  22517. faceUV?: Vector4[];
  22518. hasRings?: boolean;
  22519. enclose?: boolean;
  22520. sideOrientation?: number;
  22521. frontUVs?: Vector4;
  22522. backUVs?: Vector4;
  22523. }): VertexData;
  22524. /**
  22525. * Creates the VertexData for a torus
  22526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22527. * * diameter the diameter of the torus, optional default 1
  22528. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22529. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22530. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22531. * * 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)
  22532. * * 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)
  22533. * @returns the VertexData of the torus
  22534. */
  22535. static CreateTorus(options: {
  22536. diameter?: number;
  22537. thickness?: number;
  22538. tessellation?: number;
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData of the LineSystem
  22545. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22546. * - lines an array of lines, each line being an array of successive Vector3
  22547. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22548. * @returns the VertexData of the LineSystem
  22549. */
  22550. static CreateLineSystem(options: {
  22551. lines: Vector3[][];
  22552. colors?: Nullable<Color4[][]>;
  22553. }): VertexData;
  22554. /**
  22555. * Create the VertexData for a DashedLines
  22556. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22557. * - points an array successive Vector3
  22558. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22559. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22560. * - dashNb the intended total number of dashes, optional, default 200
  22561. * @returns the VertexData for the DashedLines
  22562. */
  22563. static CreateDashedLines(options: {
  22564. points: Vector3[];
  22565. dashSize?: number;
  22566. gapSize?: number;
  22567. dashNb?: number;
  22568. }): VertexData;
  22569. /**
  22570. * Creates the VertexData for a Ground
  22571. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22572. * - width the width (x direction) of the ground, optional, default 1
  22573. * - height the height (z direction) of the ground, optional, default 1
  22574. * - subdivisions the number of subdivisions per side, optional, default 1
  22575. * @returns the VertexData of the Ground
  22576. */
  22577. static CreateGround(options: {
  22578. width?: number;
  22579. height?: number;
  22580. subdivisions?: number;
  22581. subdivisionsX?: number;
  22582. subdivisionsY?: number;
  22583. }): VertexData;
  22584. /**
  22585. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22586. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22587. * * xmin the ground minimum X coordinate, optional, default -1
  22588. * * zmin the ground minimum Z coordinate, optional, default -1
  22589. * * xmax the ground maximum X coordinate, optional, default 1
  22590. * * zmax the ground maximum Z coordinate, optional, default 1
  22591. * * 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}
  22592. * * 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}
  22593. * @returns the VertexData of the TiledGround
  22594. */
  22595. static CreateTiledGround(options: {
  22596. xmin: number;
  22597. zmin: number;
  22598. xmax: number;
  22599. zmax: number;
  22600. subdivisions?: {
  22601. w: number;
  22602. h: number;
  22603. };
  22604. precision?: {
  22605. w: number;
  22606. h: number;
  22607. };
  22608. }): VertexData;
  22609. /**
  22610. * Creates the VertexData of the Ground designed from a heightmap
  22611. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22612. * * width the width (x direction) of the ground
  22613. * * height the height (z direction) of the ground
  22614. * * subdivisions the number of subdivisions per side
  22615. * * minHeight the minimum altitude on the ground, optional, default 0
  22616. * * maxHeight the maximum altitude on the ground, optional default 1
  22617. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22618. * * buffer the array holding the image color data
  22619. * * bufferWidth the width of image
  22620. * * bufferHeight the height of image
  22621. * @returns the VertexData of the Ground designed from a heightmap
  22622. */
  22623. static CreateGroundFromHeightMap(options: {
  22624. width: number;
  22625. height: number;
  22626. subdivisions: number;
  22627. minHeight: number;
  22628. maxHeight: number;
  22629. colorFilter: Color3;
  22630. buffer: Uint8Array;
  22631. bufferWidth: number;
  22632. bufferHeight: number;
  22633. }): VertexData;
  22634. /**
  22635. * Creates the VertexData for a Plane
  22636. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22637. * * size sets the width and height of the plane to the value of size, optional default 1
  22638. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22639. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22640. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22641. * * 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)
  22642. * * 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)
  22643. * @returns the VertexData of the box
  22644. */
  22645. static CreatePlane(options: {
  22646. size?: number;
  22647. width?: number;
  22648. height?: number;
  22649. sideOrientation?: number;
  22650. frontUVs?: Vector4;
  22651. backUVs?: Vector4;
  22652. }): VertexData;
  22653. /**
  22654. * Creates the VertexData of the Disc or regular Polygon
  22655. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22656. * * radius the radius of the disc, optional default 0.5
  22657. * * tessellation the number of polygon sides, optional, default 64
  22658. * * 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
  22659. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22660. * * 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)
  22661. * * 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)
  22662. * @returns the VertexData of the box
  22663. */
  22664. static CreateDisc(options: {
  22665. radius?: number;
  22666. tessellation?: number;
  22667. arc?: number;
  22668. sideOrientation?: number;
  22669. frontUVs?: Vector4;
  22670. backUVs?: Vector4;
  22671. }): VertexData;
  22672. /**
  22673. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22674. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22675. * @param polygon a mesh built from polygonTriangulation.build()
  22676. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22677. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22678. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22679. * @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)
  22680. * @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)
  22681. * @returns the VertexData of the Polygon
  22682. */
  22683. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22684. /**
  22685. * Creates the VertexData of the IcoSphere
  22686. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22687. * * radius the radius of the IcoSphere, optional default 1
  22688. * * radiusX allows stretching in the x direction, optional, default radius
  22689. * * radiusY allows stretching in the y direction, optional, default radius
  22690. * * radiusZ allows stretching in the z direction, optional, default radius
  22691. * * flat when true creates a flat shaded mesh, optional, default true
  22692. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22693. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22694. * * 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)
  22695. * * 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)
  22696. * @returns the VertexData of the IcoSphere
  22697. */
  22698. static CreateIcoSphere(options: {
  22699. radius?: number;
  22700. radiusX?: number;
  22701. radiusY?: number;
  22702. radiusZ?: number;
  22703. flat?: boolean;
  22704. subdivisions?: number;
  22705. sideOrientation?: number;
  22706. frontUVs?: Vector4;
  22707. backUVs?: Vector4;
  22708. }): VertexData;
  22709. /**
  22710. * Creates the VertexData for a Polyhedron
  22711. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22712. * * type provided types are:
  22713. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22714. * * 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)
  22715. * * size the size of the IcoSphere, optional default 1
  22716. * * sizeX allows stretching in the x direction, optional, default size
  22717. * * sizeY allows stretching in the y direction, optional, default size
  22718. * * sizeZ allows stretching in the z direction, optional, default size
  22719. * * 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
  22720. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22721. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22722. * * flat when true creates a flat shaded mesh, optional, default true
  22723. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22724. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22725. * * 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)
  22726. * * 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)
  22727. * @returns the VertexData of the Polyhedron
  22728. */
  22729. static CreatePolyhedron(options: {
  22730. type?: number;
  22731. size?: number;
  22732. sizeX?: number;
  22733. sizeY?: number;
  22734. sizeZ?: number;
  22735. custom?: any;
  22736. faceUV?: Vector4[];
  22737. faceColors?: Color4[];
  22738. flat?: boolean;
  22739. sideOrientation?: number;
  22740. frontUVs?: Vector4;
  22741. backUVs?: Vector4;
  22742. }): VertexData;
  22743. /**
  22744. * Creates the VertexData for a TorusKnot
  22745. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22746. * * radius the radius of the torus knot, optional, default 2
  22747. * * tube the thickness of the tube, optional, default 0.5
  22748. * * radialSegments the number of sides on each tube segments, optional, default 32
  22749. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22750. * * p the number of windings around the z axis, optional, default 2
  22751. * * q the number of windings around the x axis, optional, default 3
  22752. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22753. * * 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)
  22754. * * 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)
  22755. * @returns the VertexData of the Torus Knot
  22756. */
  22757. static CreateTorusKnot(options: {
  22758. radius?: number;
  22759. tube?: number;
  22760. radialSegments?: number;
  22761. tubularSegments?: number;
  22762. p?: number;
  22763. q?: number;
  22764. sideOrientation?: number;
  22765. frontUVs?: Vector4;
  22766. backUVs?: Vector4;
  22767. }): VertexData;
  22768. /**
  22769. * Compute normals for given positions and indices
  22770. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22771. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22772. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22773. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22774. * * facetNormals : optional array of facet normals (vector3)
  22775. * * facetPositions : optional array of facet positions (vector3)
  22776. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22777. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22778. * * bInfo : optional bounding info, required for facetPartitioning computation
  22779. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22780. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22781. * * useRightHandedSystem: optional boolean to for right handed system computation
  22782. * * depthSort : optional boolean to enable the facet depth sort computation
  22783. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22784. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22785. */
  22786. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22787. facetNormals?: any;
  22788. facetPositions?: any;
  22789. facetPartitioning?: any;
  22790. ratio?: number;
  22791. bInfo?: any;
  22792. bbSize?: Vector3;
  22793. subDiv?: any;
  22794. useRightHandedSystem?: boolean;
  22795. depthSort?: boolean;
  22796. distanceTo?: Vector3;
  22797. depthSortedFacets?: any;
  22798. }): void;
  22799. private static _ComputeSides;
  22800. /**
  22801. * Applies VertexData created from the imported parameters to the geometry
  22802. * @param parsedVertexData the parsed data from an imported file
  22803. * @param geometry the geometry to apply the VertexData to
  22804. */
  22805. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22806. }
  22807. }
  22808. declare module BABYLON {
  22809. /**
  22810. * Class containing static functions to help procedurally build meshes
  22811. */
  22812. class MeshBuilder {
  22813. private static updateSideOrientation;
  22814. /**
  22815. * Creates a box mesh
  22816. * * The parameter `size` sets the size (float) of each box side (default 1)
  22817. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22818. * * 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)
  22819. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22821. * * 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
  22822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22823. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22824. * @param name defines the name of the mesh
  22825. * @param options defines the options used to create the mesh
  22826. * @param scene defines the hosting scene
  22827. * @returns the box mesh
  22828. */
  22829. static CreateBox(name: string, options: {
  22830. size?: number;
  22831. width?: number;
  22832. height?: number;
  22833. depth?: number;
  22834. faceUV?: Vector4[];
  22835. faceColors?: Color4[];
  22836. sideOrientation?: number;
  22837. frontUVs?: Vector4;
  22838. backUVs?: Vector4;
  22839. updatable?: boolean;
  22840. }, scene?: Nullable<Scene>): Mesh;
  22841. /**
  22842. * Creates a sphere mesh
  22843. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22844. * * 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`)
  22845. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22846. * * 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
  22847. * * 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)
  22848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22849. * * 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
  22850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22851. * @param name defines the name of the mesh
  22852. * @param options defines the options used to create the mesh
  22853. * @param scene defines the hosting scene
  22854. * @returns the sphere mesh
  22855. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22856. */
  22857. static CreateSphere(name: string, options: {
  22858. segments?: number;
  22859. diameter?: number;
  22860. diameterX?: number;
  22861. diameterY?: number;
  22862. diameterZ?: number;
  22863. arc?: number;
  22864. slice?: number;
  22865. sideOrientation?: number;
  22866. frontUVs?: Vector4;
  22867. backUVs?: Vector4;
  22868. updatable?: boolean;
  22869. }, scene: any): Mesh;
  22870. /**
  22871. * Creates a plane polygonal mesh. By default, this is a disc
  22872. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22873. * * 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
  22874. * * 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
  22875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22876. * * 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
  22877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22878. * @param name defines the name of the mesh
  22879. * @param options defines the options used to create the mesh
  22880. * @param scene defines the hosting scene
  22881. * @returns the plane polygonal mesh
  22882. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22883. */
  22884. static CreateDisc(name: string, options: {
  22885. radius?: number;
  22886. tessellation?: number;
  22887. arc?: number;
  22888. updatable?: boolean;
  22889. sideOrientation?: number;
  22890. frontUVs?: Vector4;
  22891. backUVs?: Vector4;
  22892. }, scene?: Nullable<Scene>): Mesh;
  22893. /**
  22894. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22895. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22896. * * 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`)
  22897. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22898. * * 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
  22899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22900. * * 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
  22901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22902. * @param name defines the name of the mesh
  22903. * @param options defines the options used to create the mesh
  22904. * @param scene defines the hosting scene
  22905. * @returns the icosahedron mesh
  22906. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22907. */
  22908. static CreateIcoSphere(name: string, options: {
  22909. radius?: number;
  22910. radiusX?: number;
  22911. radiusY?: number;
  22912. radiusZ?: number;
  22913. flat?: boolean;
  22914. subdivisions?: number;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. updatable?: boolean;
  22919. }, scene: Scene): Mesh;
  22920. /**
  22921. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22922. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22923. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22924. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22925. * * 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
  22926. * * 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
  22927. * * 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
  22928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22929. * * 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
  22930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22931. * * 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
  22932. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22933. * * 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
  22934. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22936. * @param name defines the name of the mesh
  22937. * @param options defines the options used to create the mesh
  22938. * @param scene defines the hosting scene
  22939. * @returns the ribbon mesh
  22940. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22941. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22942. */
  22943. static CreateRibbon(name: string, options: {
  22944. pathArray: Vector3[][];
  22945. closeArray?: boolean;
  22946. closePath?: boolean;
  22947. offset?: number;
  22948. updatable?: boolean;
  22949. sideOrientation?: number;
  22950. frontUVs?: Vector4;
  22951. backUVs?: Vector4;
  22952. instance?: Mesh;
  22953. invertUV?: boolean;
  22954. uvs?: Vector2[];
  22955. colors?: Color4[];
  22956. }, scene?: Nullable<Scene>): Mesh;
  22957. /**
  22958. * Creates a cylinder or a cone mesh
  22959. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22960. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22961. * * 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.
  22962. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22963. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22964. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22965. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22966. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22967. * * 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).
  22968. * * 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
  22969. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22970. * * 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
  22971. * * 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.
  22972. * * If `enclose` is false, a ring surface is one element.
  22973. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22974. * * 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
  22975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22976. * * 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
  22977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22978. * @param name defines the name of the mesh
  22979. * @param options defines the options used to create the mesh
  22980. * @param scene defines the hosting scene
  22981. * @returns the cylinder mesh
  22982. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22983. */
  22984. static CreateCylinder(name: string, options: {
  22985. height?: number;
  22986. diameterTop?: number;
  22987. diameterBottom?: number;
  22988. diameter?: number;
  22989. tessellation?: number;
  22990. subdivisions?: number;
  22991. arc?: number;
  22992. faceColors?: Color4[];
  22993. faceUV?: Vector4[];
  22994. updatable?: boolean;
  22995. hasRings?: boolean;
  22996. enclose?: boolean;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }, scene: any): Mesh;
  23001. /**
  23002. * Creates a torus mesh
  23003. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23004. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23005. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23007. * * 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
  23008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23009. * @param name defines the name of the mesh
  23010. * @param options defines the options used to create the mesh
  23011. * @param scene defines the hosting scene
  23012. * @returns the torus mesh
  23013. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23014. */
  23015. static CreateTorus(name: string, options: {
  23016. diameter?: number;
  23017. thickness?: number;
  23018. tessellation?: number;
  23019. updatable?: boolean;
  23020. sideOrientation?: number;
  23021. frontUVs?: Vector4;
  23022. backUVs?: Vector4;
  23023. }, scene: any): Mesh;
  23024. /**
  23025. * Creates a torus knot mesh
  23026. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23027. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23028. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23029. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23031. * * 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
  23032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23033. * @param name defines the name of the mesh
  23034. * @param options defines the options used to create the mesh
  23035. * @param scene defines the hosting scene
  23036. * @returns the torus knot mesh
  23037. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23038. */
  23039. static CreateTorusKnot(name: string, options: {
  23040. radius?: number;
  23041. tube?: number;
  23042. radialSegments?: number;
  23043. tubularSegments?: number;
  23044. p?: number;
  23045. q?: number;
  23046. updatable?: boolean;
  23047. sideOrientation?: number;
  23048. frontUVs?: Vector4;
  23049. backUVs?: Vector4;
  23050. }, scene: any): Mesh;
  23051. /**
  23052. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23053. * * 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
  23054. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23055. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23056. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23057. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23058. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23059. * * 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
  23060. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23062. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23063. * @param name defines the name of the new line system
  23064. * @param options defines the options used to create the line system
  23065. * @param scene defines the hosting scene
  23066. * @returns a new line system mesh
  23067. */
  23068. static CreateLineSystem(name: string, options: {
  23069. lines: Vector3[][];
  23070. updatable?: boolean;
  23071. instance?: Nullable<LinesMesh>;
  23072. colors?: Nullable<Color4[][]>;
  23073. useVertexAlpha?: boolean;
  23074. }, scene: Nullable<Scene>): LinesMesh;
  23075. /**
  23076. * Creates a line mesh
  23077. * 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
  23078. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23079. * * The parameter `points` is an array successive Vector3
  23080. * * 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
  23081. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23082. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23083. * * When updating an instance, remember that only point positions can change, not the number of points
  23084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23085. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23086. * @param name defines the name of the new line system
  23087. * @param options defines the options used to create the line system
  23088. * @param scene defines the hosting scene
  23089. * @returns a new line mesh
  23090. */
  23091. static CreateLines(name: string, options: {
  23092. points: Vector3[];
  23093. updatable?: boolean;
  23094. instance?: Nullable<LinesMesh>;
  23095. colors?: Color4[];
  23096. useVertexAlpha?: boolean;
  23097. }, scene?: Nullable<Scene>): LinesMesh;
  23098. /**
  23099. * Creates a dashed line mesh
  23100. * * 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
  23101. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23102. * * The parameter `points` is an array successive Vector3
  23103. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23104. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23105. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23106. * * 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
  23107. * * When updating an instance, remember that only point positions can change, not the number of points
  23108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23109. * @param name defines the name of the mesh
  23110. * @param options defines the options used to create the mesh
  23111. * @param scene defines the hosting scene
  23112. * @returns the dashed line mesh
  23113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23114. */
  23115. static CreateDashedLines(name: string, options: {
  23116. points: Vector3[];
  23117. dashSize?: number;
  23118. gapSize?: number;
  23119. dashNb?: number;
  23120. updatable?: boolean;
  23121. instance?: LinesMesh;
  23122. }, scene?: Nullable<Scene>): LinesMesh;
  23123. /**
  23124. * 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.
  23125. * * 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.
  23126. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23127. * * 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.
  23128. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23129. * * 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
  23130. * * 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
  23131. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23133. * * 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
  23134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23136. * @param name defines the name of the mesh
  23137. * @param options defines the options used to create the mesh
  23138. * @param scene defines the hosting scene
  23139. * @returns the extruded shape mesh
  23140. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23142. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23143. */
  23144. static ExtrudeShape(name: string, options: {
  23145. shape: Vector3[];
  23146. path: Vector3[];
  23147. scale?: number;
  23148. rotation?: number;
  23149. cap?: number;
  23150. updatable?: boolean;
  23151. sideOrientation?: number;
  23152. frontUVs?: Vector4;
  23153. backUVs?: Vector4;
  23154. instance?: Mesh;
  23155. invertUV?: boolean;
  23156. }, scene?: Nullable<Scene>): Mesh;
  23157. /**
  23158. * Creates an custom extruded shape mesh.
  23159. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23160. * * 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.
  23161. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23162. * * 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
  23163. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23164. * * 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
  23165. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23166. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23167. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23168. * * 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
  23169. * * 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
  23170. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23172. * * 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
  23173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23175. * @param name defines the name of the mesh
  23176. * @param options defines the options used to create the mesh
  23177. * @param scene defines the hosting scene
  23178. * @returns the custom extruded shape mesh
  23179. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23180. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23181. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23182. */
  23183. static ExtrudeShapeCustom(name: string, options: {
  23184. shape: Vector3[];
  23185. path: Vector3[];
  23186. scaleFunction?: any;
  23187. rotationFunction?: any;
  23188. ribbonCloseArray?: boolean;
  23189. ribbonClosePath?: boolean;
  23190. cap?: number;
  23191. updatable?: boolean;
  23192. sideOrientation?: number;
  23193. frontUVs?: Vector4;
  23194. backUVs?: Vector4;
  23195. instance?: Mesh;
  23196. invertUV?: boolean;
  23197. }, scene: Scene): Mesh;
  23198. /**
  23199. * Creates lathe mesh.
  23200. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23201. * * 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
  23202. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23203. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23204. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23205. * * 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
  23206. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23207. * * 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
  23208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23209. * * 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
  23210. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23212. * @param name defines the name of the mesh
  23213. * @param options defines the options used to create the mesh
  23214. * @param scene defines the hosting scene
  23215. * @returns the lathe mesh
  23216. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23217. */
  23218. static CreateLathe(name: string, options: {
  23219. shape: Vector3[];
  23220. radius?: number;
  23221. tessellation?: number;
  23222. clip?: number;
  23223. arc?: number;
  23224. closed?: boolean;
  23225. updatable?: boolean;
  23226. sideOrientation?: number;
  23227. frontUVs?: Vector4;
  23228. backUVs?: Vector4;
  23229. cap?: number;
  23230. invertUV?: boolean;
  23231. }, scene: Scene): Mesh;
  23232. /**
  23233. * Creates a plane mesh
  23234. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23235. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23236. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23238. * * 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
  23239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23240. * @param name defines the name of the mesh
  23241. * @param options defines the options used to create the mesh
  23242. * @param scene defines the hosting scene
  23243. * @returns the plane mesh
  23244. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23245. */
  23246. static CreatePlane(name: string, options: {
  23247. size?: number;
  23248. width?: number;
  23249. height?: number;
  23250. sideOrientation?: number;
  23251. frontUVs?: Vector4;
  23252. backUVs?: Vector4;
  23253. updatable?: boolean;
  23254. sourcePlane?: Plane;
  23255. }, scene: Scene): Mesh;
  23256. /**
  23257. * Creates a ground mesh
  23258. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23259. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23261. * @param name defines the name of the mesh
  23262. * @param options defines the options used to create the mesh
  23263. * @param scene defines the hosting scene
  23264. * @returns the ground mesh
  23265. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23266. */
  23267. static CreateGround(name: string, options: {
  23268. width?: number;
  23269. height?: number;
  23270. subdivisions?: number;
  23271. subdivisionsX?: number;
  23272. subdivisionsY?: number;
  23273. updatable?: boolean;
  23274. }, scene: any): Mesh;
  23275. /**
  23276. * Creates a tiled ground mesh
  23277. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23278. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23279. * * 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
  23280. * * 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
  23281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23282. * @param name defines the name of the mesh
  23283. * @param options defines the options used to create the mesh
  23284. * @param scene defines the hosting scene
  23285. * @returns the tiled ground mesh
  23286. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23287. */
  23288. static CreateTiledGround(name: string, options: {
  23289. xmin: number;
  23290. zmin: number;
  23291. xmax: number;
  23292. zmax: number;
  23293. subdivisions?: {
  23294. w: number;
  23295. h: number;
  23296. };
  23297. precision?: {
  23298. w: number;
  23299. h: number;
  23300. };
  23301. updatable?: boolean;
  23302. }, scene: Scene): Mesh;
  23303. /**
  23304. * Creates a ground mesh from a height map
  23305. * * The parameter `url` sets the URL of the height map image resource.
  23306. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23307. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23308. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23309. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23310. * * 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.
  23311. * * 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).
  23312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23313. * @param name defines the name of the mesh
  23314. * @param url defines the url to the height map
  23315. * @param options defines the options used to create the mesh
  23316. * @param scene defines the hosting scene
  23317. * @returns the ground mesh
  23318. * @see http://doc.babylonjs.com/babylon101/height_map
  23319. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23320. */
  23321. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23322. width?: number;
  23323. height?: number;
  23324. subdivisions?: number;
  23325. minHeight?: number;
  23326. maxHeight?: number;
  23327. colorFilter?: Color3;
  23328. updatable?: boolean;
  23329. onReady?: (mesh: GroundMesh) => void;
  23330. }, scene: Scene): GroundMesh;
  23331. /**
  23332. * Creates a polygon mesh
  23333. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23334. * * 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
  23335. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23337. * * 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)
  23338. * * Remember you can only change the shape positions, not their number when updating a polygon
  23339. * @param name defines the name of the mesh
  23340. * @param options defines the options used to create the mesh
  23341. * @param scene defines the hosting scene
  23342. * @returns the polygon mesh
  23343. */
  23344. static CreatePolygon(name: string, options: {
  23345. shape: Vector3[];
  23346. holes?: Vector3[][];
  23347. depth?: number;
  23348. faceUV?: Vector4[];
  23349. faceColors?: Color4[];
  23350. updatable?: boolean;
  23351. sideOrientation?: number;
  23352. frontUVs?: Vector4;
  23353. backUVs?: Vector4;
  23354. }, scene: Scene): Mesh;
  23355. /**
  23356. * Creates an extruded polygon mesh, with depth in the Y direction.
  23357. * * 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)
  23358. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23359. * @param name defines the name of the mesh
  23360. * @param options defines the options used to create the mesh
  23361. * @param scene defines the hosting scene
  23362. * @returns the polygon mesh
  23363. */
  23364. static ExtrudePolygon(name: string, options: {
  23365. shape: Vector3[];
  23366. holes?: Vector3[][];
  23367. depth?: number;
  23368. faceUV?: Vector4[];
  23369. faceColors?: Color4[];
  23370. updatable?: boolean;
  23371. sideOrientation?: number;
  23372. frontUVs?: Vector4;
  23373. backUVs?: Vector4;
  23374. }, scene: Scene): Mesh;
  23375. /**
  23376. * Creates a tube mesh.
  23377. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23378. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23379. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23380. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23381. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23382. * * 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)
  23383. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23384. * * 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
  23385. * * 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
  23386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23387. * * 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
  23388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23390. * @param name defines the name of the mesh
  23391. * @param options defines the options used to create the mesh
  23392. * @param scene defines the hosting scene
  23393. * @returns the tube mesh
  23394. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23395. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23396. */
  23397. static CreateTube(name: string, options: {
  23398. path: Vector3[];
  23399. radius?: number;
  23400. tessellation?: number;
  23401. radiusFunction?: {
  23402. (i: number, distance: number): number;
  23403. };
  23404. cap?: number;
  23405. arc?: number;
  23406. updatable?: boolean;
  23407. sideOrientation?: number;
  23408. frontUVs?: Vector4;
  23409. backUVs?: Vector4;
  23410. instance?: Mesh;
  23411. invertUV?: boolean;
  23412. }, scene: Scene): Mesh;
  23413. /**
  23414. * Creates a polyhedron mesh
  23415. * * 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
  23416. * * The parameter `size` (positive float, default 1) sets the polygon size
  23417. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23418. * * 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`
  23419. * * 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
  23420. * * 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)`)
  23421. * * 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
  23422. * * 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
  23423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23426. * @param name defines the name of the mesh
  23427. * @param options defines the options used to create the mesh
  23428. * @param scene defines the hosting scene
  23429. * @returns the polyhedron mesh
  23430. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23431. */
  23432. static CreatePolyhedron(name: string, options: {
  23433. type?: number;
  23434. size?: number;
  23435. sizeX?: number;
  23436. sizeY?: number;
  23437. sizeZ?: number;
  23438. custom?: any;
  23439. faceUV?: Vector4[];
  23440. faceColors?: Color4[];
  23441. flat?: boolean;
  23442. updatable?: boolean;
  23443. sideOrientation?: number;
  23444. frontUVs?: Vector4;
  23445. backUVs?: Vector4;
  23446. }, scene: Scene): Mesh;
  23447. /**
  23448. * Creates a decal mesh.
  23449. * 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
  23450. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23451. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23452. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23453. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23454. * @param name defines the name of the mesh
  23455. * @param sourceMesh defines the mesh where the decal must be applied
  23456. * @param options defines the options used to create the mesh
  23457. * @param scene defines the hosting scene
  23458. * @returns the decal mesh
  23459. * @see http://doc.babylonjs.com/how_to/decals
  23460. */
  23461. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23462. position?: Vector3;
  23463. normal?: Vector3;
  23464. size?: Vector3;
  23465. angle?: number;
  23466. }): Mesh;
  23467. private static _ExtrudeShapeGeneric;
  23468. }
  23469. }
  23470. declare module BABYLON {
  23471. class MeshLODLevel {
  23472. distance: number;
  23473. mesh: Nullable<Mesh>;
  23474. constructor(distance: number, mesh: Nullable<Mesh>);
  23475. }
  23476. }
  23477. declare module BABYLON {
  23478. /**
  23479. * A simplifier interface for future simplification implementations.
  23480. */
  23481. interface ISimplifier {
  23482. /**
  23483. * Simplification of a given mesh according to the given settings.
  23484. * Since this requires computation, it is assumed that the function runs async.
  23485. * @param settings The settings of the simplification, including quality and distance
  23486. * @param successCallback A callback that will be called after the mesh was simplified.
  23487. * @param errorCallback in case of an error, this callback will be called. optional.
  23488. */
  23489. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23490. }
  23491. /**
  23492. * Expected simplification settings.
  23493. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23494. */
  23495. interface ISimplificationSettings {
  23496. quality: number;
  23497. distance: number;
  23498. optimizeMesh?: boolean;
  23499. }
  23500. class SimplificationSettings implements ISimplificationSettings {
  23501. quality: number;
  23502. distance: number;
  23503. optimizeMesh?: boolean | undefined;
  23504. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23505. }
  23506. interface ISimplificationTask {
  23507. settings: Array<ISimplificationSettings>;
  23508. simplificationType: SimplificationType;
  23509. mesh: Mesh;
  23510. successCallback?: () => void;
  23511. parallelProcessing: boolean;
  23512. }
  23513. class SimplificationQueue {
  23514. private _simplificationArray;
  23515. running: boolean;
  23516. constructor();
  23517. addTask(task: ISimplificationTask): void;
  23518. executeNext(): void;
  23519. runSimplification(task: ISimplificationTask): void;
  23520. private getSimplifier;
  23521. }
  23522. /**
  23523. * The implemented types of simplification
  23524. * At the moment only Quadratic Error Decimation is implemented
  23525. */
  23526. enum SimplificationType {
  23527. /** Quadratic error decimation */
  23528. QUADRATIC = 0
  23529. }
  23530. class DecimationTriangle {
  23531. vertices: Array<DecimationVertex>;
  23532. normal: Vector3;
  23533. error: Array<number>;
  23534. deleted: boolean;
  23535. isDirty: boolean;
  23536. borderFactor: number;
  23537. deletePending: boolean;
  23538. originalOffset: number;
  23539. constructor(vertices: Array<DecimationVertex>);
  23540. }
  23541. class DecimationVertex {
  23542. position: Vector3;
  23543. id: number;
  23544. q: QuadraticMatrix;
  23545. isBorder: boolean;
  23546. triangleStart: number;
  23547. triangleCount: number;
  23548. originalOffsets: Array<number>;
  23549. constructor(position: Vector3, id: number);
  23550. updatePosition(newPosition: Vector3): void;
  23551. }
  23552. class QuadraticMatrix {
  23553. data: Array<number>;
  23554. constructor(data?: Array<number>);
  23555. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23556. addInPlace(matrix: QuadraticMatrix): void;
  23557. addArrayInPlace(data: Array<number>): void;
  23558. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23559. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23560. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23561. }
  23562. class Reference {
  23563. vertexId: number;
  23564. triangleId: number;
  23565. constructor(vertexId: number, triangleId: number);
  23566. }
  23567. /**
  23568. * An implementation of the Quadratic Error simplification algorithm.
  23569. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23570. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23571. * @author RaananW
  23572. */
  23573. class QuadraticErrorSimplification implements ISimplifier {
  23574. private _mesh;
  23575. private triangles;
  23576. private vertices;
  23577. private references;
  23578. private _reconstructedMesh;
  23579. syncIterations: number;
  23580. aggressiveness: number;
  23581. decimationIterations: number;
  23582. boundingBoxEpsilon: number;
  23583. constructor(_mesh: Mesh);
  23584. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23585. private runDecimation;
  23586. private initWithMesh;
  23587. private init;
  23588. private reconstructMesh;
  23589. private initDecimatedMesh;
  23590. private isFlipped;
  23591. private updateTriangles;
  23592. private identifyBorder;
  23593. private updateMesh;
  23594. private vertexError;
  23595. private calculateError;
  23596. }
  23597. }
  23598. declare module BABYLON {
  23599. interface Scene {
  23600. /** @hidden (Backing field) */
  23601. _simplificationQueue: SimplificationQueue;
  23602. /**
  23603. * Gets or sets the simplification queue attached to the scene
  23604. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23605. */
  23606. simplificationQueue: SimplificationQueue;
  23607. }
  23608. interface Mesh {
  23609. /**
  23610. * Simplify the mesh according to the given array of settings.
  23611. * Function will return immediately and will simplify async. It returns the Mesh.
  23612. * @param settings a collection of simplification settings.
  23613. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23614. * @param type the type of simplification to run.
  23615. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23616. */
  23617. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23618. }
  23619. /**
  23620. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23621. * created in a scene
  23622. */
  23623. class SimplicationQueueSceneComponent implements ISceneComponent {
  23624. /**
  23625. * The component name helpfull to identify the component in the list of scene components.
  23626. */
  23627. readonly name: string;
  23628. /**
  23629. * The scene the component belongs to.
  23630. */
  23631. scene: Scene;
  23632. /**
  23633. * Creates a new instance of the component for the given scene
  23634. * @param scene Defines the scene to register the component in
  23635. */
  23636. constructor(scene: Scene);
  23637. /**
  23638. * Registers the component in a given scene
  23639. */
  23640. register(): void;
  23641. /**
  23642. * Rebuilds the elements related to this component in case of
  23643. * context lost for instance.
  23644. */
  23645. rebuild(): void;
  23646. /**
  23647. * Disposes the component and the associated ressources
  23648. */
  23649. dispose(): void;
  23650. private _beforeCameraUpdate;
  23651. }
  23652. }
  23653. declare module BABYLON {
  23654. class Polygon {
  23655. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23656. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23657. static Parse(input: string): Vector2[];
  23658. static StartingAt(x: number, y: number): Path2;
  23659. }
  23660. class PolygonMeshBuilder {
  23661. private _points;
  23662. private _outlinepoints;
  23663. private _holes;
  23664. private _name;
  23665. private _scene;
  23666. private _epoints;
  23667. private _eholes;
  23668. private _addToepoint;
  23669. constructor(name: string, contours: Path2, scene: Scene);
  23670. constructor(name: string, contours: Vector2[], scene: Scene);
  23671. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23672. build(updatable?: boolean, depth?: number): Mesh;
  23673. private addSide;
  23674. }
  23675. }
  23676. declare module BABYLON {
  23677. class BaseSubMesh {
  23678. /** @hidden */
  23679. _materialDefines: Nullable<MaterialDefines>;
  23680. /** @hidden */
  23681. _materialEffect: Nullable<Effect>;
  23682. readonly effect: Nullable<Effect>;
  23683. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23684. }
  23685. class SubMesh extends BaseSubMesh implements ICullable {
  23686. materialIndex: number;
  23687. verticesStart: number;
  23688. verticesCount: number;
  23689. indexStart: number;
  23690. indexCount: number;
  23691. linesIndexCount: number;
  23692. private _mesh;
  23693. private _renderingMesh;
  23694. private _boundingInfo;
  23695. private _linesIndexBuffer;
  23696. /** @hidden */
  23697. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23698. /** @hidden */
  23699. _trianglePlanes: Plane[];
  23700. /** @hidden */
  23701. _lastColliderTransformMatrix: Matrix;
  23702. /** @hidden */
  23703. _renderId: number;
  23704. /** @hidden */
  23705. _alphaIndex: number;
  23706. /** @hidden */
  23707. _distanceToCamera: number;
  23708. /** @hidden */
  23709. _id: number;
  23710. private _currentMaterial;
  23711. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23712. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23713. readonly IsGlobal: boolean;
  23714. /**
  23715. * Returns the submesh BoudingInfo object.
  23716. */
  23717. getBoundingInfo(): BoundingInfo;
  23718. /**
  23719. * Sets the submesh BoundingInfo.
  23720. * Return the SubMesh.
  23721. */
  23722. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23723. /**
  23724. * Returns the mesh of the current submesh.
  23725. */
  23726. getMesh(): AbstractMesh;
  23727. /**
  23728. * Returns the rendering mesh of the submesh.
  23729. */
  23730. getRenderingMesh(): Mesh;
  23731. /**
  23732. * Returns the submesh material.
  23733. */
  23734. getMaterial(): Nullable<Material>;
  23735. /**
  23736. * Sets a new updated BoundingInfo object to the submesh.
  23737. * Returns the SubMesh.
  23738. */
  23739. refreshBoundingInfo(): SubMesh;
  23740. /** @hidden */
  23741. _checkCollision(collider: Collider): boolean;
  23742. /**
  23743. * Updates the submesh BoundingInfo.
  23744. * Returns the Submesh.
  23745. */
  23746. updateBoundingInfo(world: Matrix): SubMesh;
  23747. /**
  23748. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23749. * Boolean returned.
  23750. */
  23751. isInFrustum(frustumPlanes: Plane[]): boolean;
  23752. /**
  23753. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23754. * Boolean returned.
  23755. */
  23756. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23757. /**
  23758. * Renders the submesh.
  23759. * Returns it.
  23760. */
  23761. render(enableAlphaMode: boolean): SubMesh;
  23762. /**
  23763. * Returns a new Index Buffer.
  23764. * Type returned : WebGLBuffer.
  23765. */
  23766. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23767. /**
  23768. * True is the passed Ray intersects the submesh bounding box.
  23769. * Boolean returned.
  23770. */
  23771. canIntersects(ray: Ray): boolean;
  23772. /**
  23773. * Returns an object IntersectionInfo.
  23774. */
  23775. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23776. /** @hidden */
  23777. _rebuild(): void;
  23778. /**
  23779. * Creates a new Submesh from the passed Mesh.
  23780. */
  23781. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23782. /**
  23783. * Disposes the Submesh.
  23784. * Returns nothing.
  23785. */
  23786. dispose(): void;
  23787. /**
  23788. * Creates a new Submesh from the passed parameters :
  23789. * - materialIndex (integer) : the index of the main mesh material.
  23790. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23791. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23792. * - mesh (Mesh) : the main mesh to create the submesh from.
  23793. * - renderingMesh (optional Mesh) : rendering mesh.
  23794. */
  23795. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23796. }
  23797. }
  23798. declare module BABYLON {
  23799. class TransformNode extends Node {
  23800. static BILLBOARDMODE_NONE: number;
  23801. static BILLBOARDMODE_X: number;
  23802. static BILLBOARDMODE_Y: number;
  23803. static BILLBOARDMODE_Z: number;
  23804. static BILLBOARDMODE_ALL: number;
  23805. private _forward;
  23806. private _forwardInverted;
  23807. private _up;
  23808. private _right;
  23809. private _rightInverted;
  23810. private _rotation;
  23811. private _rotationQuaternion;
  23812. protected _scaling: Vector3;
  23813. protected _isDirty: boolean;
  23814. private _transformToBoneReferal;
  23815. /**
  23816. * Set the billboard mode. Default is 0.
  23817. *
  23818. * | Value | Type | Description |
  23819. * | --- | --- | --- |
  23820. * | 0 | BILLBOARDMODE_NONE | |
  23821. * | 1 | BILLBOARDMODE_X | |
  23822. * | 2 | BILLBOARDMODE_Y | |
  23823. * | 4 | BILLBOARDMODE_Z | |
  23824. * | 7 | BILLBOARDMODE_ALL | |
  23825. *
  23826. */
  23827. billboardMode: number;
  23828. scalingDeterminant: number;
  23829. infiniteDistance: boolean;
  23830. /**
  23831. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23832. * By default the system will update normals to compensate
  23833. */
  23834. ignoreNonUniformScaling: boolean;
  23835. position: Vector3;
  23836. /** @hidden */
  23837. _poseMatrix: Matrix;
  23838. private _localWorld;
  23839. /** @hidden */
  23840. _worldMatrix: Matrix;
  23841. /** @hidden */
  23842. _worldMatrixDeterminant: number;
  23843. private _absolutePosition;
  23844. private _pivotMatrix;
  23845. private _pivotMatrixInverse;
  23846. private _postMultiplyPivotMatrix;
  23847. protected _isWorldMatrixFrozen: boolean;
  23848. /**
  23849. * An event triggered after the world matrix is updated
  23850. */
  23851. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23852. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23853. /**
  23854. * Gets a string identifying the name of the class
  23855. * @returns "TransformNode" string
  23856. */
  23857. getClassName(): string;
  23858. /**
  23859. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23860. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23861. * Default : (0.0, 0.0, 0.0)
  23862. */
  23863. rotation: Vector3;
  23864. /**
  23865. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23866. * Default : (1.0, 1.0, 1.0)
  23867. */
  23868. /**
  23869. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23870. * Default : (1.0, 1.0, 1.0)
  23871. */
  23872. scaling: Vector3;
  23873. /**
  23874. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23875. * It's null by default.
  23876. * 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)
  23877. */
  23878. rotationQuaternion: Nullable<Quaternion>;
  23879. /**
  23880. * The forward direction of that transform in world space.
  23881. */
  23882. readonly forward: Vector3;
  23883. /**
  23884. * The up direction of that transform in world space.
  23885. */
  23886. readonly up: Vector3;
  23887. /**
  23888. * The right direction of that transform in world space.
  23889. */
  23890. readonly right: Vector3;
  23891. /**
  23892. * Returns the latest update of the World matrix
  23893. * Returns a Matrix.
  23894. */
  23895. getWorldMatrix(): Matrix;
  23896. /** @hidden */
  23897. _getWorldMatrixDeterminant(): number;
  23898. /**
  23899. * Returns directly the latest state of the mesh World matrix.
  23900. * A Matrix is returned.
  23901. */
  23902. readonly worldMatrixFromCache: Matrix;
  23903. /**
  23904. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23905. * Returns the TransformNode.
  23906. */
  23907. updatePoseMatrix(matrix: Matrix): TransformNode;
  23908. /**
  23909. * Returns the mesh Pose matrix.
  23910. * Returned object : Matrix
  23911. */
  23912. getPoseMatrix(): Matrix;
  23913. /** @hidden */
  23914. _isSynchronized(): boolean;
  23915. /** @hidden */
  23916. _initCache(): void;
  23917. markAsDirty(property: string): TransformNode;
  23918. /**
  23919. * Returns the current mesh absolute position.
  23920. * Returns a Vector3.
  23921. */
  23922. readonly absolutePosition: Vector3;
  23923. /**
  23924. * Sets a new matrix to apply before all other transformation
  23925. * @param matrix defines the transform matrix
  23926. * @returns the current TransformNode
  23927. */
  23928. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23929. /**
  23930. * Sets a new pivot matrix to the current node
  23931. * @param matrix defines the new pivot matrix to use
  23932. * @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
  23933. * @returns the current TransformNode
  23934. */
  23935. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23936. /**
  23937. * Returns the mesh pivot matrix.
  23938. * Default : Identity.
  23939. * A Matrix is returned.
  23940. */
  23941. getPivotMatrix(): Matrix;
  23942. /**
  23943. * Prevents the World matrix to be computed any longer.
  23944. * Returns the TransformNode.
  23945. */
  23946. freezeWorldMatrix(): TransformNode;
  23947. /**
  23948. * Allows back the World matrix computation.
  23949. * Returns the TransformNode.
  23950. */
  23951. unfreezeWorldMatrix(): this;
  23952. /**
  23953. * True if the World matrix has been frozen.
  23954. * Returns a boolean.
  23955. */
  23956. readonly isWorldMatrixFrozen: boolean;
  23957. /**
  23958. * Retuns the mesh absolute position in the World.
  23959. * Returns a Vector3.
  23960. */
  23961. getAbsolutePosition(): Vector3;
  23962. /**
  23963. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23964. * Returns the TransformNode.
  23965. */
  23966. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23967. /**
  23968. * Sets the mesh position in its local space.
  23969. * Returns the TransformNode.
  23970. */
  23971. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23972. /**
  23973. * Returns the mesh position in the local space from the current World matrix values.
  23974. * Returns a new Vector3.
  23975. */
  23976. getPositionExpressedInLocalSpace(): Vector3;
  23977. /**
  23978. * Translates the mesh along the passed Vector3 in its local space.
  23979. * Returns the TransformNode.
  23980. */
  23981. locallyTranslate(vector3: Vector3): TransformNode;
  23982. private static _lookAtVectorCache;
  23983. /**
  23984. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23985. * @param targetPoint the position (must be in same space as current mesh) to look at
  23986. * @param yawCor optional yaw (y-axis) correction in radians
  23987. * @param pitchCor optional pitch (x-axis) correction in radians
  23988. * @param rollCor optional roll (z-axis) correction in radians
  23989. * @param space the choosen space of the target
  23990. * @returns the TransformNode.
  23991. */
  23992. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23993. /**
  23994. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23995. * This Vector3 is expressed in the World space.
  23996. */
  23997. getDirection(localAxis: Vector3): Vector3;
  23998. /**
  23999. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24000. * localAxis is expressed in the mesh local space.
  24001. * result is computed in the Wordl space from the mesh World matrix.
  24002. * Returns the TransformNode.
  24003. */
  24004. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24005. /**
  24006. * Sets a new pivot point to the current node
  24007. * @param point defines the new pivot point to use
  24008. * @param space defines if the point is in world or local space (local by default)
  24009. * @returns the current TransformNode
  24010. */
  24011. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24012. /**
  24013. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24014. */
  24015. getPivotPoint(): Vector3;
  24016. /**
  24017. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24018. * Returns the TransformNode.
  24019. */
  24020. getPivotPointToRef(result: Vector3): TransformNode;
  24021. /**
  24022. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24023. */
  24024. getAbsolutePivotPoint(): Vector3;
  24025. /**
  24026. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24027. * Returns the TransformNode.
  24028. */
  24029. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24030. /**
  24031. * Defines the passed node as the parent of the current node.
  24032. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24033. * Returns the TransformNode.
  24034. */
  24035. setParent(node: Nullable<Node>): TransformNode;
  24036. private _nonUniformScaling;
  24037. readonly nonUniformScaling: boolean;
  24038. /** @hidden */
  24039. _updateNonUniformScalingState(value: boolean): boolean;
  24040. /**
  24041. * Attach the current TransformNode to another TransformNode associated with a bone
  24042. * @param bone Bone affecting the TransformNode
  24043. * @param affectedTransformNode TransformNode associated with the bone
  24044. */
  24045. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24046. detachFromBone(): TransformNode;
  24047. private static _rotationAxisCache;
  24048. /**
  24049. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24050. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24051. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24052. * The passed axis is also normalized.
  24053. * Returns the TransformNode.
  24054. */
  24055. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24056. /**
  24057. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24058. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24059. * The passed axis is also normalized.
  24060. * Returns the TransformNode.
  24061. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24062. */
  24063. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24064. /**
  24065. * Translates the mesh along the axis vector for the passed distance in the given space.
  24066. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24067. * Returns the TransformNode.
  24068. */
  24069. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24070. /**
  24071. * Adds a rotation step to the mesh current rotation.
  24072. * x, y, z are Euler angles expressed in radians.
  24073. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24074. * This means this rotation is made in the mesh local space only.
  24075. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24076. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24077. * ```javascript
  24078. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24079. * ```
  24080. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24081. * 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.
  24082. * Returns the TransformNode.
  24083. */
  24084. addRotation(x: number, y: number, z: number): TransformNode;
  24085. /**
  24086. * Computes the mesh World matrix and returns it.
  24087. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  24088. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  24089. * If the parameter `force`is set to `true`, the actual computation is done.
  24090. * Returns the mesh World Matrix.
  24091. */
  24092. computeWorldMatrix(force?: boolean): Matrix;
  24093. protected _afterComputeWorldMatrix(): void;
  24094. /**
  24095. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24096. * @param func: callback function to add
  24097. *
  24098. * Returns the TransformNode.
  24099. */
  24100. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24101. /**
  24102. * Removes a registered callback function.
  24103. * Returns the TransformNode.
  24104. */
  24105. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24106. /**
  24107. * Clone the current transform node
  24108. * Returns the new transform node
  24109. * @param name Name of the new clone
  24110. * @param newParent New parent for the clone
  24111. * @param doNotCloneChildren Do not clone children hierarchy
  24112. */
  24113. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24114. serialize(currentSerializationObject?: any): any;
  24115. /**
  24116. * Returns a new TransformNode object parsed from the source provided.
  24117. * The parameter `parsedMesh` is the source.
  24118. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24119. */
  24120. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24121. /**
  24122. * Releases resources associated with this transform node.
  24123. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24124. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24125. */
  24126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24127. }
  24128. }
  24129. declare module BABYLON {
  24130. class VertexBuffer {
  24131. /** @hidden */
  24132. _buffer: Buffer;
  24133. private _kind;
  24134. private _size;
  24135. private _ownsBuffer;
  24136. private _instanced;
  24137. private _instanceDivisor;
  24138. /**
  24139. * The byte type.
  24140. */
  24141. static readonly BYTE: number;
  24142. /**
  24143. * The unsigned byte type.
  24144. */
  24145. static readonly UNSIGNED_BYTE: number;
  24146. /**
  24147. * The short type.
  24148. */
  24149. static readonly SHORT: number;
  24150. /**
  24151. * The unsigned short type.
  24152. */
  24153. static readonly UNSIGNED_SHORT: number;
  24154. /**
  24155. * The integer type.
  24156. */
  24157. static readonly INT: number;
  24158. /**
  24159. * The unsigned integer type.
  24160. */
  24161. static readonly UNSIGNED_INT: number;
  24162. /**
  24163. * The float type.
  24164. */
  24165. static readonly FLOAT: number;
  24166. /**
  24167. * Gets or sets the instance divisor when in instanced mode
  24168. */
  24169. instanceDivisor: number;
  24170. /**
  24171. * Gets the byte stride.
  24172. */
  24173. readonly byteStride: number;
  24174. /**
  24175. * Gets the byte offset.
  24176. */
  24177. readonly byteOffset: number;
  24178. /**
  24179. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24180. */
  24181. readonly normalized: boolean;
  24182. /**
  24183. * Gets the data type of each component in the array.
  24184. */
  24185. readonly type: number;
  24186. /**
  24187. * Constructor
  24188. * @param engine the engine
  24189. * @param data the data to use for this vertex buffer
  24190. * @param kind the vertex buffer kind
  24191. * @param updatable whether the data is updatable
  24192. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24193. * @param stride the stride (optional)
  24194. * @param instanced whether the buffer is instanced (optional)
  24195. * @param offset the offset of the data (optional)
  24196. * @param size the number of components (optional)
  24197. * @param type the type of the component (optional)
  24198. * @param normalized whether the data contains normalized data (optional)
  24199. * @param useBytes set to true if stride and offset are in bytes (optional)
  24200. */
  24201. 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);
  24202. /** @hidden */
  24203. _rebuild(): void;
  24204. /**
  24205. * Returns the kind of the VertexBuffer (string).
  24206. */
  24207. getKind(): string;
  24208. /**
  24209. * Boolean : is the VertexBuffer updatable ?
  24210. */
  24211. isUpdatable(): boolean;
  24212. /**
  24213. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24214. */
  24215. getData(): Nullable<DataArray>;
  24216. /**
  24217. * Returns the WebGLBuffer associated to the VertexBuffer.
  24218. */
  24219. getBuffer(): Nullable<WebGLBuffer>;
  24220. /**
  24221. * Returns the stride as a multiple of the type byte length.
  24222. * DEPRECATED. Use byteStride instead.
  24223. */
  24224. getStrideSize(): number;
  24225. /**
  24226. * Returns the offset as a multiple of the type byte length.
  24227. * DEPRECATED. Use byteOffset instead.
  24228. */
  24229. getOffset(): number;
  24230. /**
  24231. * Returns the number of components per vertex attribute (integer).
  24232. */
  24233. getSize(): number;
  24234. /**
  24235. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24236. */
  24237. getIsInstanced(): boolean;
  24238. /**
  24239. * Returns the instancing divisor, zero for non-instanced (integer).
  24240. */
  24241. getInstanceDivisor(): number;
  24242. /**
  24243. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24244. * Returns the created WebGLBuffer.
  24245. */
  24246. create(data?: DataArray): void;
  24247. /**
  24248. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24249. * This function will create a new buffer if the current one is not updatable
  24250. * Returns the updated WebGLBuffer.
  24251. */
  24252. update(data: DataArray): void;
  24253. /**
  24254. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24255. * Returns the directly updated WebGLBuffer.
  24256. * @param data the new data
  24257. * @param offset the new offset
  24258. * @param useBytes set to true if the offset is in bytes
  24259. */
  24260. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24261. /**
  24262. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24263. */
  24264. dispose(): void;
  24265. /**
  24266. * Enumerates each value of this vertex buffer as numbers.
  24267. * @param count the number of values to enumerate
  24268. * @param callback the callback function called for each value
  24269. */
  24270. forEach(count: number, callback: (value: number, index: number) => void): void;
  24271. private static _PositionKind;
  24272. private static _NormalKind;
  24273. private static _TangentKind;
  24274. private static _UVKind;
  24275. private static _UV2Kind;
  24276. private static _UV3Kind;
  24277. private static _UV4Kind;
  24278. private static _UV5Kind;
  24279. private static _UV6Kind;
  24280. private static _ColorKind;
  24281. private static _MatricesIndicesKind;
  24282. private static _MatricesWeightsKind;
  24283. private static _MatricesIndicesExtraKind;
  24284. private static _MatricesWeightsExtraKind;
  24285. static readonly PositionKind: string;
  24286. static readonly NormalKind: string;
  24287. static readonly TangentKind: string;
  24288. static readonly UVKind: string;
  24289. static readonly UV2Kind: string;
  24290. static readonly UV3Kind: string;
  24291. static readonly UV4Kind: string;
  24292. static readonly UV5Kind: string;
  24293. static readonly UV6Kind: string;
  24294. static readonly ColorKind: string;
  24295. static readonly MatricesIndicesKind: string;
  24296. static readonly MatricesWeightsKind: string;
  24297. static readonly MatricesIndicesExtraKind: string;
  24298. static readonly MatricesWeightsExtraKind: string;
  24299. /**
  24300. * Deduces the stride given a kind.
  24301. * @param kind The kind string to deduce
  24302. * @returns The deduced stride
  24303. */
  24304. static DeduceStride(kind: string): number;
  24305. /**
  24306. * Gets the byte length of the given type.
  24307. * @param type the type
  24308. * @returns the number of bytes
  24309. */
  24310. static GetTypeByteLength(type: number): number;
  24311. /**
  24312. * Enumerates each value of the given parameters as numbers.
  24313. * @param data the data to enumerate
  24314. * @param byteOffset the byte offset of the data
  24315. * @param byteStride the byte stride of the data
  24316. * @param componentCount the number of components per element
  24317. * @param componentType the type of the component
  24318. * @param count the total number of components
  24319. * @param normalized whether the data is normalized
  24320. * @param callback the callback function called for each value
  24321. */
  24322. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24323. private static _GetFloatValue;
  24324. }
  24325. }
  24326. declare module BABYLON {
  24327. /**
  24328. * Defines a target to use with MorphTargetManager
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24330. */
  24331. class MorphTarget implements IAnimatable {
  24332. /** defines the name of the target */
  24333. name: string;
  24334. /**
  24335. * Gets or sets the list of animations
  24336. */
  24337. animations: Animation[];
  24338. private _scene;
  24339. private _positions;
  24340. private _normals;
  24341. private _tangents;
  24342. private _influence;
  24343. /**
  24344. * Observable raised when the influence changes
  24345. */
  24346. onInfluenceChanged: Observable<boolean>;
  24347. /**
  24348. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24349. */
  24350. influence: number;
  24351. private _animationPropertiesOverride;
  24352. /**
  24353. * Gets or sets the animation properties override
  24354. */
  24355. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24356. /**
  24357. * Creates a new MorphTarget
  24358. * @param name defines the name of the target
  24359. * @param influence defines the influence to use
  24360. */
  24361. constructor(
  24362. /** defines the name of the target */
  24363. name: string, influence?: number, scene?: Nullable<Scene>);
  24364. /**
  24365. * Gets a boolean defining if the target contains position data
  24366. */
  24367. readonly hasPositions: boolean;
  24368. /**
  24369. * Gets a boolean defining if the target contains normal data
  24370. */
  24371. readonly hasNormals: boolean;
  24372. /**
  24373. * Gets a boolean defining if the target contains tangent data
  24374. */
  24375. readonly hasTangents: boolean;
  24376. /**
  24377. * Affects position data to this target
  24378. * @param data defines the position data to use
  24379. */
  24380. setPositions(data: Nullable<FloatArray>): void;
  24381. /**
  24382. * Gets the position data stored in this target
  24383. * @returns a FloatArray containing the position data (or null if not present)
  24384. */
  24385. getPositions(): Nullable<FloatArray>;
  24386. /**
  24387. * Affects normal data to this target
  24388. * @param data defines the normal data to use
  24389. */
  24390. setNormals(data: Nullable<FloatArray>): void;
  24391. /**
  24392. * Gets the normal data stored in this target
  24393. * @returns a FloatArray containing the normal data (or null if not present)
  24394. */
  24395. getNormals(): Nullable<FloatArray>;
  24396. /**
  24397. * Affects tangent data to this target
  24398. * @param data defines the tangent data to use
  24399. */
  24400. setTangents(data: Nullable<FloatArray>): void;
  24401. /**
  24402. * Gets the tangent data stored in this target
  24403. * @returns a FloatArray containing the tangent data (or null if not present)
  24404. */
  24405. getTangents(): Nullable<FloatArray>;
  24406. /**
  24407. * Serializes the current target into a Serialization object
  24408. * @returns the serialized object
  24409. */
  24410. serialize(): any;
  24411. /**
  24412. * Creates a new target from serialized data
  24413. * @param serializationObject defines the serialized data to use
  24414. * @returns a new MorphTarget
  24415. */
  24416. static Parse(serializationObject: any): MorphTarget;
  24417. /**
  24418. * Creates a MorphTarget from mesh data
  24419. * @param mesh defines the source mesh
  24420. * @param name defines the name to use for the new target
  24421. * @param influence defines the influence to attach to the target
  24422. * @returns a new MorphTarget
  24423. */
  24424. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24425. }
  24426. }
  24427. declare module BABYLON {
  24428. /**
  24429. * This class is used to deform meshes using morphing between different targets
  24430. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24431. */
  24432. class MorphTargetManager {
  24433. private _targets;
  24434. private _targetObservable;
  24435. private _activeTargets;
  24436. private _scene;
  24437. private _influences;
  24438. private _supportsNormals;
  24439. private _supportsTangents;
  24440. private _vertexCount;
  24441. private _uniqueId;
  24442. private _tempInfluences;
  24443. /**
  24444. * Creates a new MorphTargetManager
  24445. * @param scene defines the current scene
  24446. */
  24447. constructor(scene?: Nullable<Scene>);
  24448. /**
  24449. * Gets the unique ID of this manager
  24450. */
  24451. readonly uniqueId: number;
  24452. /**
  24453. * Gets the number of vertices handled by this manager
  24454. */
  24455. readonly vertexCount: number;
  24456. /**
  24457. * Gets a boolean indicating if this manager supports morphing of normals
  24458. */
  24459. readonly supportsNormals: boolean;
  24460. /**
  24461. * Gets a boolean indicating if this manager supports morphing of tangents
  24462. */
  24463. readonly supportsTangents: boolean;
  24464. /**
  24465. * Gets the number of targets stored in this manager
  24466. */
  24467. readonly numTargets: number;
  24468. /**
  24469. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24470. */
  24471. readonly numInfluencers: number;
  24472. /**
  24473. * Gets the list of influences (one per target)
  24474. */
  24475. readonly influences: Float32Array;
  24476. /**
  24477. * Gets the active target at specified index. An active target is a target with an influence > 0
  24478. * @param index defines the index to check
  24479. * @returns the requested target
  24480. */
  24481. getActiveTarget(index: number): MorphTarget;
  24482. /**
  24483. * Gets the target at specified index
  24484. * @param index defines the index to check
  24485. * @returns the requested target
  24486. */
  24487. getTarget(index: number): MorphTarget;
  24488. /**
  24489. * Add a new target to this manager
  24490. * @param target defines the target to add
  24491. */
  24492. addTarget(target: MorphTarget): void;
  24493. /**
  24494. * Removes a target from the manager
  24495. * @param target defines the target to remove
  24496. */
  24497. removeTarget(target: MorphTarget): void;
  24498. /**
  24499. * Serializes the current manager into a Serialization object
  24500. * @returns the serialized object
  24501. */
  24502. serialize(): any;
  24503. private _syncActiveTargets;
  24504. /**
  24505. * Syncrhonize the targets with all the meshes using this morph target manager
  24506. */
  24507. synchronize(): void;
  24508. /**
  24509. * Creates a new MorphTargetManager from serialized data
  24510. * @param serializationObject defines the serialized data
  24511. * @param scene defines the hosting scene
  24512. * @returns the new MorphTargetManager
  24513. */
  24514. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24515. }
  24516. }
  24517. declare module BABYLON {
  24518. /**
  24519. * This represents the base class for particle system in Babylon.
  24520. * 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.
  24521. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24522. * @example https://doc.babylonjs.com/babylon101/particles
  24523. */
  24524. class BaseParticleSystem {
  24525. /**
  24526. * Source color is added to the destination color without alpha affecting the result.
  24527. */
  24528. static BLENDMODE_ONEONE: number;
  24529. /**
  24530. * Blend current color and particle color using particle’s alpha.
  24531. */
  24532. static BLENDMODE_STANDARD: number;
  24533. /**
  24534. * Add current color and particle color multiplied by particle’s alpha.
  24535. */
  24536. static BLENDMODE_ADD: number;
  24537. /**
  24538. * List of animations used by the particle system.
  24539. */
  24540. animations: Animation[];
  24541. /**
  24542. * The id of the Particle system.
  24543. */
  24544. id: string;
  24545. /**
  24546. * The friendly name of the Particle system.
  24547. */
  24548. name: string;
  24549. /**
  24550. * The rendering group used by the Particle system to chose when to render.
  24551. */
  24552. renderingGroupId: number;
  24553. /**
  24554. * The emitter represents the Mesh or position we are attaching the particle system to.
  24555. */
  24556. emitter: Nullable<AbstractMesh | Vector3>;
  24557. /**
  24558. * The maximum number of particles to emit per frame
  24559. */
  24560. emitRate: number;
  24561. /**
  24562. * If you want to launch only a few particles at once, that can be done, as well.
  24563. */
  24564. manualEmitCount: number;
  24565. /**
  24566. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24567. */
  24568. updateSpeed: number;
  24569. /**
  24570. * The amount of time the particle system is running (depends of the overall update speed).
  24571. */
  24572. targetStopDuration: number;
  24573. /**
  24574. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24575. */
  24576. disposeOnStop: boolean;
  24577. /**
  24578. * Minimum power of emitting particles.
  24579. */
  24580. minEmitPower: number;
  24581. /**
  24582. * Maximum power of emitting particles.
  24583. */
  24584. maxEmitPower: number;
  24585. /**
  24586. * Minimum life time of emitting particles.
  24587. */
  24588. minLifeTime: number;
  24589. /**
  24590. * Maximum life time of emitting particles.
  24591. */
  24592. maxLifeTime: number;
  24593. /**
  24594. * Minimum Size of emitting particles.
  24595. */
  24596. minSize: number;
  24597. /**
  24598. * Maximum Size of emitting particles.
  24599. */
  24600. maxSize: number;
  24601. /**
  24602. * Minimum scale of emitting particles on X axis.
  24603. */
  24604. minScaleX: number;
  24605. /**
  24606. * Maximum scale of emitting particles on X axis.
  24607. */
  24608. maxScaleX: number;
  24609. /**
  24610. * Minimum scale of emitting particles on Y axis.
  24611. */
  24612. minScaleY: number;
  24613. /**
  24614. * Maximum scale of emitting particles on Y axis.
  24615. */
  24616. maxScaleY: number;
  24617. /**
  24618. * Gets or sets the minimal initial rotation in radians.
  24619. */
  24620. minInitialRotation: number;
  24621. /**
  24622. * Gets or sets the maximal initial rotation in radians.
  24623. */
  24624. maxInitialRotation: number;
  24625. /**
  24626. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24627. */
  24628. minAngularSpeed: number;
  24629. /**
  24630. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24631. */
  24632. maxAngularSpeed: number;
  24633. /**
  24634. * The texture used to render each particle. (this can be a spritesheet)
  24635. */
  24636. particleTexture: Nullable<Texture>;
  24637. /**
  24638. * The layer mask we are rendering the particles through.
  24639. */
  24640. layerMask: number;
  24641. /**
  24642. * This can help using your own shader to render the particle system.
  24643. * The according effect will be created
  24644. */
  24645. customShader: any;
  24646. /**
  24647. * By default particle system starts as soon as they are created. This prevents the
  24648. * automatic start to happen and let you decide when to start emitting particles.
  24649. */
  24650. preventAutoStart: boolean;
  24651. /**
  24652. * Gets or sets a texture used to add random noise to particle positions
  24653. */
  24654. noiseTexture: Nullable<BaseTexture>;
  24655. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24656. noiseStrength: Vector3;
  24657. /**
  24658. * Callback triggered when the particle animation is ending.
  24659. */
  24660. onAnimationEnd: Nullable<() => void>;
  24661. /**
  24662. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24663. */
  24664. blendMode: number;
  24665. /**
  24666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24667. * to override the particles.
  24668. */
  24669. forceDepthWrite: boolean;
  24670. /** 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 */
  24671. preWarmCycles: number;
  24672. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24673. preWarmStepOffset: number;
  24674. /**
  24675. * 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)
  24676. */
  24677. spriteCellChangeSpeed: number;
  24678. /**
  24679. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24680. */
  24681. startSpriteCellID: number;
  24682. /**
  24683. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24684. */
  24685. endSpriteCellID: number;
  24686. /**
  24687. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24688. */
  24689. spriteCellWidth: number;
  24690. /**
  24691. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24692. */
  24693. spriteCellHeight: number;
  24694. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24695. translationPivot: Vector2;
  24696. /** @hidden */
  24697. protected _isAnimationSheetEnabled: boolean;
  24698. /**
  24699. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24700. */
  24701. isAnimationSheetEnabled: boolean;
  24702. /**
  24703. * You can use gravity if you want to give an orientation to your particles.
  24704. */
  24705. gravity: Vector3;
  24706. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24707. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24708. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24709. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24710. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24711. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24712. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24713. limitVelocityDamping: number;
  24714. /**
  24715. * Gets the current list of limit velocity gradients.
  24716. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24717. * @returns the list of limit velocity gradients
  24718. */
  24719. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24720. /**
  24721. * Gets the current list of color gradients.
  24722. * You must use addColorGradient and removeColorGradient to udpate this list
  24723. * @returns the list of color gradients
  24724. */
  24725. getColorGradients(): Nullable<Array<ColorGradient>>;
  24726. /**
  24727. * Gets the current list of size gradients.
  24728. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24729. * @returns the list of size gradients
  24730. */
  24731. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24732. /**
  24733. * Gets the current list of life time gradients.
  24734. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24735. * @returns the list of life time gradients
  24736. */
  24737. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24738. /**
  24739. * Gets the current list of angular speed gradients.
  24740. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24741. * @returns the list of angular speed gradients
  24742. */
  24743. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24744. /**
  24745. * Gets the current list of velocity gradients.
  24746. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24747. * @returns the list of velocity gradients
  24748. */
  24749. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24750. /**
  24751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24752. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24753. */
  24754. direction1: Vector3;
  24755. /**
  24756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24757. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24758. */
  24759. direction2: Vector3;
  24760. /**
  24761. * 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.
  24762. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24763. */
  24764. minEmitBox: Vector3;
  24765. /**
  24766. * 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.
  24767. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24768. */
  24769. maxEmitBox: Vector3;
  24770. /**
  24771. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24772. */
  24773. color1: Color4;
  24774. /**
  24775. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24776. */
  24777. color2: Color4;
  24778. /**
  24779. * Color the particle will have at the end of its lifetime
  24780. */
  24781. colorDead: Color4;
  24782. /**
  24783. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24784. */
  24785. textureMask: Color4;
  24786. /**
  24787. * The particle emitter type defines the emitter used by the particle system.
  24788. * It can be for example box, sphere, or cone...
  24789. */
  24790. particleEmitterType: IParticleEmitterType;
  24791. /**
  24792. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24793. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24794. */
  24795. billboardMode: number;
  24796. protected _isBillboardBased: boolean;
  24797. /**
  24798. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24799. */
  24800. isBillboardBased: boolean;
  24801. /**
  24802. * The scene the particle system belongs to.
  24803. */
  24804. protected _scene: Scene;
  24805. /**
  24806. * Local cache of defines for image processing.
  24807. */
  24808. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24809. /**
  24810. * Default configuration related to image processing available in the standard Material.
  24811. */
  24812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24813. /**
  24814. * Gets the image processing configuration used either in this material.
  24815. */
  24816. /**
  24817. * Sets the Default image processing configuration used either in the this material.
  24818. *
  24819. * If sets to null, the scene one is in use.
  24820. */
  24821. imageProcessingConfiguration: ImageProcessingConfiguration;
  24822. /**
  24823. * Attaches a new image processing configuration to the Standard Material.
  24824. * @param configuration
  24825. */
  24826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24827. /** @hidden */
  24828. protected _reset(): void;
  24829. /**
  24830. * Instantiates a particle system.
  24831. * 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.
  24832. * @param name The name of the particle system
  24833. */
  24834. constructor(name: string);
  24835. /**
  24836. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24839. * @returns the emitter
  24840. */
  24841. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24842. /**
  24843. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24844. * @param radius The radius of the hemisphere to emit from
  24845. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24846. * @returns the emitter
  24847. */
  24848. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24849. /**
  24850. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24851. * @param radius The radius of the sphere to emit from
  24852. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24853. * @returns the emitter
  24854. */
  24855. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24856. /**
  24857. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24858. * @param radius The radius of the sphere to emit from
  24859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24861. * @returns the emitter
  24862. */
  24863. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24864. /**
  24865. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24866. * @param radius The radius of the cone to emit from
  24867. * @param angle The base angle of the cone
  24868. * @returns the emitter
  24869. */
  24870. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24871. /**
  24872. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24873. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24874. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24875. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24876. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24877. * @returns the emitter
  24878. */
  24879. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24880. }
  24881. }
  24882. declare module BABYLON {
  24883. /**
  24884. * This represents a GPU particle system in Babylon
  24885. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24886. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24887. */
  24888. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24889. /**
  24890. * The layer mask we are rendering the particles through.
  24891. */
  24892. layerMask: number;
  24893. private _capacity;
  24894. private _activeCount;
  24895. private _currentActiveCount;
  24896. private _accumulatedCount;
  24897. private _renderEffect;
  24898. private _updateEffect;
  24899. private _buffer0;
  24900. private _buffer1;
  24901. private _spriteBuffer;
  24902. private _updateVAO;
  24903. private _renderVAO;
  24904. private _targetIndex;
  24905. private _sourceBuffer;
  24906. private _targetBuffer;
  24907. private _engine;
  24908. private _currentRenderId;
  24909. private _started;
  24910. private _stopped;
  24911. private _timeDelta;
  24912. private _randomTexture;
  24913. private _randomTexture2;
  24914. private _attributesStrideSize;
  24915. private _updateEffectOptions;
  24916. private _randomTextureSize;
  24917. private _actualFrame;
  24918. private readonly _rawTextureWidth;
  24919. /**
  24920. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24921. */
  24922. static readonly IsSupported: boolean;
  24923. /**
  24924. * An event triggered when the system is disposed.
  24925. */
  24926. onDisposeObservable: Observable<GPUParticleSystem>;
  24927. /**
  24928. * Gets the maximum number of particles active at the same time.
  24929. * @returns The max number of active particles.
  24930. */
  24931. getCapacity(): number;
  24932. /**
  24933. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24934. * to override the particles.
  24935. */
  24936. forceDepthWrite: boolean;
  24937. /**
  24938. * Gets or set the number of active particles
  24939. */
  24940. activeParticleCount: number;
  24941. private _preWarmDone;
  24942. /**
  24943. * Is this system ready to be used/rendered
  24944. * @return true if the system is ready
  24945. */
  24946. isReady(): boolean;
  24947. /**
  24948. * Gets Wether the system has been started.
  24949. * @returns True if it has been started, otherwise false.
  24950. */
  24951. isStarted(): boolean;
  24952. /**
  24953. * Starts the particle system and begins to emit
  24954. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24955. */
  24956. start(delay?: number): void;
  24957. /**
  24958. * Stops the particle system.
  24959. */
  24960. stop(): void;
  24961. /**
  24962. * Remove all active particles
  24963. */
  24964. reset(): void;
  24965. /**
  24966. * Returns the string "GPUParticleSystem"
  24967. * @returns a string containing the class name
  24968. */
  24969. getClassName(): string;
  24970. private _colorGradientsTexture;
  24971. private _removeGradient;
  24972. /**
  24973. * Adds a new color gradient
  24974. * @param gradient defines the gradient to use (between 0 and 1)
  24975. * @param color defines the color to affect to the specified gradient
  24976. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24977. * @returns the current particle system
  24978. */
  24979. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24980. /**
  24981. * Remove a specific color gradient
  24982. * @param gradient defines the gradient to remove
  24983. * @returns the current particle system
  24984. */
  24985. removeColorGradient(gradient: number): GPUParticleSystem;
  24986. private _angularSpeedGradientsTexture;
  24987. private _sizeGradientsTexture;
  24988. private _velocityGradientsTexture;
  24989. private _limitVelocityGradientsTexture;
  24990. private _addFactorGradient;
  24991. /**
  24992. * Adds a new size gradient
  24993. * @param gradient defines the gradient to use (between 0 and 1)
  24994. * @param factor defines the size factor to affect to the specified gradient
  24995. * @returns the current particle system
  24996. */
  24997. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24998. /**
  24999. * Remove a specific size gradient
  25000. * @param gradient defines the gradient to remove
  25001. * @returns the current particle system
  25002. */
  25003. removeSizeGradient(gradient: number): GPUParticleSystem;
  25004. /**
  25005. * Adds a new angular speed gradient
  25006. * @param gradient defines the gradient to use (between 0 and 1)
  25007. * @param factor defines the angular speed to affect to the specified gradient
  25008. * @returns the current particle system
  25009. */
  25010. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25011. /**
  25012. * Remove a specific angular speed gradient
  25013. * @param gradient defines the gradient to remove
  25014. * @returns the current particle system
  25015. */
  25016. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25017. /**
  25018. * Adds a new velocity gradient
  25019. * @param gradient defines the gradient to use (between 0 and 1)
  25020. * @param factor defines the velocity to affect to the specified gradient
  25021. * @returns the current particle system
  25022. */
  25023. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25024. /**
  25025. * Remove a specific velocity gradient
  25026. * @param gradient defines the gradient to remove
  25027. * @returns the current particle system
  25028. */
  25029. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25030. /**
  25031. * Adds a new limit velocity gradient
  25032. * @param gradient defines the gradient to use (between 0 and 1)
  25033. * @param factor defines the limit velocity value to affect to the specified gradient
  25034. * @returns the current particle system
  25035. */
  25036. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25037. /**
  25038. * Remove a specific limit velocity gradient
  25039. * @param gradient defines the gradient to remove
  25040. * @returns the current particle system
  25041. */
  25042. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25043. /**
  25044. * Instantiates a GPU particle system.
  25045. * 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.
  25046. * @param name The name of the particle system
  25047. * @param options The options used to create the system
  25048. * @param scene The scene the particle system belongs to
  25049. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25050. */
  25051. constructor(name: string, options: Partial<{
  25052. capacity: number;
  25053. randomTextureSize: number;
  25054. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25055. protected _reset(): void;
  25056. private _createUpdateVAO;
  25057. private _createRenderVAO;
  25058. private _initialize;
  25059. /** @hidden */
  25060. _recreateUpdateEffect(): void;
  25061. /** @hidden */
  25062. _recreateRenderEffect(): void;
  25063. /**
  25064. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25065. * @param preWarm defines if we are in the pre-warmimg phase
  25066. */
  25067. animate(preWarm?: boolean): void;
  25068. private _createFactorGradientTexture;
  25069. private _createSizeGradientTexture;
  25070. private _createAngularSpeedGradientTexture;
  25071. private _createVelocityGradientTexture;
  25072. private _createColorGradientTexture;
  25073. /**
  25074. * Renders the particle system in its current state
  25075. * @param preWarm defines if the system should only update the particles but not render them
  25076. * @returns the current number of particles
  25077. */
  25078. render(preWarm?: boolean): number;
  25079. /**
  25080. * Rebuilds the particle system
  25081. */
  25082. rebuild(): void;
  25083. private _releaseBuffers;
  25084. private _releaseVAOs;
  25085. /**
  25086. * Disposes the particle system and free the associated resources
  25087. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25088. */
  25089. dispose(disposeTexture?: boolean): void;
  25090. /**
  25091. * Clones the particle system.
  25092. * @param name The name of the cloned object
  25093. * @param newEmitter The new emitter to use
  25094. * @returns the cloned particle system
  25095. */
  25096. clone(name: string, newEmitter: any): GPUParticleSystem;
  25097. /**
  25098. * Serializes the particle system to a JSON object.
  25099. * @returns the JSON object
  25100. */
  25101. serialize(): any;
  25102. /**
  25103. * Parses a JSON object to create a GPU particle system.
  25104. * @param parsedParticleSystem The JSON object to parse
  25105. * @param scene The scene to create the particle system in
  25106. * @param rootUrl The root url to use to load external dependencies like texture
  25107. * @returns the parsed GPU particle system
  25108. */
  25109. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25110. }
  25111. }
  25112. declare module BABYLON {
  25113. /**
  25114. * Interface representing a particle system in Babylon.js.
  25115. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25116. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25117. */
  25118. interface IParticleSystem {
  25119. /**
  25120. * List of animations used by the particle system.
  25121. */
  25122. animations: Animation[];
  25123. /**
  25124. * The id of the Particle system.
  25125. */
  25126. id: string;
  25127. /**
  25128. * The name of the Particle system.
  25129. */
  25130. name: string;
  25131. /**
  25132. * The emitter represents the Mesh or position we are attaching the particle system to.
  25133. */
  25134. emitter: Nullable<AbstractMesh | Vector3>;
  25135. /**
  25136. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25137. */
  25138. isBillboardBased: boolean;
  25139. /**
  25140. * The rendering group used by the Particle system to chose when to render.
  25141. */
  25142. renderingGroupId: number;
  25143. /**
  25144. * The layer mask we are rendering the particles through.
  25145. */
  25146. layerMask: number;
  25147. /**
  25148. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25149. */
  25150. updateSpeed: number;
  25151. /**
  25152. * The amount of time the particle system is running (depends of the overall update speed).
  25153. */
  25154. targetStopDuration: number;
  25155. /**
  25156. * The texture used to render each particle. (this can be a spritesheet)
  25157. */
  25158. particleTexture: Nullable<Texture>;
  25159. /**
  25160. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25161. */
  25162. blendMode: number;
  25163. /**
  25164. * Minimum life time of emitting particles.
  25165. */
  25166. minLifeTime: number;
  25167. /**
  25168. * Maximum life time of emitting particles.
  25169. */
  25170. maxLifeTime: number;
  25171. /**
  25172. * Minimum Size of emitting particles.
  25173. */
  25174. minSize: number;
  25175. /**
  25176. * Maximum Size of emitting particles.
  25177. */
  25178. maxSize: number;
  25179. /**
  25180. * Minimum scale of emitting particles on X axis.
  25181. */
  25182. minScaleX: number;
  25183. /**
  25184. * Maximum scale of emitting particles on X axis.
  25185. */
  25186. maxScaleX: number;
  25187. /**
  25188. * Minimum scale of emitting particles on Y axis.
  25189. */
  25190. minScaleY: number;
  25191. /**
  25192. * Maximum scale of emitting particles on Y axis.
  25193. */
  25194. maxScaleY: number;
  25195. /**
  25196. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25197. */
  25198. color1: Color4;
  25199. /**
  25200. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25201. */
  25202. color2: Color4;
  25203. /**
  25204. * Color the particle will have at the end of its lifetime.
  25205. */
  25206. colorDead: Color4;
  25207. /**
  25208. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25209. */
  25210. emitRate: number;
  25211. /**
  25212. * You can use gravity if you want to give an orientation to your particles.
  25213. */
  25214. gravity: Vector3;
  25215. /**
  25216. * Minimum power of emitting particles.
  25217. */
  25218. minEmitPower: number;
  25219. /**
  25220. * Maximum power of emitting particles.
  25221. */
  25222. maxEmitPower: number;
  25223. /**
  25224. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25225. */
  25226. minAngularSpeed: number;
  25227. /**
  25228. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25229. */
  25230. maxAngularSpeed: number;
  25231. /**
  25232. * Gets or sets the minimal initial rotation in radians.
  25233. */
  25234. minInitialRotation: number;
  25235. /**
  25236. * Gets or sets the maximal initial rotation in radians.
  25237. */
  25238. maxInitialRotation: number;
  25239. /**
  25240. * The particle emitter type defines the emitter used by the particle system.
  25241. * It can be for example box, sphere, or cone...
  25242. */
  25243. particleEmitterType: Nullable<IParticleEmitterType>;
  25244. /**
  25245. * 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
  25246. */
  25247. preWarmCycles: number;
  25248. /**
  25249. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25250. */
  25251. preWarmStepOffset: number;
  25252. /**
  25253. * 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)
  25254. */
  25255. spriteCellChangeSpeed: number;
  25256. /**
  25257. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25258. */
  25259. startSpriteCellID: number;
  25260. /**
  25261. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25262. */
  25263. endSpriteCellID: number;
  25264. /**
  25265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25266. */
  25267. spriteCellWidth: number;
  25268. /**
  25269. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25270. */
  25271. spriteCellHeight: number;
  25272. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25273. translationPivot: Vector2;
  25274. /**
  25275. * Gets or sets a texture used to add random noise to particle positions
  25276. */
  25277. noiseTexture: Nullable<BaseTexture>;
  25278. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25279. noiseStrength: Vector3;
  25280. /**
  25281. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25282. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25283. */
  25284. billboardMode: number;
  25285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25286. limitVelocityDamping: number;
  25287. /**
  25288. * Gets the maximum number of particles active at the same time.
  25289. * @returns The max number of active particles.
  25290. */
  25291. getCapacity(): number;
  25292. /**
  25293. * Gets Wether the system has been started.
  25294. * @returns True if it has been started, otherwise false.
  25295. */
  25296. isStarted(): boolean;
  25297. /**
  25298. * Gets if the particle system has been started.
  25299. * @return true if the system has been started, otherwise false.
  25300. */
  25301. isStarted(): boolean;
  25302. /**
  25303. * Animates the particle system for this frame.
  25304. */
  25305. animate(): void;
  25306. /**
  25307. * Renders the particle system in its current state.
  25308. * @returns the current number of particles
  25309. */
  25310. render(): number;
  25311. /**
  25312. * Dispose the particle system and frees its associated resources.
  25313. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25314. */
  25315. dispose(disposeTexture?: boolean): void;
  25316. /**
  25317. * Clones the particle system.
  25318. * @param name The name of the cloned object
  25319. * @param newEmitter The new emitter to use
  25320. * @returns the cloned particle system
  25321. */
  25322. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25323. /**
  25324. * Serializes the particle system to a JSON object.
  25325. * @returns the JSON object
  25326. */
  25327. serialize(): any;
  25328. /**
  25329. * Rebuild the particle system
  25330. */
  25331. rebuild(): void;
  25332. /**
  25333. * Starts the particle system and begins to emit
  25334. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25335. */
  25336. start(delay?: number): void;
  25337. /**
  25338. * Stops the particle system.
  25339. */
  25340. stop(): void;
  25341. /**
  25342. * Remove all active particles
  25343. */
  25344. reset(): void;
  25345. /**
  25346. * Is this system ready to be used/rendered
  25347. * @return true if the system is ready
  25348. */
  25349. isReady(): boolean;
  25350. /**
  25351. * Adds a new color gradient
  25352. * @param gradient defines the gradient to use (between 0 and 1)
  25353. * @param color defines the color to affect to the specified gradient
  25354. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25355. * @returns the current particle system
  25356. */
  25357. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25358. /**
  25359. * Remove a specific color gradient
  25360. * @param gradient defines the gradient to remove
  25361. * @returns the current particle system
  25362. */
  25363. removeColorGradient(gradient: number): IParticleSystem;
  25364. /**
  25365. * Adds a new size gradient
  25366. * @param gradient defines the gradient to use (between 0 and 1)
  25367. * @param factor defines the size factor to affect to the specified gradient
  25368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25369. * @returns the current particle system
  25370. */
  25371. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25372. /**
  25373. * Remove a specific size gradient
  25374. * @param gradient defines the gradient to remove
  25375. * @returns the current particle system
  25376. */
  25377. removeSizeGradient(gradient: number): IParticleSystem;
  25378. /**
  25379. * Gets the current list of color gradients.
  25380. * You must use addColorGradient and removeColorGradient to udpate this list
  25381. * @returns the list of color gradients
  25382. */
  25383. getColorGradients(): Nullable<Array<ColorGradient>>;
  25384. /**
  25385. * Gets the current list of size gradients.
  25386. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25387. * @returns the list of size gradients
  25388. */
  25389. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25390. /**
  25391. * Gets the current list of angular speed gradients.
  25392. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25393. * @returns the list of angular speed gradients
  25394. */
  25395. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25396. /**
  25397. * Adds a new angular speed gradient
  25398. * @param gradient defines the gradient to use (between 0 and 1)
  25399. * @param factor defines the angular speed to affect to the specified gradient
  25400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25401. * @returns the current particle system
  25402. */
  25403. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25404. /**
  25405. * Remove a specific angular speed gradient
  25406. * @param gradient defines the gradient to remove
  25407. * @returns the current particle system
  25408. */
  25409. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25410. /**
  25411. * Gets the current list of velocity gradients.
  25412. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25413. * @returns the list of velocity gradients
  25414. */
  25415. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25416. /**
  25417. * Adds a new velocity gradient
  25418. * @param gradient defines the gradient to use (between 0 and 1)
  25419. * @param factor defines the velocity to affect to the specified gradient
  25420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25421. * @returns the current particle system
  25422. */
  25423. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25424. /**
  25425. * Remove a specific velocity gradient
  25426. * @param gradient defines the gradient to remove
  25427. * @returns the current particle system
  25428. */
  25429. removeVelocityGradient(gradient: number): IParticleSystem;
  25430. /**
  25431. * Gets the current list of limit velocity gradients.
  25432. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25433. * @returns the list of limit velocity gradients
  25434. */
  25435. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25436. /**
  25437. * Adds a new limit velocity gradient
  25438. * @param gradient defines the gradient to use (between 0 and 1)
  25439. * @param factor defines the limit velocity to affect to the specified gradient
  25440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25441. * @returns the current particle system
  25442. */
  25443. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25444. /**
  25445. * Remove a specific limit velocity gradient
  25446. * @param gradient defines the gradient to remove
  25447. * @returns the current particle system
  25448. */
  25449. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25450. }
  25451. }
  25452. declare module BABYLON {
  25453. /**
  25454. * A particle represents one of the element emitted by a particle system.
  25455. * This is mainly define by its coordinates, direction, velocity and age.
  25456. */
  25457. class Particle {
  25458. /**
  25459. * particleSystem the particle system the particle belongs to.
  25460. */
  25461. particleSystem: ParticleSystem;
  25462. /**
  25463. * The world position of the particle in the scene.
  25464. */
  25465. position: Vector3;
  25466. /**
  25467. * The world direction of the particle in the scene.
  25468. */
  25469. direction: Vector3;
  25470. /**
  25471. * The color of the particle.
  25472. */
  25473. color: Color4;
  25474. /**
  25475. * The color change of the particle per step.
  25476. */
  25477. colorStep: Color4;
  25478. /**
  25479. * Defines how long will the life of the particle be.
  25480. */
  25481. lifeTime: number;
  25482. /**
  25483. * The current age of the particle.
  25484. */
  25485. age: number;
  25486. /**
  25487. * The current size of the particle.
  25488. */
  25489. size: number;
  25490. /**
  25491. * The current scale of the particle.
  25492. */
  25493. scale: Vector2;
  25494. /**
  25495. * The current angle of the particle.
  25496. */
  25497. angle: number;
  25498. /**
  25499. * Defines how fast is the angle changing.
  25500. */
  25501. angularSpeed: number;
  25502. /**
  25503. * Defines the cell index used by the particle to be rendered from a sprite.
  25504. */
  25505. cellIndex: number;
  25506. /** @hidden */
  25507. _initialDirection: Nullable<Vector3>;
  25508. /** @hidden */
  25509. _initialStartSpriteCellID: number;
  25510. _initialEndSpriteCellID: number;
  25511. /** @hidden */
  25512. _currentColorGradient: Nullable<ColorGradient>;
  25513. /** @hidden */
  25514. _currentColor1: Color4;
  25515. /** @hidden */
  25516. _currentColor2: Color4;
  25517. /** @hidden */
  25518. _currentSizeGradient: Nullable<FactorGradient>;
  25519. /** @hidden */
  25520. _currentSize1: number;
  25521. /** @hidden */
  25522. _currentSize2: number;
  25523. /** @hidden */
  25524. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25525. /** @hidden */
  25526. _currentAngularSpeed1: number;
  25527. /** @hidden */
  25528. _currentAngularSpeed2: number;
  25529. /** @hidden */
  25530. _currentVelocityGradient: Nullable<FactorGradient>;
  25531. /** @hidden */
  25532. _currentVelocity1: number;
  25533. /** @hidden */
  25534. _currentVelocity2: number;
  25535. /** @hidden */
  25536. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25537. /** @hidden */
  25538. _currentLimitVelocity1: number;
  25539. /** @hidden */
  25540. _currentLimitVelocity2: number;
  25541. /**
  25542. * Creates a new instance Particle
  25543. * @param particleSystem the particle system the particle belongs to
  25544. */
  25545. constructor(
  25546. /**
  25547. * particleSystem the particle system the particle belongs to.
  25548. */
  25549. particleSystem: ParticleSystem);
  25550. private updateCellInfoFromSystem;
  25551. /**
  25552. * Defines how the sprite cell index is updated for the particle
  25553. */
  25554. updateCellIndex(): void;
  25555. /**
  25556. * Copy the properties of particle to another one.
  25557. * @param other the particle to copy the information to.
  25558. */
  25559. copyTo(other: Particle): void;
  25560. }
  25561. }
  25562. declare module BABYLON {
  25563. /**
  25564. * This class is made for on one-liner static method to help creating particle system set.
  25565. */
  25566. class ParticleHelper {
  25567. /**
  25568. * Gets or sets base Assets URL
  25569. */
  25570. static BaseAssetsUrl: string;
  25571. /**
  25572. * Create a default particle system that you can tweak
  25573. * @param emitter defines the emitter to use
  25574. * @param capacity defines the system capacity (default is 500 particles)
  25575. * @param scene defines the hosting scene
  25576. * @returns the new Particle system
  25577. */
  25578. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene): ParticleSystem;
  25579. /**
  25580. * This is the main static method (one-liner) of this helper to create different particle systems
  25581. * @param type This string represents the type to the particle system to create
  25582. * @param scene The scene where the particle system should live
  25583. * @param gpu If the system will use gpu
  25584. * @returns the ParticleSystemSet created
  25585. */
  25586. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25587. /**
  25588. * Static function used to export a particle system to a ParticleSystemSet variable.
  25589. * Please note that the emitter shape is not exported
  25590. * @param system defines the particle systems to export
  25591. */
  25592. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25593. }
  25594. }
  25595. declare module BABYLON {
  25596. /**
  25597. * This represents a particle system in Babylon.
  25598. * 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.
  25599. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25600. * @example https://doc.babylonjs.com/babylon101/particles
  25601. */
  25602. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25603. /**
  25604. * This function can be defined to provide custom update for active particles.
  25605. * This function will be called instead of regular update (age, position, color, etc.).
  25606. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25607. */
  25608. updateFunction: (particles: Particle[]) => void;
  25609. private _emitterWorldMatrix;
  25610. /**
  25611. * This function can be defined to specify initial direction for every new particle.
  25612. * It by default use the emitterType defined function
  25613. */
  25614. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25615. /**
  25616. * This function can be defined to specify initial position for every new particle.
  25617. * It by default use the emitterType defined function
  25618. */
  25619. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25620. /**
  25621. * An event triggered when the system is disposed
  25622. */
  25623. onDisposeObservable: Observable<ParticleSystem>;
  25624. private _onDisposeObserver;
  25625. /**
  25626. * Sets a callback that will be triggered when the system is disposed
  25627. */
  25628. onDispose: () => void;
  25629. /**
  25630. * Get hosting scene
  25631. * @returns the scene
  25632. */
  25633. getScene(): Scene;
  25634. private _particles;
  25635. private _epsilon;
  25636. private _capacity;
  25637. private _stockParticles;
  25638. private _newPartsExcess;
  25639. private _vertexData;
  25640. private _vertexBuffer;
  25641. private _vertexBuffers;
  25642. private _spriteBuffer;
  25643. private _indexBuffer;
  25644. private _effect;
  25645. private _customEffect;
  25646. private _cachedDefines;
  25647. private _scaledColorStep;
  25648. private _colorDiff;
  25649. private _scaledDirection;
  25650. private _scaledGravity;
  25651. private _currentRenderId;
  25652. private _alive;
  25653. private _useInstancing;
  25654. private _started;
  25655. private _stopped;
  25656. private _actualFrame;
  25657. private _scaledUpdateSpeed;
  25658. private _vertexBufferSize;
  25659. /**
  25660. * 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.
  25661. */
  25662. subEmitters: ParticleSystem[];
  25663. /**
  25664. * The current active Sub-systems, this property is used by the root particle system only.
  25665. */
  25666. activeSubSystems: Array<ParticleSystem>;
  25667. private _rootParticleSystem;
  25668. /**
  25669. * Gets the current list of active particles
  25670. */
  25671. readonly particles: Particle[];
  25672. /**
  25673. * Returns the string "ParticleSystem"
  25674. * @returns a string containing the class name
  25675. */
  25676. getClassName(): string;
  25677. /**
  25678. * Instantiates a particle system.
  25679. * 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.
  25680. * @param name The name of the particle system
  25681. * @param capacity The max number of particles alive at the same time
  25682. * @param scene The scene the particle system belongs to
  25683. * @param customEffect a custom effect used to change the way particles are rendered by default
  25684. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25685. * @param epsilon Offset used to render the particles
  25686. */
  25687. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25688. private _addFactorGradient;
  25689. private _removeFactorGradient;
  25690. /**
  25691. * Adds a new life time gradient
  25692. * @param gradient defines the gradient to use (between 0 and 1)
  25693. * @param factor defines the life time factor to affect to the specified gradient
  25694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25695. * @returns the current particle system
  25696. */
  25697. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25698. /**
  25699. * Remove a specific life time gradient
  25700. * @param gradient defines the gradient to remove
  25701. * @returns the current particle system
  25702. */
  25703. removeLifeTimeGradient(gradient: number): IParticleSystem;
  25704. /**
  25705. * Adds a new size gradient
  25706. * @param gradient defines the gradient to use (between 0 and 1)
  25707. * @param factor defines the size factor to affect to the specified gradient
  25708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25709. * @returns the current particle system
  25710. */
  25711. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25712. /**
  25713. * Remove a specific size gradient
  25714. * @param gradient defines the gradient to remove
  25715. * @returns the current particle system
  25716. */
  25717. removeSizeGradient(gradient: number): IParticleSystem;
  25718. /**
  25719. * Adds a new angular speed gradient
  25720. * @param gradient defines the gradient to use (between 0 and 1)
  25721. * @param factor defines the angular speed to affect to the specified gradient
  25722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25723. * @returns the current particle system
  25724. */
  25725. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25726. /**
  25727. * Remove a specific angular speed gradient
  25728. * @param gradient defines the gradient to remove
  25729. * @returns the current particle system
  25730. */
  25731. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25732. /**
  25733. * Adds a new velocity gradient
  25734. * @param gradient defines the gradient to use (between 0 and 1)
  25735. * @param factor defines the velocity to affect to the specified gradient
  25736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25737. * @returns the current particle system
  25738. */
  25739. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25740. /**
  25741. * Remove a specific velocity gradient
  25742. * @param gradient defines the gradient to remove
  25743. * @returns the current particle system
  25744. */
  25745. removeVelocityGradient(gradient: number): IParticleSystem;
  25746. /**
  25747. * Adds a new limit velocity gradient
  25748. * @param gradient defines the gradient to use (between 0 and 1)
  25749. * @param factor defines the limit velocity value to affect to the specified gradient
  25750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25751. * @returns the current particle system
  25752. */
  25753. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25754. /**
  25755. * Remove a specific limit velocity gradient
  25756. * @param gradient defines the gradient to remove
  25757. * @returns the current particle system
  25758. */
  25759. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25760. /**
  25761. * Adds a new color gradient
  25762. * @param gradient defines the gradient to use (between 0 and 1)
  25763. * @param color defines the color to affect to the specified gradient
  25764. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25765. */
  25766. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  25767. /**
  25768. * Remove a specific color gradient
  25769. * @param gradient defines the gradient to remove
  25770. */
  25771. removeColorGradient(gradient: number): IParticleSystem;
  25772. private _fetchR;
  25773. protected _reset(): void;
  25774. private _resetEffect;
  25775. private _createVertexBuffers;
  25776. private _createIndexBuffer;
  25777. /**
  25778. * Gets the maximum number of particles active at the same time.
  25779. * @returns The max number of active particles.
  25780. */
  25781. getCapacity(): number;
  25782. /**
  25783. * Gets whether there are still active particles in the system.
  25784. * @returns True if it is alive, otherwise false.
  25785. */
  25786. isAlive(): boolean;
  25787. /**
  25788. * Gets whether the system has been started.
  25789. * @returns True if it has been started, otherwise false.
  25790. */
  25791. isStarted(): boolean;
  25792. /**
  25793. * Starts the particle system and begins to emit
  25794. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25795. */
  25796. start(delay?: number): void;
  25797. /**
  25798. * Stops the particle system.
  25799. * @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.
  25800. */
  25801. stop(stopSubEmitters?: boolean): void;
  25802. /**
  25803. * Remove all active particles
  25804. */
  25805. reset(): void;
  25806. /**
  25807. * @hidden (for internal use only)
  25808. */
  25809. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25810. /**
  25811. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25812. * Its lifetime will start back at 0.
  25813. */
  25814. recycleParticle: (particle: Particle) => void;
  25815. private _stopSubEmitters;
  25816. private _createParticle;
  25817. private _removeFromRoot;
  25818. private _emitFromParticle;
  25819. private _update;
  25820. /** @hidden */
  25821. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25822. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25823. private _getEffect;
  25824. /**
  25825. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25826. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25827. */
  25828. animate(preWarmOnly?: boolean): void;
  25829. private _appendParticleVertices;
  25830. /**
  25831. * Rebuilds the particle system.
  25832. */
  25833. rebuild(): void;
  25834. /**
  25835. * Is this system ready to be used/rendered
  25836. * @return true if the system is ready
  25837. */
  25838. isReady(): boolean;
  25839. /**
  25840. * Renders the particle system in its current state.
  25841. * @returns the current number of particles
  25842. */
  25843. render(): number;
  25844. /**
  25845. * Disposes the particle system and free the associated resources
  25846. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25847. */
  25848. dispose(disposeTexture?: boolean): void;
  25849. /**
  25850. * Clones the particle system.
  25851. * @param name The name of the cloned object
  25852. * @param newEmitter The new emitter to use
  25853. * @returns the cloned particle system
  25854. */
  25855. clone(name: string, newEmitter: any): ParticleSystem;
  25856. /**
  25857. * Serializes the particle system to a JSON object.
  25858. * @returns the JSON object
  25859. */
  25860. serialize(): any;
  25861. /** @hidden */
  25862. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  25863. /** @hidden */
  25864. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  25865. /**
  25866. * Parses a JSON object to create a particle system.
  25867. * @param parsedParticleSystem The JSON object to parse
  25868. * @param scene The scene to create the particle system in
  25869. * @param rootUrl The root url to use to load external dependencies like texture
  25870. * @returns the Parsed particle system
  25871. */
  25872. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  25873. }
  25874. }
  25875. declare module BABYLON {
  25876. interface Engine {
  25877. /**
  25878. * Create an effect to use with particle systems.
  25879. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  25880. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  25881. * @param uniformsNames defines a list of attribute names
  25882. * @param samplers defines an array of string used to represent textures
  25883. * @param defines defines the string containing the defines to use to compile the shaders
  25884. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  25885. * @param onCompiled defines a function to call when the effect creation is successful
  25886. * @param onError defines a function to call when the effect creation has failed
  25887. * @returns the new Effect
  25888. */
  25889. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  25890. }
  25891. }
  25892. declare module BABYLON {
  25893. /**
  25894. * Represents a set of particle systems working together to create a specific effect
  25895. */
  25896. class ParticleSystemSet implements IDisposable {
  25897. private _emitterCreationOptions;
  25898. private _emitterNode;
  25899. /**
  25900. * Gets the particle system list
  25901. */
  25902. systems: IParticleSystem[];
  25903. /**
  25904. * Gets the emitter node used with this set
  25905. */
  25906. readonly emitterNode: Nullable<TransformNode>;
  25907. /**
  25908. * Creates a new emitter mesh as a sphere
  25909. * @param options defines the options used to create the sphere
  25910. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  25911. * @param scene defines the hosting scene
  25912. */
  25913. setEmitterAsSphere(options: {
  25914. diameter: number;
  25915. segments: number;
  25916. color: Color3;
  25917. }, renderingGroupId: number, scene: Scene): void;
  25918. /**
  25919. * Starts all particle systems of the set
  25920. * @param emitter defines an optional mesh to use as emitter for the particle systems
  25921. */
  25922. start(emitter?: AbstractMesh): void;
  25923. /**
  25924. * Release all associated resources
  25925. */
  25926. dispose(): void;
  25927. /**
  25928. * Serialize the set into a JSON compatible object
  25929. * @returns a JSON compatible representation of the set
  25930. */
  25931. serialize(): any;
  25932. /**
  25933. * Parse a new ParticleSystemSet from a serialized source
  25934. * @param data defines a JSON compatible representation of the set
  25935. * @param scene defines the hosting scene
  25936. * @param gpu defines if we want GPU particles or CPU particles
  25937. * @returns a new ParticleSystemSet
  25938. */
  25939. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  25940. }
  25941. }
  25942. declare module BABYLON {
  25943. /**
  25944. * Represents one particle of a solid particle system.
  25945. */
  25946. class SolidParticle {
  25947. /**
  25948. * particle global index
  25949. */
  25950. idx: number;
  25951. /**
  25952. * The color of the particle
  25953. */
  25954. color: Nullable<Color4>;
  25955. /**
  25956. * The world space position of the particle.
  25957. */
  25958. position: Vector3;
  25959. /**
  25960. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25961. */
  25962. rotation: Vector3;
  25963. /**
  25964. * The world space rotation quaternion of the particle.
  25965. */
  25966. rotationQuaternion: Nullable<Quaternion>;
  25967. /**
  25968. * The scaling of the particle.
  25969. */
  25970. scaling: Vector3;
  25971. /**
  25972. * The uvs of the particle.
  25973. */
  25974. uvs: Vector4;
  25975. /**
  25976. * The current speed of the particle.
  25977. */
  25978. velocity: Vector3;
  25979. /**
  25980. * The pivot point in the particle local space.
  25981. */
  25982. pivot: Vector3;
  25983. /**
  25984. * Must the particle be translated from its pivot point in its local space ?
  25985. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25986. * Default : false
  25987. */
  25988. translateFromPivot: boolean;
  25989. /**
  25990. * Is the particle active or not ?
  25991. */
  25992. alive: boolean;
  25993. /**
  25994. * Is the particle visible or not ?
  25995. */
  25996. isVisible: boolean;
  25997. /**
  25998. * Index of this particle in the global "positions" array (Internal use)
  25999. * @hidden
  26000. */
  26001. _pos: number;
  26002. /**
  26003. * @hidden Index of this particle in the global "indices" array (Internal use)
  26004. */
  26005. _ind: number;
  26006. /**
  26007. * @hidden ModelShape of this particle (Internal use)
  26008. */
  26009. _model: ModelShape;
  26010. /**
  26011. * ModelShape id of this particle
  26012. */
  26013. shapeId: number;
  26014. /**
  26015. * Index of the particle in its shape id (Internal use)
  26016. */
  26017. idxInShape: number;
  26018. /**
  26019. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26020. */
  26021. _modelBoundingInfo: BoundingInfo;
  26022. /**
  26023. * @hidden Particle BoundingInfo object (Internal use)
  26024. */
  26025. _boundingInfo: BoundingInfo;
  26026. /**
  26027. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26028. */
  26029. _sps: SolidParticleSystem;
  26030. /**
  26031. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26032. */
  26033. _stillInvisible: boolean;
  26034. /**
  26035. * @hidden Last computed particle rotation matrix
  26036. */
  26037. _rotationMatrix: number[];
  26038. /**
  26039. * Parent particle Id, if any.
  26040. * Default null.
  26041. */
  26042. parentId: Nullable<number>;
  26043. /**
  26044. * @hidden Internal global position in the SPS.
  26045. */
  26046. _globalPosition: Vector3;
  26047. /**
  26048. * Creates a Solid Particle object.
  26049. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26050. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26051. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26052. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26053. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26054. * @param shapeId (integer) is the model shape identifier in the SPS.
  26055. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26056. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26057. */
  26058. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26059. /**
  26060. * Legacy support, changed scale to scaling
  26061. */
  26062. /**
  26063. * Legacy support, changed scale to scaling
  26064. */
  26065. scale: Vector3;
  26066. /**
  26067. * Legacy support, changed quaternion to rotationQuaternion
  26068. */
  26069. /**
  26070. * Legacy support, changed quaternion to rotationQuaternion
  26071. */
  26072. quaternion: Nullable<Quaternion>;
  26073. /**
  26074. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26075. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26076. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26077. * @returns true if it intersects
  26078. */
  26079. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26080. }
  26081. /**
  26082. * Represents the shape of the model used by one particle of a solid particle system.
  26083. * SPS internal tool, don't use it manually.
  26084. */
  26085. class ModelShape {
  26086. /**
  26087. * The shape id
  26088. * @hidden
  26089. */
  26090. shapeID: number;
  26091. /**
  26092. * flat array of model positions (internal use)
  26093. * @hidden
  26094. */
  26095. _shape: Vector3[];
  26096. /**
  26097. * flat array of model UVs (internal use)
  26098. * @hidden
  26099. */
  26100. _shapeUV: number[];
  26101. /**
  26102. * length of the shape in the model indices array (internal use)
  26103. * @hidden
  26104. */
  26105. _indicesLength: number;
  26106. /**
  26107. * Custom position function (internal use)
  26108. * @hidden
  26109. */
  26110. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26111. /**
  26112. * Custom vertex function (internal use)
  26113. * @hidden
  26114. */
  26115. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26116. /**
  26117. * 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.
  26118. * SPS internal tool, don't use it manually.
  26119. * @hidden
  26120. */
  26121. 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>);
  26122. }
  26123. /**
  26124. * Represents a Depth Sorted Particle in the solid particle system.
  26125. */
  26126. class DepthSortedParticle {
  26127. /**
  26128. * Index of the particle in the "indices" array
  26129. */
  26130. ind: number;
  26131. /**
  26132. * Length of the particle shape in the "indices" array
  26133. */
  26134. indicesLength: number;
  26135. /**
  26136. * Squared distance from the particle to the camera
  26137. */
  26138. sqDistance: number;
  26139. }
  26140. }
  26141. declare module BABYLON {
  26142. /**
  26143. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26144. *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.
  26145. * The SPS is also a particle system. It provides some methods to manage the particles.
  26146. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26147. *
  26148. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26149. */
  26150. class SolidParticleSystem implements IDisposable {
  26151. /**
  26152. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26153. * Example : var p = SPS.particles[i];
  26154. */
  26155. particles: SolidParticle[];
  26156. /**
  26157. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26158. */
  26159. nbParticles: number;
  26160. /**
  26161. * If the particles must ever face the camera (default false). Useful for planar particles.
  26162. */
  26163. billboard: boolean;
  26164. /**
  26165. * Recompute normals when adding a shape
  26166. */
  26167. recomputeNormals: boolean;
  26168. /**
  26169. * This a counter ofr your own usage. It's not set by any SPS functions.
  26170. */
  26171. counter: number;
  26172. /**
  26173. * The SPS name. This name is also given to the underlying mesh.
  26174. */
  26175. name: string;
  26176. /**
  26177. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26178. */
  26179. mesh: Mesh;
  26180. /**
  26181. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26182. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26183. */
  26184. vars: any;
  26185. /**
  26186. * This array is populated when the SPS is set as 'pickable'.
  26187. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26188. * Each element of this array is an object `{idx: int, faceId: int}`.
  26189. * `idx` is the picked particle index in the `SPS.particles` array
  26190. * `faceId` is the picked face index counted within this particle.
  26191. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26192. */
  26193. pickedParticles: {
  26194. idx: number;
  26195. faceId: number;
  26196. }[];
  26197. /**
  26198. * This array is populated when `enableDepthSort` is set to true.
  26199. * Each element of this array is an instance of the class DepthSortedParticle.
  26200. */
  26201. depthSortedParticles: DepthSortedParticle[];
  26202. /**
  26203. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26204. * @hidden
  26205. */
  26206. _bSphereOnly: boolean;
  26207. /**
  26208. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26209. * @hidden
  26210. */
  26211. _bSphereRadiusFactor: number;
  26212. private _scene;
  26213. private _positions;
  26214. private _indices;
  26215. private _normals;
  26216. private _colors;
  26217. private _uvs;
  26218. private _indices32;
  26219. private _positions32;
  26220. private _normals32;
  26221. private _fixedNormal32;
  26222. private _colors32;
  26223. private _uvs32;
  26224. private _index;
  26225. private _updatable;
  26226. private _pickable;
  26227. private _isVisibilityBoxLocked;
  26228. private _alwaysVisible;
  26229. private _depthSort;
  26230. private _shapeCounter;
  26231. private _copy;
  26232. private _shape;
  26233. private _shapeUV;
  26234. private _color;
  26235. private _computeParticleColor;
  26236. private _computeParticleTexture;
  26237. private _computeParticleRotation;
  26238. private _computeParticleVertex;
  26239. private _computeBoundingBox;
  26240. private _depthSortParticles;
  26241. private _cam_axisZ;
  26242. private _cam_axisY;
  26243. private _cam_axisX;
  26244. private _axisZ;
  26245. private _camera;
  26246. private _particle;
  26247. private _camDir;
  26248. private _camInvertedPosition;
  26249. private _rotMatrix;
  26250. private _invertMatrix;
  26251. private _rotated;
  26252. private _quaternion;
  26253. private _vertex;
  26254. private _normal;
  26255. private _yaw;
  26256. private _pitch;
  26257. private _roll;
  26258. private _halfroll;
  26259. private _halfpitch;
  26260. private _halfyaw;
  26261. private _sinRoll;
  26262. private _cosRoll;
  26263. private _sinPitch;
  26264. private _cosPitch;
  26265. private _sinYaw;
  26266. private _cosYaw;
  26267. private _mustUnrotateFixedNormals;
  26268. private _minimum;
  26269. private _maximum;
  26270. private _minBbox;
  26271. private _maxBbox;
  26272. private _particlesIntersect;
  26273. private _depthSortFunction;
  26274. private _needs32Bits;
  26275. private _pivotBackTranslation;
  26276. private _scaledPivot;
  26277. private _particleHasParent;
  26278. private _parent;
  26279. /**
  26280. * Creates a SPS (Solid Particle System) object.
  26281. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26282. * @param scene (Scene) is the scene in which the SPS is added.
  26283. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26284. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26285. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26286. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26287. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26288. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26289. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26290. */
  26291. constructor(name: string, scene: Scene, options?: {
  26292. updatable?: boolean;
  26293. isPickable?: boolean;
  26294. enableDepthSort?: boolean;
  26295. particleIntersection?: boolean;
  26296. boundingSphereOnly?: boolean;
  26297. bSphereRadiusFactor?: number;
  26298. });
  26299. /**
  26300. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26301. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26302. * @returns the created mesh
  26303. */
  26304. buildMesh(): Mesh;
  26305. /**
  26306. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26307. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26308. * Thus the particles generated from `digest()` have their property `position` set yet.
  26309. * @param mesh ( Mesh ) is the mesh to be digested
  26310. * @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
  26311. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26312. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26313. * @returns the current SPS
  26314. */
  26315. digest(mesh: Mesh, options?: {
  26316. facetNb?: number;
  26317. number?: number;
  26318. delta?: number;
  26319. }): SolidParticleSystem;
  26320. private _unrotateFixedNormals;
  26321. private _resetCopy;
  26322. private _meshBuilder;
  26323. private _posToShape;
  26324. private _uvsToShapeUV;
  26325. private _addParticle;
  26326. /**
  26327. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26328. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26329. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26330. * @param nb (positive integer) the number of particles to be created from this model
  26331. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26332. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26333. * @returns the number of shapes in the system
  26334. */
  26335. addShape(mesh: Mesh, nb: number, options?: {
  26336. positionFunction?: any;
  26337. vertexFunction?: any;
  26338. }): number;
  26339. private _rebuildParticle;
  26340. /**
  26341. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26342. * @returns the SPS.
  26343. */
  26344. rebuildMesh(): SolidParticleSystem;
  26345. /**
  26346. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26347. * This method calls `updateParticle()` for each particle of the SPS.
  26348. * For an animated SPS, it is usually called within the render loop.
  26349. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26350. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26351. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26352. * @returns the SPS.
  26353. */
  26354. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26355. private _quaternionRotationYPR;
  26356. private _quaternionToRotationMatrix;
  26357. /**
  26358. * Disposes the SPS.
  26359. */
  26360. dispose(): void;
  26361. /**
  26362. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26363. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26364. * @returns the SPS.
  26365. */
  26366. refreshVisibleSize(): SolidParticleSystem;
  26367. /**
  26368. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26369. * @param size the size (float) of the visibility box
  26370. * note : this doesn't lock the SPS mesh bounding box.
  26371. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26372. */
  26373. setVisibilityBox(size: number): void;
  26374. /**
  26375. * Gets whether the SPS as always visible or not
  26376. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26377. */
  26378. /**
  26379. * Sets the SPS as always visible or not
  26380. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26381. */
  26382. isAlwaysVisible: boolean;
  26383. /**
  26384. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26385. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26386. */
  26387. /**
  26388. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26389. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26390. */
  26391. isVisibilityBoxLocked: boolean;
  26392. /**
  26393. * Tells to `setParticles()` to compute the particle rotations or not.
  26394. * Default value : true. The SPS is faster when it's set to false.
  26395. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26396. */
  26397. /**
  26398. * Gets if `setParticles()` computes the particle rotations or not.
  26399. * Default value : true. The SPS is faster when it's set to false.
  26400. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26401. */
  26402. computeParticleRotation: boolean;
  26403. /**
  26404. * Tells to `setParticles()` to compute the particle colors or not.
  26405. * Default value : true. The SPS is faster when it's set to false.
  26406. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26407. */
  26408. /**
  26409. * Gets if `setParticles()` computes the particle colors or not.
  26410. * Default value : true. The SPS is faster when it's set to false.
  26411. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26412. */
  26413. computeParticleColor: boolean;
  26414. /**
  26415. * Gets if `setParticles()` computes the particle textures or not.
  26416. * Default value : true. The SPS is faster when it's set to false.
  26417. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26418. */
  26419. computeParticleTexture: boolean;
  26420. /**
  26421. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26422. * Default value : false. The SPS is faster when it's set to false.
  26423. * Note : the particle custom vertex positions aren't stored values.
  26424. */
  26425. /**
  26426. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26427. * Default value : false. The SPS is faster when it's set to false.
  26428. * Note : the particle custom vertex positions aren't stored values.
  26429. */
  26430. computeParticleVertex: boolean;
  26431. /**
  26432. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26433. */
  26434. /**
  26435. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26436. */
  26437. computeBoundingBox: boolean;
  26438. /**
  26439. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26440. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26441. * Default : `true`
  26442. */
  26443. /**
  26444. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26445. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26446. * Default : `true`
  26447. */
  26448. depthSortParticles: boolean;
  26449. /**
  26450. * This function does nothing. It may be overwritten to set all the particle first values.
  26451. * The SPS doesn't call this function, you may have to call it by your own.
  26452. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26453. */
  26454. initParticles(): void;
  26455. /**
  26456. * This function does nothing. It may be overwritten to recycle a particle.
  26457. * The SPS doesn't call this function, you may have to call it by your own.
  26458. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26459. * @param particle The particle to recycle
  26460. * @returns the recycled particle
  26461. */
  26462. recycleParticle(particle: SolidParticle): SolidParticle;
  26463. /**
  26464. * Updates a particle : this function should be overwritten by the user.
  26465. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26466. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26467. * @example : just set a particle position or velocity and recycle conditions
  26468. * @param particle The particle to update
  26469. * @returns the updated particle
  26470. */
  26471. updateParticle(particle: SolidParticle): SolidParticle;
  26472. /**
  26473. * Updates a vertex of a particle : it can be overwritten by the user.
  26474. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26475. * @param particle the current particle
  26476. * @param vertex the current index of the current particle
  26477. * @param pt the index of the current vertex in the particle shape
  26478. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26479. * @example : just set a vertex particle position
  26480. * @returns the updated vertex
  26481. */
  26482. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26483. /**
  26484. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26485. * This does nothing and may be overwritten by the user.
  26486. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26487. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26488. * @param update the boolean update value actually passed to setParticles()
  26489. */
  26490. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26491. /**
  26492. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26493. * This will be passed three parameters.
  26494. * This does nothing and may be overwritten by the user.
  26495. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26496. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26497. * @param update the boolean update value actually passed to setParticles()
  26498. */
  26499. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26500. }
  26501. }
  26502. declare module BABYLON {
  26503. interface PhysicsImpostorJoint {
  26504. mainImpostor: PhysicsImpostor;
  26505. connectedImpostor: PhysicsImpostor;
  26506. joint: PhysicsJoint;
  26507. }
  26508. class PhysicsEngine {
  26509. private _physicsPlugin;
  26510. gravity: Vector3;
  26511. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  26512. setGravity(gravity: Vector3): void;
  26513. /**
  26514. * Set the time step of the physics engine.
  26515. * default is 1/60.
  26516. * To slow it down, enter 1/600 for example.
  26517. * To speed it up, 1/30
  26518. * @param {number} newTimeStep the new timestep to apply to this world.
  26519. */
  26520. setTimeStep(newTimeStep?: number): void;
  26521. /**
  26522. * Get the time step of the physics engine.
  26523. */
  26524. getTimeStep(): number;
  26525. dispose(): void;
  26526. getPhysicsPluginName(): string;
  26527. static Epsilon: number;
  26528. private _impostors;
  26529. private _joints;
  26530. /**
  26531. * Adding a new impostor for the impostor tracking.
  26532. * This will be done by the impostor itself.
  26533. * @param {PhysicsImpostor} impostor the impostor to add
  26534. */
  26535. addImpostor(impostor: PhysicsImpostor): void;
  26536. /**
  26537. * Remove an impostor from the engine.
  26538. * This impostor and its mesh will not longer be updated by the physics engine.
  26539. * @param {PhysicsImpostor} impostor the impostor to remove
  26540. */
  26541. removeImpostor(impostor: PhysicsImpostor): void;
  26542. /**
  26543. * Add a joint to the physics engine
  26544. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  26545. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  26546. * @param {PhysicsJoint} the joint that will connect both impostors.
  26547. */
  26548. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26549. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26550. /**
  26551. * Called by the scene. no need to call it.
  26552. * @hidden
  26553. */
  26554. _step(delta: number): void;
  26555. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26556. getImpostors(): Array<PhysicsImpostor>;
  26557. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26558. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26559. }
  26560. interface IPhysicsEnginePlugin {
  26561. world: any;
  26562. name: string;
  26563. setGravity(gravity: Vector3): void;
  26564. setTimeStep(timeStep: number): void;
  26565. getTimeStep(): number;
  26566. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26567. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26568. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26569. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26570. removePhysicsBody(impostor: PhysicsImpostor): void;
  26571. generateJoint(joint: PhysicsImpostorJoint): void;
  26572. removeJoint(joint: PhysicsImpostorJoint): void;
  26573. isSupported(): boolean;
  26574. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26576. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26577. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26578. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26579. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26580. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26581. getBodyMass(impostor: PhysicsImpostor): number;
  26582. getBodyFriction(impostor: PhysicsImpostor): number;
  26583. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26584. getBodyRestitution(impostor: PhysicsImpostor): number;
  26585. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26586. sleepBody(impostor: PhysicsImpostor): void;
  26587. wakeUpBody(impostor: PhysicsImpostor): void;
  26588. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26589. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26590. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26591. getRadius(impostor: PhysicsImpostor): number;
  26592. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26593. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26594. dispose(): void;
  26595. }
  26596. }
  26597. declare module BABYLON {
  26598. class PhysicsHelper {
  26599. private _scene;
  26600. private _physicsEngine;
  26601. constructor(scene: Scene);
  26602. /**
  26603. * @param {Vector3} origin the origin of the explosion
  26604. * @param {number} radius the explosion radius
  26605. * @param {number} strength the explosion strength
  26606. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26607. */
  26608. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26609. /**
  26610. * @param {Vector3} origin the origin of the explosion
  26611. * @param {number} radius the explosion radius
  26612. * @param {number} strength the explosion strength
  26613. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26614. */
  26615. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  26616. /**
  26617. * @param {Vector3} origin the origin of the explosion
  26618. * @param {number} radius the explosion radius
  26619. * @param {number} strength the explosion strength
  26620. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  26621. */
  26622. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  26623. /**
  26624. * @param {Vector3} origin the origin of the updraft
  26625. * @param {number} radius the radius of the updraft
  26626. * @param {number} strength the strength of the updraft
  26627. * @param {number} height the height of the updraft
  26628. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  26629. */
  26630. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  26631. /**
  26632. * @param {Vector3} origin the of the vortex
  26633. * @param {number} radius the radius of the vortex
  26634. * @param {number} strength the strength of the vortex
  26635. * @param {number} height the height of the vortex
  26636. */
  26637. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  26638. }
  26639. /***** Radial explosion *****/
  26640. class PhysicsRadialExplosionEvent {
  26641. private _scene;
  26642. private _sphere;
  26643. private _sphereOptions;
  26644. private _rays;
  26645. private _dataFetched;
  26646. constructor(scene: Scene);
  26647. /**
  26648. * Returns the data related to the radial explosion event (sphere & rays).
  26649. * @returns {PhysicsRadialExplosionEventData}
  26650. */
  26651. getData(): PhysicsRadialExplosionEventData;
  26652. /**
  26653. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  26654. * @param impostor
  26655. * @param {Vector3} origin the origin of the explosion
  26656. * @param {number} radius the explosion radius
  26657. * @param {number} strength the explosion strength
  26658. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  26659. * @returns {Nullable<PhysicsForceAndContactPoint>}
  26660. */
  26661. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  26662. /**
  26663. * Disposes the sphere.
  26664. * @param {bolean} force
  26665. */
  26666. dispose(force?: boolean): void;
  26667. /*** Helpers ***/
  26668. private _prepareSphere;
  26669. private _intersectsWithSphere;
  26670. }
  26671. /***** Gravitational Field *****/
  26672. class PhysicsGravitationalFieldEvent {
  26673. private _physicsHelper;
  26674. private _scene;
  26675. private _origin;
  26676. private _radius;
  26677. private _strength;
  26678. private _falloff;
  26679. private _tickCallback;
  26680. private _sphere;
  26681. private _dataFetched;
  26682. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  26683. /**
  26684. * Returns the data related to the gravitational field event (sphere).
  26685. * @returns {PhysicsGravitationalFieldEventData}
  26686. */
  26687. getData(): PhysicsGravitationalFieldEventData;
  26688. /**
  26689. * Enables the gravitational field.
  26690. */
  26691. enable(): void;
  26692. /**
  26693. * Disables the gravitational field.
  26694. */
  26695. disable(): void;
  26696. /**
  26697. * Disposes the sphere.
  26698. * @param {bolean} force
  26699. */
  26700. dispose(force?: boolean): void;
  26701. private _tick;
  26702. }
  26703. /***** Updraft *****/
  26704. class PhysicsUpdraftEvent {
  26705. private _scene;
  26706. private _origin;
  26707. private _radius;
  26708. private _strength;
  26709. private _height;
  26710. private _updraftMode;
  26711. private _physicsEngine;
  26712. private _originTop;
  26713. private _originDirection;
  26714. private _tickCallback;
  26715. private _cylinder;
  26716. private _cylinderPosition;
  26717. private _dataFetched;
  26718. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  26719. /**
  26720. * Returns the data related to the updraft event (cylinder).
  26721. * @returns {PhysicsUpdraftEventData}
  26722. */
  26723. getData(): PhysicsUpdraftEventData;
  26724. /**
  26725. * Enables the updraft.
  26726. */
  26727. enable(): void;
  26728. /**
  26729. * Disables the cortex.
  26730. */
  26731. disable(): void;
  26732. /**
  26733. * Disposes the sphere.
  26734. * @param {bolean} force
  26735. */
  26736. dispose(force?: boolean): void;
  26737. private getImpostorForceAndContactPoint;
  26738. private _tick;
  26739. /*** Helpers ***/
  26740. private _prepareCylinder;
  26741. private _intersectsWithCylinder;
  26742. }
  26743. /***** Vortex *****/
  26744. class PhysicsVortexEvent {
  26745. private _scene;
  26746. private _origin;
  26747. private _radius;
  26748. private _strength;
  26749. private _height;
  26750. private _physicsEngine;
  26751. private _originTop;
  26752. private _centripetalForceThreshold;
  26753. private _updraftMultiplier;
  26754. private _tickCallback;
  26755. private _cylinder;
  26756. private _cylinderPosition;
  26757. private _dataFetched;
  26758. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  26759. /**
  26760. * Returns the data related to the vortex event (cylinder).
  26761. * @returns {PhysicsVortexEventData}
  26762. */
  26763. getData(): PhysicsVortexEventData;
  26764. /**
  26765. * Enables the vortex.
  26766. */
  26767. enable(): void;
  26768. /**
  26769. * Disables the cortex.
  26770. */
  26771. disable(): void;
  26772. /**
  26773. * Disposes the sphere.
  26774. * @param {bolean} force
  26775. */
  26776. dispose(force?: boolean): void;
  26777. private getImpostorForceAndContactPoint;
  26778. private _tick;
  26779. /*** Helpers ***/
  26780. private _prepareCylinder;
  26781. private _intersectsWithCylinder;
  26782. }
  26783. /***** Enums *****/
  26784. /**
  26785. * The strenght of the force in correspondence to the distance of the affected object
  26786. */
  26787. enum PhysicsRadialImpulseFalloff {
  26788. /** Defines that impulse is constant in strength across it's whole radius */
  26789. Constant = 0,
  26790. /** DEfines that impulse gets weaker if it's further from the origin */
  26791. Linear = 1
  26792. }
  26793. /**
  26794. * The strenght of the force in correspondence to the distance of the affected object
  26795. */
  26796. enum PhysicsUpdraftMode {
  26797. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  26798. Center = 0,
  26799. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  26800. Perpendicular = 1
  26801. }
  26802. /***** Data interfaces *****/
  26803. interface PhysicsForceAndContactPoint {
  26804. force: Vector3;
  26805. contactPoint: Vector3;
  26806. }
  26807. interface PhysicsRadialExplosionEventData {
  26808. sphere: Mesh;
  26809. rays: Array<Ray>;
  26810. }
  26811. interface PhysicsGravitationalFieldEventData {
  26812. sphere: Mesh;
  26813. }
  26814. interface PhysicsUpdraftEventData {
  26815. cylinder: Mesh;
  26816. }
  26817. interface PhysicsVortexEventData {
  26818. cylinder: Mesh;
  26819. }
  26820. }
  26821. declare module BABYLON {
  26822. interface PhysicsImpostorParameters {
  26823. mass: number;
  26824. friction?: number;
  26825. restitution?: number;
  26826. nativeOptions?: any;
  26827. ignoreParent?: boolean;
  26828. disableBidirectionalTransformation?: boolean;
  26829. }
  26830. interface IPhysicsEnabledObject {
  26831. position: Vector3;
  26832. rotationQuaternion: Nullable<Quaternion>;
  26833. scaling: Vector3;
  26834. rotation?: Vector3;
  26835. parent?: any;
  26836. getBoundingInfo(): BoundingInfo;
  26837. computeWorldMatrix(force: boolean): Matrix;
  26838. getWorldMatrix?(): Matrix;
  26839. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26840. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26841. getIndices?(): Nullable<IndicesArray>;
  26842. getScene?(): Scene;
  26843. getAbsolutePosition(): Vector3;
  26844. getAbsolutePivotPoint(): Vector3;
  26845. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26847. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26848. getClassName(): string;
  26849. }
  26850. class PhysicsImpostor {
  26851. object: IPhysicsEnabledObject;
  26852. type: number;
  26853. private _options;
  26854. private _scene?;
  26855. static DEFAULT_OBJECT_SIZE: Vector3;
  26856. static IDENTITY_QUATERNION: Quaternion;
  26857. private _physicsEngine;
  26858. private _physicsBody;
  26859. private _bodyUpdateRequired;
  26860. private _onBeforePhysicsStepCallbacks;
  26861. private _onAfterPhysicsStepCallbacks;
  26862. private _onPhysicsCollideCallbacks;
  26863. private _deltaPosition;
  26864. private _deltaRotation;
  26865. private _deltaRotationConjugated;
  26866. private _parent;
  26867. private _isDisposed;
  26868. private static _tmpVecs;
  26869. private static _tmpQuat;
  26870. readonly isDisposed: boolean;
  26871. mass: number;
  26872. friction: number;
  26873. restitution: number;
  26874. uniqueId: number;
  26875. private _joints;
  26876. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26877. /**
  26878. * This function will completly initialize this impostor.
  26879. * It will create a new body - but only if this mesh has no parent.
  26880. * If it has, this impostor will not be used other than to define the impostor
  26881. * of the child mesh.
  26882. * @hidden
  26883. */
  26884. _init(): void;
  26885. private _getPhysicsParent;
  26886. /**
  26887. * Should a new body be generated.
  26888. */
  26889. isBodyInitRequired(): boolean;
  26890. setScalingUpdated(updated: boolean): void;
  26891. /**
  26892. * Force a regeneration of this or the parent's impostor's body.
  26893. * Use under cautious - This will remove all joints already implemented.
  26894. */
  26895. forceUpdate(): void;
  26896. /**
  26897. * Gets the body that holds this impostor. Either its own, or its parent.
  26898. */
  26899. /**
  26900. * Set the physics body. Used mainly by the physics engine/plugin
  26901. */
  26902. physicsBody: any;
  26903. parent: Nullable<PhysicsImpostor>;
  26904. resetUpdateFlags(): void;
  26905. getObjectExtendSize(): Vector3;
  26906. getObjectCenter(): Vector3;
  26907. /**
  26908. * Get a specific parametes from the options parameter.
  26909. */
  26910. getParam(paramName: string): any;
  26911. /**
  26912. * Sets a specific parameter in the options given to the physics plugin
  26913. */
  26914. setParam(paramName: string, value: number): void;
  26915. /**
  26916. * Specifically change the body's mass option. Won't recreate the physics body object
  26917. */
  26918. setMass(mass: number): void;
  26919. getLinearVelocity(): Nullable<Vector3>;
  26920. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26921. getAngularVelocity(): Nullable<Vector3>;
  26922. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26923. /**
  26924. * Execute a function with the physics plugin native code.
  26925. * Provide a function the will have two variables - the world object and the physics body object.
  26926. */
  26927. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26928. /**
  26929. * Register a function that will be executed before the physics world is stepping forward.
  26930. */
  26931. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26932. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26933. /**
  26934. * Register a function that will be executed after the physics step
  26935. */
  26936. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26937. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26938. /**
  26939. * register a function that will be executed when this impostor collides against a different body.
  26940. */
  26941. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26942. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26943. private _tmpQuat;
  26944. private _tmpQuat2;
  26945. getParentsRotation(): Quaternion;
  26946. /**
  26947. * this function is executed by the physics engine.
  26948. */
  26949. beforeStep: () => void;
  26950. /**
  26951. * this function is executed by the physics engine.
  26952. */
  26953. afterStep: () => void;
  26954. /**
  26955. * Legacy collision detection event support
  26956. */
  26957. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26958. onCollide: (e: {
  26959. body: any;
  26960. }) => void;
  26961. /**
  26962. * Apply a force
  26963. */
  26964. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26965. /**
  26966. * Apply an impulse
  26967. */
  26968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26969. /**
  26970. * A help function to create a joint.
  26971. */
  26972. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26973. /**
  26974. * Add a joint to this impostor with a different impostor.
  26975. */
  26976. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26977. /**
  26978. * Will keep this body still, in a sleep mode.
  26979. */
  26980. sleep(): PhysicsImpostor;
  26981. /**
  26982. * Wake the body up.
  26983. */
  26984. wakeUp(): PhysicsImpostor;
  26985. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26986. dispose(): void;
  26987. setDeltaPosition(position: Vector3): void;
  26988. setDeltaRotation(rotation: Quaternion): void;
  26989. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  26990. getRadius(): number;
  26991. /**
  26992. * Sync a bone with this impostor
  26993. * @param bone The bone to sync to the impostor.
  26994. * @param boneMesh The mesh that the bone is influencing.
  26995. * @param jointPivot The pivot of the joint / bone in local space.
  26996. * @param distToJoint Optional distance from the impostor to the joint.
  26997. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  26998. */
  26999. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27000. /**
  27001. * Sync impostor to a bone
  27002. * @param bone The bone that the impostor will be synced to.
  27003. * @param boneMesh The mesh that the bone is influencing.
  27004. * @param jointPivot The pivot of the joint / bone in local space.
  27005. * @param distToJoint Optional distance from the impostor to the joint.
  27006. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27007. * @param boneAxis Optional vector3 axis the bone is aligned with
  27008. */
  27009. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27010. static NoImpostor: number;
  27011. static SphereImpostor: number;
  27012. static BoxImpostor: number;
  27013. static PlaneImpostor: number;
  27014. static MeshImpostor: number;
  27015. static CylinderImpostor: number;
  27016. static ParticleImpostor: number;
  27017. static HeightmapImpostor: number;
  27018. }
  27019. }
  27020. declare module BABYLON {
  27021. interface PhysicsJointData {
  27022. mainPivot?: Vector3;
  27023. connectedPivot?: Vector3;
  27024. mainAxis?: Vector3;
  27025. connectedAxis?: Vector3;
  27026. collision?: boolean;
  27027. nativeParams?: any;
  27028. }
  27029. /**
  27030. * This is a holder class for the physics joint created by the physics plugin.
  27031. * It holds a set of functions to control the underlying joint.
  27032. */
  27033. class PhysicsJoint {
  27034. type: number;
  27035. jointData: PhysicsJointData;
  27036. private _physicsJoint;
  27037. protected _physicsPlugin: IPhysicsEnginePlugin;
  27038. constructor(type: number, jointData: PhysicsJointData);
  27039. physicsJoint: any;
  27040. physicsPlugin: IPhysicsEnginePlugin;
  27041. /**
  27042. * Execute a function that is physics-plugin specific.
  27043. * @param {Function} func the function that will be executed.
  27044. * It accepts two parameters: the physics world and the physics joint.
  27045. */
  27046. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27047. static DistanceJoint: number;
  27048. static HingeJoint: number;
  27049. static BallAndSocketJoint: number;
  27050. static WheelJoint: number;
  27051. static SliderJoint: number;
  27052. static PrismaticJoint: number;
  27053. static UniversalJoint: number;
  27054. static Hinge2Joint: number;
  27055. static PointToPointJoint: number;
  27056. static SpringJoint: number;
  27057. static LockJoint: number;
  27058. }
  27059. /**
  27060. * A class representing a physics distance joint.
  27061. */
  27062. class DistanceJoint extends PhysicsJoint {
  27063. constructor(jointData: DistanceJointData);
  27064. /**
  27065. * Update the predefined distance.
  27066. */
  27067. updateDistance(maxDistance: number, minDistance?: number): void;
  27068. }
  27069. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27070. constructor(type: number, jointData: PhysicsJointData);
  27071. /**
  27072. * Set the motor values.
  27073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27074. * @param {number} force the force to apply
  27075. * @param {number} maxForce max force for this motor.
  27076. */
  27077. setMotor(force?: number, maxForce?: number): void;
  27078. /**
  27079. * Set the motor's limits.
  27080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27081. */
  27082. setLimit(upperLimit: number, lowerLimit?: number): void;
  27083. }
  27084. /**
  27085. * This class represents a single hinge physics joint
  27086. */
  27087. class HingeJoint extends MotorEnabledJoint {
  27088. constructor(jointData: PhysicsJointData);
  27089. /**
  27090. * Set the motor values.
  27091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27092. * @param {number} force the force to apply
  27093. * @param {number} maxForce max force for this motor.
  27094. */
  27095. setMotor(force?: number, maxForce?: number): void;
  27096. /**
  27097. * Set the motor's limits.
  27098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27099. */
  27100. setLimit(upperLimit: number, lowerLimit?: number): void;
  27101. }
  27102. /**
  27103. * This class represents a dual hinge physics joint (same as wheel joint)
  27104. */
  27105. class Hinge2Joint extends MotorEnabledJoint {
  27106. constructor(jointData: PhysicsJointData);
  27107. /**
  27108. * Set the motor values.
  27109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27110. * @param {number} force the force to apply
  27111. * @param {number} maxForce max force for this motor.
  27112. * @param {motorIndex} the motor's index, 0 or 1.
  27113. */
  27114. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27115. /**
  27116. * Set the motor limits.
  27117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27118. * @param {number} upperLimit the upper limit
  27119. * @param {number} lowerLimit lower limit
  27120. * @param {motorIndex} the motor's index, 0 or 1.
  27121. */
  27122. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27123. }
  27124. interface IMotorEnabledJoint {
  27125. physicsJoint: any;
  27126. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27127. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27128. }
  27129. interface DistanceJointData extends PhysicsJointData {
  27130. maxDistance: number;
  27131. }
  27132. interface SpringJointData extends PhysicsJointData {
  27133. length: number;
  27134. stiffness: number;
  27135. damping: number;
  27136. }
  27137. }
  27138. declare module BABYLON {
  27139. /**
  27140. * Postprocess used to generate anaglyphic rendering
  27141. */
  27142. class AnaglyphPostProcess extends PostProcess {
  27143. private _passedProcess;
  27144. /**
  27145. * Creates a new AnaglyphPostProcess
  27146. * @param name defines postprocess name
  27147. * @param options defines creation options or target ratio scale
  27148. * @param rigCameras defines cameras using this postprocess
  27149. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27150. * @param engine defines hosting engine
  27151. * @param reusable defines if the postprocess will be reused multiple times per frame
  27152. */
  27153. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27154. }
  27155. }
  27156. declare module BABYLON {
  27157. class BlackAndWhitePostProcess extends PostProcess {
  27158. degree: number;
  27159. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27160. }
  27161. }
  27162. declare module BABYLON {
  27163. /**
  27164. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27165. */
  27166. class BloomEffect extends PostProcessRenderEffect {
  27167. private bloomScale;
  27168. /**
  27169. * @hidden Internal
  27170. */
  27171. _effects: Array<PostProcess>;
  27172. /**
  27173. * @hidden Internal
  27174. */
  27175. _downscale: ExtractHighlightsPostProcess;
  27176. private _blurX;
  27177. private _blurY;
  27178. private _merge;
  27179. /**
  27180. * The luminance threshold to find bright areas of the image to bloom.
  27181. */
  27182. threshold: number;
  27183. /**
  27184. * The strength of the bloom.
  27185. */
  27186. weight: number;
  27187. /**
  27188. * Specifies the size of the bloom blur kernel, relative to the final output size
  27189. */
  27190. kernel: number;
  27191. /**
  27192. * Creates a new instance of @see BloomEffect
  27193. * @param scene The scene the effect belongs to.
  27194. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27195. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27196. * @param bloomWeight The the strength of bloom.
  27197. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27198. * @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)
  27199. */
  27200. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27201. /**
  27202. * Disposes each of the internal effects for a given camera.
  27203. * @param camera The camera to dispose the effect on.
  27204. */
  27205. disposeEffects(camera: Camera): void;
  27206. /**
  27207. * @hidden Internal
  27208. */
  27209. _updateEffects(): void;
  27210. /**
  27211. * Internal
  27212. * @returns if all the contained post processes are ready.
  27213. * @hidden
  27214. */
  27215. _isReady(): boolean;
  27216. }
  27217. }
  27218. declare module BABYLON {
  27219. /**
  27220. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27221. */
  27222. class BloomMergePostProcess extends PostProcess {
  27223. /** Weight of the bloom to be added to the original input. */
  27224. weight: number;
  27225. /**
  27226. * Creates a new instance of @see BloomMergePostProcess
  27227. * @param name The name of the effect.
  27228. * @param originalFromInput Post process which's input will be used for the merge.
  27229. * @param blurred Blurred highlights post process which's output will be used.
  27230. * @param weight Weight of the bloom to be added to the original input.
  27231. * @param options The required width/height ratio to downsize to before computing the render pass.
  27232. * @param camera The camera to apply the render pass to.
  27233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27234. * @param engine The engine which the post process will be applied. (default: current engine)
  27235. * @param reusable If the post process can be reused on the same frame. (default: false)
  27236. * @param textureType Type of textures used when performing the post process. (default: 0)
  27237. * @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)
  27238. */
  27239. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27240. /** Weight of the bloom to be added to the original input. */
  27241. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27242. }
  27243. }
  27244. declare module BABYLON {
  27245. /**
  27246. * The Blur Post Process which blurs an image based on a kernel and direction.
  27247. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27248. */
  27249. class BlurPostProcess extends PostProcess {
  27250. /** The direction in which to blur the image. */
  27251. direction: Vector2;
  27252. private blockCompilation;
  27253. protected _kernel: number;
  27254. protected _idealKernel: number;
  27255. protected _packedFloat: boolean;
  27256. private _staticDefines;
  27257. /**
  27258. * Sets the length in pixels of the blur sample region
  27259. */
  27260. /**
  27261. * Gets the length in pixels of the blur sample region
  27262. */
  27263. kernel: number;
  27264. /**
  27265. * Sets wether or not the blur needs to unpack/repack floats
  27266. */
  27267. /**
  27268. * Gets wether or not the blur is unpacking/repacking floats
  27269. */
  27270. packedFloat: boolean;
  27271. /**
  27272. * Creates a new instance BlurPostProcess
  27273. * @param name The name of the effect.
  27274. * @param direction The direction in which to blur the image.
  27275. * @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.
  27276. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27277. * @param camera The camera to apply the render pass to.
  27278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27279. * @param engine The engine which the post process will be applied. (default: current engine)
  27280. * @param reusable If the post process can be reused on the same frame. (default: false)
  27281. * @param textureType Type of textures used when performing the post process. (default: 0)
  27282. * @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)
  27283. */
  27284. constructor(name: string,
  27285. /** The direction in which to blur the image. */
  27286. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27287. /**
  27288. * Updates the effect with the current post process compile time values and recompiles the shader.
  27289. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27290. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27291. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27292. * @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
  27293. * @param onCompiled Called when the shader has been compiled.
  27294. * @param onError Called if there is an error when compiling a shader.
  27295. */
  27296. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27297. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27298. /**
  27299. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27300. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27301. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27302. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27303. * The gaps between physical kernels are compensated for in the weighting of the samples
  27304. * @param idealKernel Ideal blur kernel.
  27305. * @return Nearest best kernel.
  27306. */
  27307. protected _nearestBestKernel(idealKernel: number): number;
  27308. /**
  27309. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27310. * @param x The point on the Gaussian distribution to sample.
  27311. * @return the value of the Gaussian function at x.
  27312. */
  27313. protected _gaussianWeight(x: number): number;
  27314. /**
  27315. * Generates a string that can be used as a floating point number in GLSL.
  27316. * @param x Value to print.
  27317. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27318. * @return GLSL float string.
  27319. */
  27320. protected _glslFloat(x: number, decimalFigures?: number): string;
  27321. }
  27322. }
  27323. declare module BABYLON {
  27324. /**
  27325. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27326. */
  27327. class ChromaticAberrationPostProcess extends PostProcess {
  27328. /**
  27329. * The amount of seperation of rgb channels (default: 30)
  27330. */
  27331. aberrationAmount: number;
  27332. /**
  27333. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27334. */
  27335. radialIntensity: number;
  27336. /**
  27337. * 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))
  27338. */
  27339. direction: Vector2;
  27340. /**
  27341. * 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))
  27342. */
  27343. centerPosition: Vector2;
  27344. /**
  27345. * Creates a new instance ChromaticAberrationPostProcess
  27346. * @param name The name of the effect.
  27347. * @param screenWidth The width of the screen to apply the effect on.
  27348. * @param screenHeight The height of the screen to apply the effect on.
  27349. * @param options The required width/height ratio to downsize to before computing the render pass.
  27350. * @param camera The camera to apply the render pass to.
  27351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27352. * @param engine The engine which the post process will be applied. (default: current engine)
  27353. * @param reusable If the post process can be reused on the same frame. (default: false)
  27354. * @param textureType Type of textures used when performing the post process. (default: 0)
  27355. * @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)
  27356. */
  27357. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27358. }
  27359. }
  27360. declare module BABYLON {
  27361. /**
  27362. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27363. */
  27364. class CircleOfConfusionPostProcess extends PostProcess {
  27365. /**
  27366. * 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.
  27367. */
  27368. lensSize: number;
  27369. /**
  27370. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27371. */
  27372. fStop: number;
  27373. /**
  27374. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27375. */
  27376. focusDistance: number;
  27377. /**
  27378. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27379. */
  27380. focalLength: number;
  27381. private _depthTexture;
  27382. /**
  27383. * Creates a new instance CircleOfConfusionPostProcess
  27384. * @param name The name of the effect.
  27385. * @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.
  27386. * @param options The required width/height ratio to downsize to before computing the render pass.
  27387. * @param camera The camera to apply the render pass to.
  27388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27389. * @param engine The engine which the post process will be applied. (default: current engine)
  27390. * @param reusable If the post process can be reused on the same frame. (default: false)
  27391. * @param textureType Type of textures used when performing the post process. (default: 0)
  27392. * @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)
  27393. */
  27394. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27395. /**
  27396. * 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.
  27397. */
  27398. depthTexture: RenderTargetTexture;
  27399. }
  27400. }
  27401. declare module BABYLON {
  27402. class ColorCorrectionPostProcess extends PostProcess {
  27403. private _colorTableTexture;
  27404. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27405. }
  27406. }
  27407. declare module BABYLON {
  27408. /**
  27409. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27410. * input texture to perform effects such as edge detection or sharpening
  27411. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27412. */
  27413. class ConvolutionPostProcess extends PostProcess {
  27414. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27415. kernel: number[];
  27416. /**
  27417. * Creates a new instance ConvolutionPostProcess
  27418. * @param name The name of the effect.
  27419. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27420. * @param options The required width/height ratio to downsize to before computing the render pass.
  27421. * @param camera The camera to apply the render pass to.
  27422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27423. * @param engine The engine which the post process will be applied. (default: current engine)
  27424. * @param reusable If the post process can be reused on the same frame. (default: false)
  27425. * @param textureType Type of textures used when performing the post process. (default: 0)
  27426. */
  27427. constructor(name: string,
  27428. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27429. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27430. /**
  27431. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27432. */
  27433. static EdgeDetect0Kernel: number[];
  27434. /**
  27435. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27436. */
  27437. static EdgeDetect1Kernel: number[];
  27438. /**
  27439. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27440. */
  27441. static EdgeDetect2Kernel: number[];
  27442. /**
  27443. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27444. */
  27445. static SharpenKernel: number[];
  27446. /**
  27447. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27448. */
  27449. static EmbossKernel: number[];
  27450. /**
  27451. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27452. */
  27453. static GaussianKernel: number[];
  27454. }
  27455. }
  27456. declare module BABYLON {
  27457. /**
  27458. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27459. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27460. * based on samples that have a large difference in distance than the center pixel.
  27461. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27462. */
  27463. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27464. direction: Vector2;
  27465. /**
  27466. * Creates a new instance CircleOfConfusionPostProcess
  27467. * @param name The name of the effect.
  27468. * @param scene The scene the effect belongs to.
  27469. * @param direction The direction the blur should be applied.
  27470. * @param kernel The size of the kernel used to blur.
  27471. * @param options The required width/height ratio to downsize to before computing the render pass.
  27472. * @param camera The camera to apply the render pass to.
  27473. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27474. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27476. * @param engine The engine which the post process will be applied. (default: current engine)
  27477. * @param reusable If the post process can be reused on the same frame. (default: false)
  27478. * @param textureType Type of textures used when performing the post process. (default: 0)
  27479. * @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)
  27480. */
  27481. 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);
  27482. }
  27483. }
  27484. declare module BABYLON {
  27485. /**
  27486. * Specifies the level of max blur that should be applied when using the depth of field effect
  27487. */
  27488. enum DepthOfFieldEffectBlurLevel {
  27489. /**
  27490. * Subtle blur
  27491. */
  27492. Low = 0,
  27493. /**
  27494. * Medium blur
  27495. */
  27496. Medium = 1,
  27497. /**
  27498. * Large blur
  27499. */
  27500. High = 2
  27501. }
  27502. /**
  27503. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27504. */
  27505. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27506. private _circleOfConfusion;
  27507. /**
  27508. * @hidden Internal, blurs from high to low
  27509. */
  27510. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27511. private _depthOfFieldBlurY;
  27512. private _dofMerge;
  27513. /**
  27514. * @hidden Internal post processes in depth of field effect
  27515. */
  27516. _effects: Array<PostProcess>;
  27517. /**
  27518. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27519. */
  27520. focalLength: number;
  27521. /**
  27522. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27523. */
  27524. fStop: number;
  27525. /**
  27526. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27527. */
  27528. focusDistance: number;
  27529. /**
  27530. * 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.
  27531. */
  27532. lensSize: number;
  27533. /**
  27534. * Creates a new instance DepthOfFieldEffect
  27535. * @param scene The scene the effect belongs to.
  27536. * @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.
  27537. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27538. * @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)
  27539. */
  27540. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27541. /**
  27542. * 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.
  27543. */
  27544. depthTexture: RenderTargetTexture;
  27545. /**
  27546. * Disposes each of the internal effects for a given camera.
  27547. * @param camera The camera to dispose the effect on.
  27548. */
  27549. disposeEffects(camera: Camera): void;
  27550. /**
  27551. * @hidden Internal
  27552. */
  27553. _updateEffects(): void;
  27554. /**
  27555. * Internal
  27556. * @returns if all the contained post processes are ready.
  27557. * @hidden
  27558. */
  27559. _isReady(): boolean;
  27560. }
  27561. }
  27562. declare module BABYLON {
  27563. /**
  27564. * Options to be set when merging outputs from the default pipeline.
  27565. */
  27566. class DepthOfFieldMergePostProcessOptions {
  27567. /**
  27568. * The original image to merge on top of
  27569. */
  27570. originalFromInput: PostProcess;
  27571. /**
  27572. * Parameters to perform the merge of the depth of field effect
  27573. */
  27574. depthOfField?: {
  27575. circleOfConfusion: PostProcess;
  27576. blurSteps: Array<PostProcess>;
  27577. };
  27578. /**
  27579. * Parameters to perform the merge of bloom effect
  27580. */
  27581. bloom?: {
  27582. blurred: PostProcess;
  27583. weight: number;
  27584. };
  27585. }
  27586. /**
  27587. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27588. */
  27589. class DepthOfFieldMergePostProcess extends PostProcess {
  27590. private blurSteps;
  27591. /**
  27592. * Creates a new instance of DepthOfFieldMergePostProcess
  27593. * @param name The name of the effect.
  27594. * @param originalFromInput Post process which's input will be used for the merge.
  27595. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27596. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27597. * @param options The required width/height ratio to downsize to before computing the render pass.
  27598. * @param camera The camera to apply the render pass to.
  27599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27600. * @param engine The engine which the post process will be applied. (default: current engine)
  27601. * @param reusable If the post process can be reused on the same frame. (default: false)
  27602. * @param textureType Type of textures used when performing the post process. (default: 0)
  27603. * @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)
  27604. */
  27605. 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);
  27606. /**
  27607. * Updates the effect with the current post process compile time values and recompiles the shader.
  27608. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27609. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27610. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27611. * @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
  27612. * @param onCompiled Called when the shader has been compiled.
  27613. * @param onError Called if there is an error when compiling a shader.
  27614. */
  27615. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27616. }
  27617. }
  27618. declare module BABYLON {
  27619. class DisplayPassPostProcess extends PostProcess {
  27620. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27621. }
  27622. }
  27623. declare module BABYLON {
  27624. /**
  27625. * 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.
  27626. */
  27627. class ExtractHighlightsPostProcess extends PostProcess {
  27628. /**
  27629. * The luminance threshold, pixels below this value will be set to black.
  27630. */
  27631. threshold: number;
  27632. /** @hidden */
  27633. _exposure: number;
  27634. /**
  27635. * Post process which has the input texture to be used when performing highlight extraction
  27636. * @hidden
  27637. */
  27638. _inputPostProcess: Nullable<PostProcess>;
  27639. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27640. }
  27641. }
  27642. declare module BABYLON {
  27643. class FilterPostProcess extends PostProcess {
  27644. kernelMatrix: Matrix;
  27645. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27646. }
  27647. }
  27648. declare module BABYLON {
  27649. class FxaaPostProcess extends PostProcess {
  27650. texelWidth: number;
  27651. texelHeight: number;
  27652. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27653. private _getDefines;
  27654. }
  27655. }
  27656. declare module BABYLON {
  27657. /**
  27658. * The GrainPostProcess adds noise to the image at mid luminance levels
  27659. */
  27660. class GrainPostProcess extends PostProcess {
  27661. /**
  27662. * The intensity of the grain added (default: 30)
  27663. */
  27664. intensity: number;
  27665. /**
  27666. * If the grain should be randomized on every frame
  27667. */
  27668. animated: boolean;
  27669. /**
  27670. * Creates a new instance of @see GrainPostProcess
  27671. * @param name The name of the effect.
  27672. * @param options The required width/height ratio to downsize to before computing the render pass.
  27673. * @param camera The camera to apply the render pass to.
  27674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27675. * @param engine The engine which the post process will be applied. (default: current engine)
  27676. * @param reusable If the post process can be reused on the same frame. (default: false)
  27677. * @param textureType Type of textures used when performing the post process. (default: 0)
  27678. * @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)
  27679. */
  27680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27681. }
  27682. }
  27683. declare module BABYLON {
  27684. class HighlightsPostProcess extends PostProcess {
  27685. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27686. }
  27687. }
  27688. declare module BABYLON {
  27689. class ImageProcessingPostProcess extends PostProcess {
  27690. /**
  27691. * Default configuration related to image processing available in the PBR Material.
  27692. */
  27693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27694. /**
  27695. * Gets the image processing configuration used either in this material.
  27696. */
  27697. /**
  27698. * Sets the Default image processing configuration used either in the this material.
  27699. *
  27700. * If sets to null, the scene one is in use.
  27701. */
  27702. imageProcessingConfiguration: ImageProcessingConfiguration;
  27703. /**
  27704. * Keep track of the image processing observer to allow dispose and replace.
  27705. */
  27706. private _imageProcessingObserver;
  27707. /**
  27708. * Attaches a new image processing configuration to the PBR Material.
  27709. * @param configuration
  27710. */
  27711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27712. /**
  27713. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27714. */
  27715. /**
  27716. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27717. */
  27718. colorCurves: Nullable<ColorCurves>;
  27719. /**
  27720. * Gets wether the color curves effect is enabled.
  27721. */
  27722. /**
  27723. * Sets wether the color curves effect is enabled.
  27724. */
  27725. colorCurvesEnabled: boolean;
  27726. /**
  27727. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27728. */
  27729. /**
  27730. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27731. */
  27732. colorGradingTexture: Nullable<BaseTexture>;
  27733. /**
  27734. * Gets wether the color grading effect is enabled.
  27735. */
  27736. /**
  27737. * Gets wether the color grading effect is enabled.
  27738. */
  27739. colorGradingEnabled: boolean;
  27740. /**
  27741. * Gets exposure used in the effect.
  27742. */
  27743. /**
  27744. * Sets exposure used in the effect.
  27745. */
  27746. exposure: number;
  27747. /**
  27748. * Gets wether tonemapping is enabled or not.
  27749. */
  27750. /**
  27751. * Sets wether tonemapping is enabled or not
  27752. */
  27753. toneMappingEnabled: boolean;
  27754. /**
  27755. * Gets contrast used in the effect.
  27756. */
  27757. /**
  27758. * Sets contrast used in the effect.
  27759. */
  27760. contrast: number;
  27761. /**
  27762. * Gets Vignette stretch size.
  27763. */
  27764. /**
  27765. * Sets Vignette stretch size.
  27766. */
  27767. vignetteStretch: number;
  27768. /**
  27769. * Gets Vignette centre X Offset.
  27770. */
  27771. /**
  27772. * Sets Vignette centre X Offset.
  27773. */
  27774. vignetteCentreX: number;
  27775. /**
  27776. * Gets Vignette centre Y Offset.
  27777. */
  27778. /**
  27779. * Sets Vignette centre Y Offset.
  27780. */
  27781. vignetteCentreY: number;
  27782. /**
  27783. * Gets Vignette weight or intensity of the vignette effect.
  27784. */
  27785. /**
  27786. * Sets Vignette weight or intensity of the vignette effect.
  27787. */
  27788. vignetteWeight: number;
  27789. /**
  27790. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27791. * if vignetteEnabled is set to true.
  27792. */
  27793. /**
  27794. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27795. * if vignetteEnabled is set to true.
  27796. */
  27797. vignetteColor: Color4;
  27798. /**
  27799. * Gets Camera field of view used by the Vignette effect.
  27800. */
  27801. /**
  27802. * Sets Camera field of view used by the Vignette effect.
  27803. */
  27804. vignetteCameraFov: number;
  27805. /**
  27806. * Gets the vignette blend mode allowing different kind of effect.
  27807. */
  27808. /**
  27809. * Sets the vignette blend mode allowing different kind of effect.
  27810. */
  27811. vignetteBlendMode: number;
  27812. /**
  27813. * Gets wether the vignette effect is enabled.
  27814. */
  27815. /**
  27816. * Sets wether the vignette effect is enabled.
  27817. */
  27818. vignetteEnabled: boolean;
  27819. private _fromLinearSpace;
  27820. /**
  27821. * Gets wether the input of the processing is in Gamma or Linear Space.
  27822. */
  27823. /**
  27824. * Sets wether the input of the processing is in Gamma or Linear Space.
  27825. */
  27826. fromLinearSpace: boolean;
  27827. /**
  27828. * Defines cache preventing GC.
  27829. */
  27830. private _defines;
  27831. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27832. getClassName(): string;
  27833. protected _updateParameters(): void;
  27834. dispose(camera?: Camera): void;
  27835. }
  27836. }
  27837. declare module BABYLON {
  27838. class PassPostProcess extends PostProcess {
  27839. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27840. }
  27841. }
  27842. declare module BABYLON {
  27843. type PostProcessOptions = {
  27844. width: number;
  27845. height: number;
  27846. };
  27847. /**
  27848. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27849. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27850. */
  27851. class PostProcess {
  27852. /** Name of the PostProcess. */
  27853. name: string;
  27854. /**
  27855. * Width of the texture to apply the post process on
  27856. */
  27857. width: number;
  27858. /**
  27859. * Height of the texture to apply the post process on
  27860. */
  27861. height: number;
  27862. /**
  27863. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27864. * @hidden
  27865. */
  27866. _outputTexture: Nullable<InternalTexture>;
  27867. /**
  27868. * Sampling mode used by the shader
  27869. * See https://doc.babylonjs.com/classes/3.1/texture
  27870. */
  27871. renderTargetSamplingMode: number;
  27872. /**
  27873. * Clear color to use when screen clearing
  27874. */
  27875. clearColor: Color4;
  27876. /**
  27877. * If the buffer needs to be cleared before applying the post process. (default: true)
  27878. * Should be set to false if shader will overwrite all previous pixels.
  27879. */
  27880. autoClear: boolean;
  27881. /**
  27882. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27883. */
  27884. alphaMode: number;
  27885. /**
  27886. * Sets the setAlphaBlendConstants of the babylon engine
  27887. */
  27888. alphaConstants: Color4;
  27889. /**
  27890. * Animations to be used for the post processing
  27891. */
  27892. animations: Animation[];
  27893. /**
  27894. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27895. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27896. */
  27897. enablePixelPerfectMode: boolean;
  27898. /**
  27899. * Force the postprocess to be applied without taking in account viewport
  27900. */
  27901. forceFullscreenViewport: boolean;
  27902. /**
  27903. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27904. *
  27905. * | Value | Type | Description |
  27906. * | ----- | ----------------------------------- | ----------- |
  27907. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27908. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27909. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27910. *
  27911. */
  27912. scaleMode: number;
  27913. /**
  27914. * Force textures to be a power of two (default: false)
  27915. */
  27916. alwaysForcePOT: boolean;
  27917. private _samples;
  27918. /**
  27919. * Number of sample textures (default: 1)
  27920. */
  27921. samples: number;
  27922. /**
  27923. * Modify the scale of the post process to be the same as the viewport (default: false)
  27924. */
  27925. adaptScaleToCurrentViewport: boolean;
  27926. private _camera;
  27927. private _scene;
  27928. private _engine;
  27929. private _options;
  27930. private _reusable;
  27931. private _textureType;
  27932. /**
  27933. * Smart array of input and output textures for the post process.
  27934. * @hidden
  27935. */
  27936. _textures: SmartArray<InternalTexture>;
  27937. /**
  27938. * The index in _textures that corresponds to the output texture.
  27939. * @hidden
  27940. */
  27941. _currentRenderTextureInd: number;
  27942. private _effect;
  27943. private _samplers;
  27944. private _fragmentUrl;
  27945. private _vertexUrl;
  27946. private _parameters;
  27947. private _scaleRatio;
  27948. protected _indexParameters: any;
  27949. private _shareOutputWithPostProcess;
  27950. private _texelSize;
  27951. private _forcedOutputTexture;
  27952. /**
  27953. * An event triggered when the postprocess is activated.
  27954. */
  27955. onActivateObservable: Observable<Camera>;
  27956. private _onActivateObserver;
  27957. /**
  27958. * A function that is added to the onActivateObservable
  27959. */
  27960. onActivate: Nullable<(camera: Camera) => void>;
  27961. /**
  27962. * An event triggered when the postprocess changes its size.
  27963. */
  27964. onSizeChangedObservable: Observable<PostProcess>;
  27965. private _onSizeChangedObserver;
  27966. /**
  27967. * A function that is added to the onSizeChangedObservable
  27968. */
  27969. onSizeChanged: (postProcess: PostProcess) => void;
  27970. /**
  27971. * An event triggered when the postprocess applies its effect.
  27972. */
  27973. onApplyObservable: Observable<Effect>;
  27974. private _onApplyObserver;
  27975. /**
  27976. * A function that is added to the onApplyObservable
  27977. */
  27978. onApply: (effect: Effect) => void;
  27979. /**
  27980. * An event triggered before rendering the postprocess
  27981. */
  27982. onBeforeRenderObservable: Observable<Effect>;
  27983. private _onBeforeRenderObserver;
  27984. /**
  27985. * A function that is added to the onBeforeRenderObservable
  27986. */
  27987. onBeforeRender: (effect: Effect) => void;
  27988. /**
  27989. * An event triggered after rendering the postprocess
  27990. */
  27991. onAfterRenderObservable: Observable<Effect>;
  27992. private _onAfterRenderObserver;
  27993. /**
  27994. * A function that is added to the onAfterRenderObservable
  27995. */
  27996. onAfterRender: (efect: Effect) => void;
  27997. /**
  27998. * 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
  27999. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28000. */
  28001. inputTexture: InternalTexture;
  28002. /**
  28003. * Gets the camera which post process is applied to.
  28004. * @returns The camera the post process is applied to.
  28005. */
  28006. getCamera(): Camera;
  28007. /**
  28008. * Gets the texel size of the postprocess.
  28009. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28010. */
  28011. readonly texelSize: Vector2;
  28012. /**
  28013. * Creates a new instance PostProcess
  28014. * @param name The name of the PostProcess.
  28015. * @param fragmentUrl The url of the fragment shader to be used.
  28016. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28017. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28018. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28019. * @param camera The camera to apply the render pass to.
  28020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28021. * @param engine The engine which the post process will be applied. (default: current engine)
  28022. * @param reusable If the post process can be reused on the same frame. (default: false)
  28023. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28024. * @param textureType Type of textures used when performing the post process. (default: 0)
  28025. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28026. * @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
  28027. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28028. */
  28029. constructor(
  28030. /** Name of the PostProcess. */
  28031. 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);
  28032. /**
  28033. * Gets the engine which this post process belongs to.
  28034. * @returns The engine the post process was enabled with.
  28035. */
  28036. getEngine(): Engine;
  28037. /**
  28038. * The effect that is created when initializing the post process.
  28039. * @returns The created effect corrisponding the the postprocess.
  28040. */
  28041. getEffect(): Effect;
  28042. /**
  28043. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28044. * @param postProcess The post process to share the output with.
  28045. * @returns This post process.
  28046. */
  28047. shareOutputWith(postProcess: PostProcess): PostProcess;
  28048. /**
  28049. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28050. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28051. */
  28052. useOwnOutput(): void;
  28053. /**
  28054. * Updates the effect with the current post process compile time values and recompiles the shader.
  28055. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28056. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28057. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28058. * @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
  28059. * @param onCompiled Called when the shader has been compiled.
  28060. * @param onError Called if there is an error when compiling a shader.
  28061. */
  28062. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28063. /**
  28064. * The post process is reusable if it can be used multiple times within one frame.
  28065. * @returns If the post process is reusable
  28066. */
  28067. isReusable(): boolean;
  28068. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28069. markTextureDirty(): void;
  28070. /**
  28071. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28072. * 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.
  28073. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28074. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28075. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28076. * @returns The target texture that was bound to be written to.
  28077. */
  28078. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28079. /**
  28080. * If the post process is supported.
  28081. */
  28082. readonly isSupported: boolean;
  28083. /**
  28084. * The aspect ratio of the output texture.
  28085. */
  28086. readonly aspectRatio: number;
  28087. /**
  28088. * Get a value indicating if the post-process is ready to be used
  28089. * @returns true if the post-process is ready (shader is compiled)
  28090. */
  28091. isReady(): boolean;
  28092. /**
  28093. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28094. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28095. */
  28096. apply(): Nullable<Effect>;
  28097. private _disposeTextures;
  28098. /**
  28099. * Disposes the post process.
  28100. * @param camera The camera to dispose the post process on.
  28101. */
  28102. dispose(camera?: Camera): void;
  28103. }
  28104. }
  28105. declare module BABYLON {
  28106. /**
  28107. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28109. */
  28110. class PostProcessManager {
  28111. private _scene;
  28112. private _indexBuffer;
  28113. private _vertexBuffers;
  28114. /**
  28115. * Creates a new instance PostProcess
  28116. * @param scene The scene that the post process is associated with.
  28117. */
  28118. constructor(scene: Scene);
  28119. private _prepareBuffers;
  28120. private _buildIndexBuffer;
  28121. /**
  28122. * Rebuilds the vertex buffers of the manager.
  28123. * @hidden
  28124. */
  28125. _rebuild(): void;
  28126. /**
  28127. * Prepares a frame to be run through a post process.
  28128. * @param sourceTexture The input texture to the post procesess. (default: null)
  28129. * @param postProcesses An array of post processes to be run. (default: null)
  28130. * @returns True if the post processes were able to be run.
  28131. * @hidden
  28132. */
  28133. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28134. /**
  28135. * Manually render a set of post processes to a texture.
  28136. * @param postProcesses An array of post processes to be run.
  28137. * @param targetTexture The target texture to render to.
  28138. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28139. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28140. * @param lodLevel defines which lod of the texture to render to
  28141. */
  28142. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28143. /**
  28144. * Finalize the result of the output of the postprocesses.
  28145. * @param doNotPresent If true the result will not be displayed to the screen.
  28146. * @param targetTexture The target texture to render to.
  28147. * @param faceIndex The index of the face to bind the target texture to.
  28148. * @param postProcesses The array of post processes to render.
  28149. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28150. * @hidden
  28151. */
  28152. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28153. /**
  28154. * Disposes of the post process manager.
  28155. */
  28156. dispose(): void;
  28157. }
  28158. }
  28159. declare module BABYLON {
  28160. class RefractionPostProcess extends PostProcess {
  28161. color: Color3;
  28162. depth: number;
  28163. colorLevel: number;
  28164. private _refTexture;
  28165. private _ownRefractionTexture;
  28166. /**
  28167. * Gets or sets the refraction texture
  28168. * Please note that you are responsible for disposing the texture if you set it manually
  28169. */
  28170. refractionTexture: Texture;
  28171. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28172. dispose(camera: Camera): void;
  28173. }
  28174. }
  28175. declare module BABYLON {
  28176. /**
  28177. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28178. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28179. */
  28180. class SharpenPostProcess extends PostProcess {
  28181. /**
  28182. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28183. */
  28184. colorAmount: number;
  28185. /**
  28186. * How much sharpness should be applied (default: 0.3)
  28187. */
  28188. edgeAmount: number;
  28189. /**
  28190. * Creates a new instance ConvolutionPostProcess
  28191. * @param name The name of the effect.
  28192. * @param options The required width/height ratio to downsize to before computing the render pass.
  28193. * @param camera The camera to apply the render pass to.
  28194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28195. * @param engine The engine which the post process will be applied. (default: current engine)
  28196. * @param reusable If the post process can be reused on the same frame. (default: false)
  28197. * @param textureType Type of textures used when performing the post process. (default: 0)
  28198. * @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)
  28199. */
  28200. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28201. }
  28202. }
  28203. declare module BABYLON {
  28204. class StereoscopicInterlacePostProcess extends PostProcess {
  28205. private _stepSize;
  28206. private _passedProcess;
  28207. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28208. }
  28209. }
  28210. declare module BABYLON {
  28211. /** Defines operator used for tonemapping */
  28212. enum TonemappingOperator {
  28213. /** Hable */
  28214. Hable = 0,
  28215. /** Reinhard */
  28216. Reinhard = 1,
  28217. /** HejiDawson */
  28218. HejiDawson = 2,
  28219. /** Photographic */
  28220. Photographic = 3
  28221. }
  28222. /**
  28223. * Defines a post process to apply tone mapping
  28224. */
  28225. class TonemapPostProcess extends PostProcess {
  28226. private _operator;
  28227. /** Defines the required exposure adjustement */
  28228. exposureAdjustment: number;
  28229. /**
  28230. * Creates a new TonemapPostProcess
  28231. * @param name defines the name of the postprocess
  28232. * @param _operator defines the operator to use
  28233. * @param exposureAdjustment defines the required exposure adjustement
  28234. * @param camera defines the camera to use (can be null)
  28235. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28236. * @param engine defines the hosting engine (can be ignore if camera is set)
  28237. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28238. */
  28239. constructor(name: string, _operator: TonemappingOperator,
  28240. /** Defines the required exposure adjustement */
  28241. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28242. }
  28243. }
  28244. declare module BABYLON {
  28245. class VolumetricLightScatteringPostProcess extends PostProcess {
  28246. private _volumetricLightScatteringPass;
  28247. private _volumetricLightScatteringRTT;
  28248. private _viewPort;
  28249. private _screenCoordinates;
  28250. private _cachedDefines;
  28251. /**
  28252. * If not undefined, the mesh position is computed from the attached node position
  28253. */
  28254. attachedNode: {
  28255. position: Vector3;
  28256. };
  28257. /**
  28258. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28259. */
  28260. customMeshPosition: Vector3;
  28261. /**
  28262. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28263. */
  28264. useCustomMeshPosition: boolean;
  28265. /**
  28266. * If the post-process should inverse the light scattering direction
  28267. */
  28268. invert: boolean;
  28269. /**
  28270. * The internal mesh used by the post-process
  28271. */
  28272. mesh: Mesh;
  28273. useDiffuseColor: boolean;
  28274. /**
  28275. * Array containing the excluded meshes not rendered in the internal pass
  28276. */
  28277. excludedMeshes: AbstractMesh[];
  28278. /**
  28279. * Controls the overall intensity of the post-process
  28280. */
  28281. exposure: number;
  28282. /**
  28283. * Dissipates each sample's contribution in range [0, 1]
  28284. */
  28285. decay: number;
  28286. /**
  28287. * Controls the overall intensity of each sample
  28288. */
  28289. weight: number;
  28290. /**
  28291. * Controls the density of each sample
  28292. */
  28293. density: number;
  28294. /**
  28295. * @constructor
  28296. * @param {string} name - The post-process name
  28297. * @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)
  28298. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28299. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28300. * @param {number} samples - The post-process quality, default 100
  28301. * @param {number} samplingMode - The post-process filtering mode
  28302. * @param {BABYLON.Engine} engine - The babylon engine
  28303. * @param {boolean} reusable - If the post-process is reusable
  28304. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28305. */
  28306. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28307. getClassName(): string;
  28308. private _isReady;
  28309. /**
  28310. * Sets the new light position for light scattering effect
  28311. * @param {BABYLON.Vector3} The new custom light position
  28312. */
  28313. setCustomMeshPosition(position: Vector3): void;
  28314. /**
  28315. * Returns the light position for light scattering effect
  28316. * @return {BABYLON.Vector3} The custom light position
  28317. */
  28318. getCustomMeshPosition(): Vector3;
  28319. /**
  28320. * Disposes the internal assets and detaches the post-process from the camera
  28321. */
  28322. dispose(camera: Camera): void;
  28323. /**
  28324. * Returns the render target texture used by the post-process
  28325. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28326. */
  28327. getPass(): RenderTargetTexture;
  28328. private _meshExcluded;
  28329. private _createPass;
  28330. private _updateMeshScreenCoordinates;
  28331. /**
  28332. * Creates a default mesh for the Volumeric Light Scattering post-process
  28333. * @param {string} The mesh name
  28334. * @param {BABYLON.Scene} The scene where to create the mesh
  28335. * @return {BABYLON.Mesh} the default mesh
  28336. */
  28337. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28338. }
  28339. }
  28340. declare module BABYLON {
  28341. class VRDistortionCorrectionPostProcess extends PostProcess {
  28342. private _isRightEye;
  28343. private _distortionFactors;
  28344. private _postProcessScaleFactor;
  28345. private _lensCenterOffset;
  28346. private _scaleIn;
  28347. private _scaleFactor;
  28348. private _lensCenter;
  28349. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28350. }
  28351. }
  28352. declare module BABYLON {
  28353. /**
  28354. * Class used to generate realtime reflection / refraction cube textures
  28355. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  28356. */
  28357. class ReflectionProbe {
  28358. /** defines the name of the probe */
  28359. name: string;
  28360. private _scene;
  28361. private _renderTargetTexture;
  28362. private _projectionMatrix;
  28363. private _viewMatrix;
  28364. private _target;
  28365. private _add;
  28366. private _attachedMesh;
  28367. private _invertYAxis;
  28368. /** Gets or sets probe position (center of the cube map) */
  28369. position: Vector3;
  28370. /**
  28371. * Creates a new reflection probe
  28372. * @param name defines the name of the probe
  28373. * @param size defines the texture resolution (for each face)
  28374. * @param scene defines the hosting scene
  28375. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  28376. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  28377. */
  28378. constructor(
  28379. /** defines the name of the probe */
  28380. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  28381. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  28382. samples: number;
  28383. /** Gets or sets the refresh rate to use (on every frame by default) */
  28384. refreshRate: number;
  28385. /**
  28386. * Gets the hosting scene
  28387. * @returns a Scene
  28388. */
  28389. getScene(): Scene;
  28390. /** Gets the internal CubeTexture used to render to */
  28391. readonly cubeTexture: RenderTargetTexture;
  28392. /** Gets the list of meshes to render */
  28393. readonly renderList: Nullable<AbstractMesh[]>;
  28394. /**
  28395. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  28396. * @param mesh defines the mesh to attach to
  28397. */
  28398. attachToMesh(mesh: AbstractMesh): void;
  28399. /**
  28400. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  28401. * @param renderingGroupId The rendering group id corresponding to its index
  28402. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28403. */
  28404. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28405. /**
  28406. * Clean all associated resources
  28407. */
  28408. dispose(): void;
  28409. }
  28410. }
  28411. declare module BABYLON {
  28412. interface Scene {
  28413. /** @hidden (Backing field) */
  28414. _boundingBoxRenderer: BoundingBoxRenderer;
  28415. /** @hidden (Backing field) */
  28416. _forceShowBoundingBoxes: boolean;
  28417. /**
  28418. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28419. */
  28420. forceShowBoundingBoxes: boolean;
  28421. /**
  28422. * Gets the bounding box renderer associated with the scene
  28423. * @returns a BoundingBoxRenderer
  28424. */
  28425. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28426. }
  28427. interface AbstractMesh {
  28428. /** @hidden (Backing field) */
  28429. _showBoundingBox: boolean;
  28430. /**
  28431. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  28432. */
  28433. showBoundingBox: boolean;
  28434. }
  28435. class BoundingBoxRenderer implements ISceneComponent {
  28436. /**
  28437. * The component name helpfull to identify the component in the list of scene components.
  28438. */
  28439. readonly name: string;
  28440. /**
  28441. * The scene the component belongs to.
  28442. */
  28443. scene: Scene;
  28444. frontColor: Color3;
  28445. backColor: Color3;
  28446. showBackLines: boolean;
  28447. renderList: SmartArray<BoundingBox>;
  28448. private _colorShader;
  28449. private _vertexBuffers;
  28450. private _indexBuffer;
  28451. constructor(scene: Scene);
  28452. /**
  28453. * Registers the component in a given scene
  28454. */
  28455. register(): void;
  28456. private _evaluateSubMesh;
  28457. private _activeMesh;
  28458. private _prepareRessources;
  28459. private _createIndexBuffer;
  28460. /**
  28461. * Rebuilds the elements related to this component in case of
  28462. * context lost for instance.
  28463. */
  28464. rebuild(): void;
  28465. reset(): void;
  28466. render(): void;
  28467. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  28468. dispose(): void;
  28469. }
  28470. }
  28471. declare module BABYLON {
  28472. /**
  28473. * This represents a depth renderer in Babylon.
  28474. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  28475. */
  28476. class DepthRenderer {
  28477. private _scene;
  28478. private _depthMap;
  28479. private _effect;
  28480. private _cachedDefines;
  28481. private _camera;
  28482. /**
  28483. * Instantiates a depth renderer
  28484. * @param scene The scene the renderer belongs to
  28485. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  28486. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  28487. */
  28488. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  28489. /**
  28490. * Creates the depth rendering effect and checks if the effect is ready.
  28491. * @param subMesh The submesh to be used to render the depth map of
  28492. * @param useInstances If multiple world instances should be used
  28493. * @returns if the depth renderer is ready to render the depth map
  28494. */
  28495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28496. /**
  28497. * Gets the texture which the depth map will be written to.
  28498. * @returns The depth map texture
  28499. */
  28500. getDepthMap(): RenderTargetTexture;
  28501. /**
  28502. * Disposes of the depth renderer.
  28503. */
  28504. dispose(): void;
  28505. }
  28506. }
  28507. declare module BABYLON {
  28508. interface Scene {
  28509. /** @hidden (Backing field) */
  28510. _depthRenderer: {
  28511. [id: string]: DepthRenderer;
  28512. };
  28513. /**
  28514. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  28515. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  28516. * @returns the created depth renderer
  28517. */
  28518. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  28519. /**
  28520. * Disables a depth renderer for a given camera
  28521. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  28522. */
  28523. disableDepthRenderer(camera?: Nullable<Camera>): void;
  28524. }
  28525. /**
  28526. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  28527. * in several rendering techniques.
  28528. */
  28529. class DepthRendererSceneComponent implements ISceneComponent {
  28530. /**
  28531. * The component name helpfull to identify the component in the list of scene components.
  28532. */
  28533. readonly name: string;
  28534. /**
  28535. * The scene the component belongs to.
  28536. */
  28537. scene: Scene;
  28538. /**
  28539. * Creates a new instance of the component for the given scene
  28540. * @param scene Defines the scene to register the component in
  28541. */
  28542. constructor(scene: Scene);
  28543. /**
  28544. * Registers the component in a given scene
  28545. */
  28546. register(): void;
  28547. /**
  28548. * Rebuilds the elements related to this component in case of
  28549. * context lost for instance.
  28550. */
  28551. rebuild(): void;
  28552. /**
  28553. * Disposes the component and the associated ressources
  28554. */
  28555. dispose(): void;
  28556. private _gatherRenderTargets;
  28557. }
  28558. }
  28559. declare module BABYLON {
  28560. /**
  28561. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28562. */
  28563. class EdgesRenderer {
  28564. edgesWidthScalerForOrthographic: number;
  28565. edgesWidthScalerForPerspective: number;
  28566. protected _source: AbstractMesh;
  28567. protected _linesPositions: number[];
  28568. protected _linesNormals: number[];
  28569. protected _linesIndices: number[];
  28570. protected _epsilon: number;
  28571. protected _indicesCount: number;
  28572. protected _lineShader: ShaderMaterial;
  28573. protected _ib: WebGLBuffer;
  28574. protected _buffers: {
  28575. [key: string]: Nullable<VertexBuffer>;
  28576. };
  28577. protected _checkVerticesInsteadOfIndices: boolean;
  28578. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28579. isEnabled: boolean;
  28580. /**
  28581. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28582. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28583. * @param source Mesh used to create edges
  28584. * @param epsilon sum of angles in adjacency to check for edge
  28585. * @param checkVerticesInsteadOfIndices
  28586. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28587. */
  28588. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  28589. protected _prepareRessources(): void;
  28590. /** @hidden */
  28591. _rebuild(): void;
  28592. /**
  28593. * Releases the required resources for the edges renderer
  28594. */
  28595. dispose(): void;
  28596. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28597. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28598. /**
  28599. * Checks if the pair of p0 and p1 is en edge
  28600. * @param faceIndex
  28601. * @param edge
  28602. * @param faceNormals
  28603. * @param p0
  28604. * @param p1
  28605. * @private
  28606. */
  28607. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28608. /**
  28609. * Generates lines edges from adjacencjes
  28610. * @private
  28611. */
  28612. _generateEdgesLines(): void;
  28613. render(): void;
  28614. }
  28615. }
  28616. declare module BABYLON {
  28617. /**
  28618. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28619. */
  28620. class GeometryBufferRenderer {
  28621. private _scene;
  28622. private _multiRenderTarget;
  28623. private _ratio;
  28624. private _enablePosition;
  28625. protected _effect: Effect;
  28626. protected _cachedDefines: string;
  28627. /**
  28628. * Set the render list (meshes to be rendered) used in the G buffer.
  28629. */
  28630. renderList: Mesh[];
  28631. /**
  28632. * Gets wether or not G buffer are supported by the running hardware.
  28633. * This requires draw buffer supports
  28634. */
  28635. readonly isSupported: boolean;
  28636. /**
  28637. * Gets wether or not position are enabled for the G buffer.
  28638. */
  28639. /**
  28640. * Sets wether or not position are enabled for the G buffer.
  28641. */
  28642. enablePosition: boolean;
  28643. /**
  28644. * Gets the scene associated with the buffer.
  28645. */
  28646. readonly scene: Scene;
  28647. /**
  28648. * Gets the ratio used by the buffer during its creation.
  28649. * How big is the buffer related to the main canvas.
  28650. */
  28651. readonly ratio: number;
  28652. /**
  28653. * Creates a new G Buffer for the scene
  28654. * @param scene The scene the buffer belongs to
  28655. * @param ratio How big is the buffer related to the main canvas.
  28656. */
  28657. constructor(scene: Scene, ratio?: number);
  28658. /**
  28659. * Checks wether everything is ready to render a submesh to the G buffer.
  28660. * @param subMesh the submesh to check readiness for
  28661. * @param useInstances is the mesh drawn using instance or not
  28662. * @returns true if ready otherwise false
  28663. */
  28664. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28665. /**
  28666. * Gets the current underlying G Buffer.
  28667. * @returns the buffer
  28668. */
  28669. getGBuffer(): MultiRenderTarget;
  28670. /**
  28671. * Gets the number of samples used to render the buffer (anti aliasing).
  28672. */
  28673. /**
  28674. * Sets the number of samples used to render the buffer (anti aliasing).
  28675. */
  28676. samples: number;
  28677. /**
  28678. * Disposes the renderer and frees up associated resources.
  28679. */
  28680. dispose(): void;
  28681. protected _createRenderTargets(): void;
  28682. }
  28683. }
  28684. declare module BABYLON {
  28685. interface Scene {
  28686. /** @hidden (Backing field) */
  28687. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28688. /**
  28689. * Gets or Sets the current geometry buffer associated to the scene.
  28690. */
  28691. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  28692. /**
  28693. * Enables a GeometryBufferRender and associates it with the scene
  28694. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  28695. * @returns the GeometryBufferRenderer
  28696. */
  28697. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  28698. /**
  28699. * Disables the GeometryBufferRender associated with the scene
  28700. */
  28701. disableGeometryBufferRenderer(): void;
  28702. }
  28703. /**
  28704. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  28705. * in several rendering techniques.
  28706. */
  28707. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  28708. /**
  28709. * The component name helpfull to identify the component in the list of scene components.
  28710. */
  28711. readonly name: string;
  28712. /**
  28713. * The scene the component belongs to.
  28714. */
  28715. scene: Scene;
  28716. /**
  28717. * Creates a new instance of the component for the given scene
  28718. * @param scene Defines the scene to register the component in
  28719. */
  28720. constructor(scene: Scene);
  28721. /**
  28722. * Registers the component in a given scene
  28723. */
  28724. register(): void;
  28725. /**
  28726. * Rebuilds the elements related to this component in case of
  28727. * context lost for instance.
  28728. */
  28729. rebuild(): void;
  28730. /**
  28731. * Disposes the component and the associated ressources
  28732. */
  28733. dispose(): void;
  28734. private _gatherRenderTargets;
  28735. }
  28736. }
  28737. declare module BABYLON {
  28738. /**
  28739. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28740. */
  28741. class LineEdgesRenderer extends EdgesRenderer {
  28742. /**
  28743. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28744. * @param source LineMesh used to generate edges
  28745. * @param epsilon not important (specified angle for edge detection)
  28746. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28747. */
  28748. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28749. /**
  28750. * Always create the edge since its a line so only important things are p0 and p1
  28751. * @param faceIndex not important for LineMesh
  28752. * @param edge not important for LineMesh
  28753. * @param faceNormals not important for LineMesh
  28754. * @param p0 beginnig of line
  28755. * @param p1 end of line
  28756. */
  28757. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28758. /**
  28759. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28760. */
  28761. _generateEdgesLines(): void;
  28762. }
  28763. }
  28764. declare module BABYLON {
  28765. class OutlineRenderer {
  28766. private _scene;
  28767. private _effect;
  28768. private _cachedDefines;
  28769. zOffset: number;
  28770. constructor(scene: Scene);
  28771. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  28772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28773. }
  28774. }
  28775. declare module BABYLON {
  28776. class RenderingGroup {
  28777. index: number;
  28778. private _scene;
  28779. private _opaqueSubMeshes;
  28780. private _transparentSubMeshes;
  28781. private _alphaTestSubMeshes;
  28782. private _depthOnlySubMeshes;
  28783. private _particleSystems;
  28784. private _spriteManagers;
  28785. private _opaqueSortCompareFn;
  28786. private _alphaTestSortCompareFn;
  28787. private _transparentSortCompareFn;
  28788. private _renderOpaque;
  28789. private _renderAlphaTest;
  28790. private _renderTransparent;
  28791. private _edgesRenderers;
  28792. onBeforeTransparentRendering: () => void;
  28793. /**
  28794. * Set the opaque sort comparison function.
  28795. * If null the sub meshes will be render in the order they were created
  28796. */
  28797. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28798. /**
  28799. * Set the alpha test sort comparison function.
  28800. * If null the sub meshes will be render in the order they were created
  28801. */
  28802. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28803. /**
  28804. * Set the transparent sort comparison function.
  28805. * If null the sub meshes will be render in the order they were created
  28806. */
  28807. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  28808. /**
  28809. * Creates a new rendering group.
  28810. * @param index The rendering group index
  28811. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28812. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28813. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28814. */
  28815. 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>);
  28816. /**
  28817. * Render all the sub meshes contained in the group.
  28818. * @param customRenderFunction Used to override the default render behaviour of the group.
  28819. * @returns true if rendered some submeshes.
  28820. */
  28821. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28822. /**
  28823. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28824. * @param subMeshes The submeshes to render
  28825. */
  28826. private renderOpaqueSorted;
  28827. /**
  28828. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28829. * @param subMeshes The submeshes to render
  28830. */
  28831. private renderAlphaTestSorted;
  28832. /**
  28833. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28834. * @param subMeshes The submeshes to render
  28835. */
  28836. private renderTransparentSorted;
  28837. /**
  28838. * Renders the submeshes in a specified order.
  28839. * @param subMeshes The submeshes to sort before render
  28840. * @param sortCompareFn The comparison function use to sort
  28841. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28842. * @param transparent Specifies to activate blending if true
  28843. */
  28844. private static renderSorted;
  28845. /**
  28846. * Renders the submeshes in the order they were dispatched (no sort applied).
  28847. * @param subMeshes The submeshes to render
  28848. */
  28849. private static renderUnsorted;
  28850. /**
  28851. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28852. * are rendered back to front if in the same alpha index.
  28853. *
  28854. * @param a The first submesh
  28855. * @param b The second submesh
  28856. * @returns The result of the comparison
  28857. */
  28858. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28859. /**
  28860. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28861. * are rendered back to front.
  28862. *
  28863. * @param a The first submesh
  28864. * @param b The second submesh
  28865. * @returns The result of the comparison
  28866. */
  28867. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28868. /**
  28869. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28870. * are rendered front to back (prevent overdraw).
  28871. *
  28872. * @param a The first submesh
  28873. * @param b The second submesh
  28874. * @returns The result of the comparison
  28875. */
  28876. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28877. /**
  28878. * Resets the different lists of submeshes to prepare a new frame.
  28879. */
  28880. prepare(): void;
  28881. dispose(): void;
  28882. /**
  28883. * Inserts the submesh in its correct queue depending on its material.
  28884. * @param subMesh The submesh to dispatch
  28885. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28886. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28887. */
  28888. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28889. dispatchSprites(spriteManager: SpriteManager): void;
  28890. dispatchParticles(particleSystem: IParticleSystem): void;
  28891. private _renderParticles;
  28892. private _renderSprites;
  28893. }
  28894. }
  28895. declare module BABYLON {
  28896. /**
  28897. * Interface describing the different options available in the rendering manager
  28898. * regarding Auto Clear between groups.
  28899. */
  28900. interface IRenderingManagerAutoClearSetup {
  28901. /**
  28902. * Defines whether or not autoclear is enable.
  28903. */
  28904. autoClear: boolean;
  28905. /**
  28906. * Defines whether or not to autoclear the depth buffer.
  28907. */
  28908. depth: boolean;
  28909. /**
  28910. * Defines whether or not to autoclear the stencil buffer.
  28911. */
  28912. stencil: boolean;
  28913. }
  28914. class RenderingManager {
  28915. /**
  28916. * The max id used for rendering groups (not included)
  28917. */
  28918. static MAX_RENDERINGGROUPS: number;
  28919. /**
  28920. * The min id used for rendering groups (included)
  28921. */
  28922. static MIN_RENDERINGGROUPS: number;
  28923. /**
  28924. * Used to globally prevent autoclearing scenes.
  28925. */
  28926. static AUTOCLEAR: boolean;
  28927. /**
  28928. * @hidden
  28929. */
  28930. _useSceneAutoClearSetup: boolean;
  28931. private _scene;
  28932. private _renderingGroups;
  28933. private _depthStencilBufferAlreadyCleaned;
  28934. private _autoClearDepthStencil;
  28935. private _customOpaqueSortCompareFn;
  28936. private _customAlphaTestSortCompareFn;
  28937. private _customTransparentSortCompareFn;
  28938. private _renderingGroupInfo;
  28939. constructor(scene: Scene);
  28940. private _clearDepthStencilBuffer;
  28941. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28942. reset(): void;
  28943. dispose(): void;
  28944. /**
  28945. * Clear the info related to rendering groups preventing retention points during dispose.
  28946. */
  28947. freeRenderingGroups(): void;
  28948. private _prepareRenderingGroup;
  28949. dispatchSprites(spriteManager: SpriteManager): void;
  28950. dispatchParticles(particleSystem: IParticleSystem): void;
  28951. /**
  28952. * @param subMesh The submesh to dispatch
  28953. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28954. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28955. */
  28956. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28957. /**
  28958. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28959. * This allowed control for front to back rendering or reversly depending of the special needs.
  28960. *
  28961. * @param renderingGroupId The rendering group id corresponding to its index
  28962. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28963. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28964. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28965. */
  28966. 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;
  28967. /**
  28968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28969. *
  28970. * @param renderingGroupId The rendering group id corresponding to its index
  28971. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28972. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28973. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28974. */
  28975. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28976. /**
  28977. * Gets the current auto clear configuration for one rendering group of the rendering
  28978. * manager.
  28979. * @param index the rendering group index to get the information for
  28980. * @returns The auto clear setup for the requested rendering group
  28981. */
  28982. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28983. }
  28984. }
  28985. declare module BABYLON {
  28986. /**
  28987. * Renders a layer on top of an existing scene
  28988. */
  28989. class UtilityLayerRenderer implements IDisposable {
  28990. /** the original scene that will be rendered on top of */
  28991. originalScene: Scene;
  28992. private _pointerCaptures;
  28993. private _lastPointerEvents;
  28994. private static _DefaultUtilityLayer;
  28995. private static _DefaultKeepDepthUtilityLayer;
  28996. /**
  28997. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  28998. */
  28999. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29000. /**
  29001. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  29002. */
  29003. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29004. /**
  29005. * The scene that is rendered on top of the original scene
  29006. */
  29007. utilityLayerScene: Scene;
  29008. /**
  29009. * If the utility layer should automatically be rendered on top of existing scene
  29010. */
  29011. shouldRender: boolean;
  29012. /**
  29013. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29014. */
  29015. onlyCheckPointerDownEvents: boolean;
  29016. /**
  29017. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29018. */
  29019. processAllEvents: boolean;
  29020. /**
  29021. * Observable raised when the pointer move from the utility layer scene to the main scene
  29022. */
  29023. onPointerOutObservable: Observable<number>;
  29024. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29025. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29026. private _afterRenderObserver;
  29027. private _sceneDisposeObserver;
  29028. private _originalPointerObserver;
  29029. /**
  29030. * Instantiates a UtilityLayerRenderer
  29031. * @param originalScene the original scene that will be rendered on top of
  29032. */
  29033. constructor(
  29034. /** the original scene that will be rendered on top of */
  29035. originalScene: Scene);
  29036. private _notifyObservers;
  29037. /**
  29038. * Renders the utility layers scene on top of the original scene
  29039. */
  29040. render(): void;
  29041. /**
  29042. * Disposes of the renderer
  29043. */
  29044. dispose(): void;
  29045. private _updateCamera;
  29046. }
  29047. }
  29048. declare module BABYLON {
  29049. class Sprite {
  29050. name: string;
  29051. position: Vector3;
  29052. color: Color4;
  29053. width: number;
  29054. height: number;
  29055. angle: number;
  29056. cellIndex: number;
  29057. invertU: number;
  29058. invertV: number;
  29059. disposeWhenFinishedAnimating: boolean;
  29060. animations: Animation[];
  29061. isPickable: boolean;
  29062. actionManager: ActionManager;
  29063. private _animationStarted;
  29064. private _loopAnimation;
  29065. private _fromIndex;
  29066. private _toIndex;
  29067. private _delay;
  29068. private _direction;
  29069. private _manager;
  29070. private _time;
  29071. private _onAnimationEnd;
  29072. /**
  29073. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29074. */
  29075. isVisible: boolean;
  29076. size: number;
  29077. constructor(name: string, manager: SpriteManager);
  29078. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29079. stopAnimation(): void;
  29080. /** @hidden */
  29081. _animate(deltaTime: number): void;
  29082. dispose(): void;
  29083. }
  29084. }
  29085. declare module BABYLON {
  29086. class SpriteManager {
  29087. name: string;
  29088. sprites: Sprite[];
  29089. renderingGroupId: number;
  29090. layerMask: number;
  29091. fogEnabled: boolean;
  29092. isPickable: boolean;
  29093. cellWidth: number;
  29094. cellHeight: number;
  29095. /**
  29096. * An event triggered when the manager is disposed.
  29097. */
  29098. onDisposeObservable: Observable<SpriteManager>;
  29099. private _onDisposeObserver;
  29100. onDispose: () => void;
  29101. private _capacity;
  29102. private _spriteTexture;
  29103. private _epsilon;
  29104. private _scene;
  29105. private _vertexData;
  29106. private _buffer;
  29107. private _vertexBuffers;
  29108. private _indexBuffer;
  29109. private _effectBase;
  29110. private _effectFog;
  29111. texture: Texture;
  29112. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29113. private _appendSpriteVertex;
  29114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29115. render(): void;
  29116. dispose(): void;
  29117. }
  29118. }
  29119. declare module BABYLON {
  29120. /**
  29121. * @hidden
  29122. **/
  29123. class _AlphaState {
  29124. private _isAlphaBlendDirty;
  29125. private _isBlendFunctionParametersDirty;
  29126. private _isBlendEquationParametersDirty;
  29127. private _isBlendConstantsDirty;
  29128. private _alphaBlend;
  29129. private _blendFunctionParameters;
  29130. private _blendEquationParameters;
  29131. private _blendConstants;
  29132. /**
  29133. * Initializes the state.
  29134. */
  29135. constructor();
  29136. readonly isDirty: boolean;
  29137. alphaBlend: boolean;
  29138. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29139. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29140. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29141. reset(): void;
  29142. apply(gl: WebGLRenderingContext): void;
  29143. }
  29144. }
  29145. declare module BABYLON {
  29146. /**
  29147. * @hidden
  29148. **/
  29149. class _DepthCullingState {
  29150. private _isDepthTestDirty;
  29151. private _isDepthMaskDirty;
  29152. private _isDepthFuncDirty;
  29153. private _isCullFaceDirty;
  29154. private _isCullDirty;
  29155. private _isZOffsetDirty;
  29156. private _isFrontFaceDirty;
  29157. private _depthTest;
  29158. private _depthMask;
  29159. private _depthFunc;
  29160. private _cull;
  29161. private _cullFace;
  29162. private _zOffset;
  29163. private _frontFace;
  29164. /**
  29165. * Initializes the state.
  29166. */
  29167. constructor();
  29168. readonly isDirty: boolean;
  29169. zOffset: number;
  29170. cullFace: Nullable<number>;
  29171. cull: Nullable<boolean>;
  29172. depthFunc: Nullable<number>;
  29173. depthMask: boolean;
  29174. depthTest: boolean;
  29175. frontFace: Nullable<number>;
  29176. reset(): void;
  29177. apply(gl: WebGLRenderingContext): void;
  29178. }
  29179. }
  29180. declare module BABYLON {
  29181. /**
  29182. * @hidden
  29183. **/
  29184. class _StencilState {
  29185. private _isStencilTestDirty;
  29186. private _isStencilMaskDirty;
  29187. private _isStencilFuncDirty;
  29188. private _isStencilOpDirty;
  29189. private _stencilTest;
  29190. private _stencilMask;
  29191. private _stencilFunc;
  29192. private _stencilFuncRef;
  29193. private _stencilFuncMask;
  29194. private _stencilOpStencilFail;
  29195. private _stencilOpDepthFail;
  29196. private _stencilOpStencilDepthPass;
  29197. readonly isDirty: boolean;
  29198. stencilFunc: number;
  29199. stencilFuncRef: number;
  29200. stencilFuncMask: number;
  29201. stencilOpStencilFail: number;
  29202. stencilOpDepthFail: number;
  29203. stencilOpStencilDepthPass: number;
  29204. stencilMask: number;
  29205. stencilTest: boolean;
  29206. constructor();
  29207. reset(): void;
  29208. apply(gl: WebGLRenderingContext): void;
  29209. }
  29210. }
  29211. declare module BABYLON {
  29212. /**
  29213. * Class used to evalaute queries containing `and` and `or` operators
  29214. */
  29215. class AndOrNotEvaluator {
  29216. /**
  29217. * Evaluate a query
  29218. * @param query defines the query to evaluate
  29219. * @param evaluateCallback defines the callback used to filter result
  29220. * @returns true if the query matches
  29221. */
  29222. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  29223. private static _HandleParenthesisContent;
  29224. private static _SimplifyNegation;
  29225. }
  29226. }
  29227. declare module BABYLON {
  29228. /**
  29229. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  29230. */
  29231. enum AssetTaskState {
  29232. /**
  29233. * Initialization
  29234. */
  29235. INIT = 0,
  29236. /**
  29237. * Running
  29238. */
  29239. RUNNING = 1,
  29240. /**
  29241. * Done
  29242. */
  29243. DONE = 2,
  29244. /**
  29245. * Error
  29246. */
  29247. ERROR = 3
  29248. }
  29249. /**
  29250. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  29251. */
  29252. abstract class AbstractAssetTask {
  29253. /**
  29254. * Task name
  29255. */ name: string;
  29256. /**
  29257. * Callback called when the task is successful
  29258. */
  29259. onSuccess: (task: any) => void;
  29260. /**
  29261. * Callback called when the task is not successful
  29262. */
  29263. onError: (task: any, message?: string, exception?: any) => void;
  29264. /**
  29265. * Creates a new {BABYLON.AssetsManager}
  29266. * @param name defines the name of the task
  29267. */
  29268. constructor(
  29269. /**
  29270. * Task name
  29271. */ name: string);
  29272. private _isCompleted;
  29273. private _taskState;
  29274. private _errorObject;
  29275. /**
  29276. * Get if the task is completed
  29277. */
  29278. readonly isCompleted: boolean;
  29279. /**
  29280. * Gets the current state of the task
  29281. */
  29282. readonly taskState: AssetTaskState;
  29283. /**
  29284. * Gets the current error object (if task is in error)
  29285. */
  29286. readonly errorObject: {
  29287. message?: string;
  29288. exception?: any;
  29289. };
  29290. /**
  29291. * Internal only
  29292. * @hidden
  29293. */
  29294. _setErrorObject(message?: string, exception?: any): void;
  29295. /**
  29296. * Execute the current task
  29297. * @param scene defines the scene where you want your assets to be loaded
  29298. * @param onSuccess is a callback called when the task is successfully executed
  29299. * @param onError is a callback called if an error occurs
  29300. */
  29301. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29302. /**
  29303. * Execute the current task
  29304. * @param scene defines the scene where you want your assets to be loaded
  29305. * @param onSuccess is a callback called when the task is successfully executed
  29306. * @param onError is a callback called if an error occurs
  29307. */
  29308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29309. /**
  29310. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  29311. * This can be used with failed tasks that have the reason for failure fixed.
  29312. */
  29313. reset(): void;
  29314. private onErrorCallback;
  29315. private onDoneCallback;
  29316. }
  29317. /**
  29318. * Define the interface used by progress events raised during assets loading
  29319. */
  29320. interface IAssetsProgressEvent {
  29321. /**
  29322. * Defines the number of remaining tasks to process
  29323. */
  29324. remainingCount: number;
  29325. /**
  29326. * Defines the total number of tasks
  29327. */
  29328. totalCount: number;
  29329. /**
  29330. * Defines the task that was just processed
  29331. */
  29332. task: AbstractAssetTask;
  29333. }
  29334. /**
  29335. * Class used to share progress information about assets loading
  29336. */
  29337. class AssetsProgressEvent implements IAssetsProgressEvent {
  29338. /**
  29339. * Defines the number of remaining tasks to process
  29340. */
  29341. remainingCount: number;
  29342. /**
  29343. * Defines the total number of tasks
  29344. */
  29345. totalCount: number;
  29346. /**
  29347. * Defines the task that was just processed
  29348. */
  29349. task: AbstractAssetTask;
  29350. /**
  29351. * Creates a {BABYLON.AssetsProgressEvent}
  29352. * @param remainingCount defines the number of remaining tasks to process
  29353. * @param totalCount defines the total number of tasks
  29354. * @param task defines the task that was just processed
  29355. */
  29356. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  29357. }
  29358. /**
  29359. * Define a task used by {BABYLON.AssetsManager} to load meshes
  29360. */
  29361. class MeshAssetTask extends AbstractAssetTask {
  29362. /**
  29363. * Defines the name of the task
  29364. */
  29365. name: string;
  29366. /**
  29367. * Defines the list of mesh's names you want to load
  29368. */
  29369. meshesNames: any;
  29370. /**
  29371. * Defines the root url to use as a base to load your meshes and associated resources
  29372. */
  29373. rootUrl: string;
  29374. /**
  29375. * Defines the filename of the scene to load from
  29376. */
  29377. sceneFilename: string;
  29378. /**
  29379. * Gets the list of loaded meshes
  29380. */
  29381. loadedMeshes: Array<AbstractMesh>;
  29382. /**
  29383. * Gets the list of loaded particle systems
  29384. */
  29385. loadedParticleSystems: Array<IParticleSystem>;
  29386. /**
  29387. * Gets the list of loaded skeletons
  29388. */
  29389. loadedSkeletons: Array<Skeleton>;
  29390. /**
  29391. * Callback called when the task is successful
  29392. */
  29393. onSuccess: (task: MeshAssetTask) => void;
  29394. /**
  29395. * Callback called when the task is successful
  29396. */
  29397. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  29398. /**
  29399. * Creates a new {BABYLON.MeshAssetTask}
  29400. * @param name defines the name of the task
  29401. * @param meshesNames defines the list of mesh's names you want to load
  29402. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  29403. * @param sceneFilename defines the filename of the scene to load from
  29404. */
  29405. constructor(
  29406. /**
  29407. * Defines the name of the task
  29408. */
  29409. name: string,
  29410. /**
  29411. * Defines the list of mesh's names you want to load
  29412. */
  29413. meshesNames: any,
  29414. /**
  29415. * Defines the root url to use as a base to load your meshes and associated resources
  29416. */
  29417. rootUrl: string,
  29418. /**
  29419. * Defines the filename of the scene to load from
  29420. */
  29421. sceneFilename: string);
  29422. /**
  29423. * Execute the current task
  29424. * @param scene defines the scene where you want your assets to be loaded
  29425. * @param onSuccess is a callback called when the task is successfully executed
  29426. * @param onError is a callback called if an error occurs
  29427. */
  29428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29429. }
  29430. /**
  29431. * Define a task used by {BABYLON.AssetsManager} to load text content
  29432. */
  29433. class TextFileAssetTask extends AbstractAssetTask {
  29434. /**
  29435. * Defines the name of the task
  29436. */
  29437. name: string;
  29438. /**
  29439. * Defines the location of the file to load
  29440. */
  29441. url: string;
  29442. /**
  29443. * Gets the loaded text string
  29444. */
  29445. text: string;
  29446. /**
  29447. * Callback called when the task is successful
  29448. */
  29449. onSuccess: (task: TextFileAssetTask) => void;
  29450. /**
  29451. * Callback called when the task is successful
  29452. */
  29453. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  29454. /**
  29455. * Creates a new TextFileAssetTask object
  29456. * @param name defines the name of the task
  29457. * @param url defines the location of the file to load
  29458. */
  29459. constructor(
  29460. /**
  29461. * Defines the name of the task
  29462. */
  29463. name: string,
  29464. /**
  29465. * Defines the location of the file to load
  29466. */
  29467. url: string);
  29468. /**
  29469. * Execute the current task
  29470. * @param scene defines the scene where you want your assets to be loaded
  29471. * @param onSuccess is a callback called when the task is successfully executed
  29472. * @param onError is a callback called if an error occurs
  29473. */
  29474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29475. }
  29476. /**
  29477. * Define a task used by {BABYLON.AssetsManager} to load binary data
  29478. */
  29479. class BinaryFileAssetTask extends AbstractAssetTask {
  29480. /**
  29481. * Defines the name of the task
  29482. */
  29483. name: string;
  29484. /**
  29485. * Defines the location of the file to load
  29486. */
  29487. url: string;
  29488. /**
  29489. * Gets the lodaded data (as an array buffer)
  29490. */
  29491. data: ArrayBuffer;
  29492. /**
  29493. * Callback called when the task is successful
  29494. */
  29495. onSuccess: (task: BinaryFileAssetTask) => void;
  29496. /**
  29497. * Callback called when the task is successful
  29498. */
  29499. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  29500. /**
  29501. * Creates a new BinaryFileAssetTask object
  29502. * @param name defines the name of the new task
  29503. * @param url defines the location of the file to load
  29504. */
  29505. constructor(
  29506. /**
  29507. * Defines the name of the task
  29508. */
  29509. name: string,
  29510. /**
  29511. * Defines the location of the file to load
  29512. */
  29513. url: string);
  29514. /**
  29515. * Execute the current task
  29516. * @param scene defines the scene where you want your assets to be loaded
  29517. * @param onSuccess is a callback called when the task is successfully executed
  29518. * @param onError is a callback called if an error occurs
  29519. */
  29520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29521. }
  29522. /**
  29523. * Define a task used by {BABYLON.AssetsManager} to load images
  29524. */
  29525. class ImageAssetTask extends AbstractAssetTask {
  29526. /**
  29527. * Defines the name of the task
  29528. */
  29529. name: string;
  29530. /**
  29531. * Defines the location of the image to load
  29532. */
  29533. url: string;
  29534. /**
  29535. * Gets the loaded images
  29536. */
  29537. image: HTMLImageElement;
  29538. /**
  29539. * Callback called when the task is successful
  29540. */
  29541. onSuccess: (task: ImageAssetTask) => void;
  29542. /**
  29543. * Callback called when the task is successful
  29544. */
  29545. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  29546. /**
  29547. * Creates a new ImageAssetTask
  29548. * @param name defines the name of the task
  29549. * @param url defines the location of the image to load
  29550. */
  29551. constructor(
  29552. /**
  29553. * Defines the name of the task
  29554. */
  29555. name: string,
  29556. /**
  29557. * Defines the location of the image to load
  29558. */
  29559. url: string);
  29560. /**
  29561. * Execute the current task
  29562. * @param scene defines the scene where you want your assets to be loaded
  29563. * @param onSuccess is a callback called when the task is successfully executed
  29564. * @param onError is a callback called if an error occurs
  29565. */
  29566. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29567. }
  29568. /**
  29569. * Defines the interface used by texture loading tasks
  29570. */
  29571. interface ITextureAssetTask<TEX extends BaseTexture> {
  29572. /**
  29573. * Gets the loaded texture
  29574. */
  29575. texture: TEX;
  29576. }
  29577. /**
  29578. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  29579. */
  29580. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  29581. /**
  29582. * Defines the name of the task
  29583. */
  29584. name: string;
  29585. /**
  29586. * Defines the location of the file to load
  29587. */
  29588. url: string;
  29589. /**
  29590. * Defines if mipmap should not be generated (default is false)
  29591. */
  29592. noMipmap?: boolean | undefined;
  29593. /**
  29594. * Defines if texture must be inverted on Y axis (default is false)
  29595. */
  29596. invertY?: boolean | undefined;
  29597. /**
  29598. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29599. */
  29600. samplingMode: number;
  29601. /**
  29602. * Gets the loaded texture
  29603. */
  29604. texture: Texture;
  29605. /**
  29606. * Callback called when the task is successful
  29607. */
  29608. onSuccess: (task: TextureAssetTask) => void;
  29609. /**
  29610. * Callback called when the task is successful
  29611. */
  29612. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  29613. /**
  29614. * Creates a new TextureAssetTask object
  29615. * @param name defines the name of the task
  29616. * @param url defines the location of the file to load
  29617. * @param noMipmap defines if mipmap should not be generated (default is false)
  29618. * @param invertY defines if texture must be inverted on Y axis (default is false)
  29619. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29620. */
  29621. constructor(
  29622. /**
  29623. * Defines the name of the task
  29624. */
  29625. name: string,
  29626. /**
  29627. * Defines the location of the file to load
  29628. */
  29629. url: string,
  29630. /**
  29631. * Defines if mipmap should not be generated (default is false)
  29632. */
  29633. noMipmap?: boolean | undefined,
  29634. /**
  29635. * Defines if texture must be inverted on Y axis (default is false)
  29636. */
  29637. invertY?: boolean | undefined,
  29638. /**
  29639. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  29640. */
  29641. samplingMode?: number);
  29642. /**
  29643. * Execute the current task
  29644. * @param scene defines the scene where you want your assets to be loaded
  29645. * @param onSuccess is a callback called when the task is successfully executed
  29646. * @param onError is a callback called if an error occurs
  29647. */
  29648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29649. }
  29650. /**
  29651. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  29652. */
  29653. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  29654. /**
  29655. * Defines the name of the task
  29656. */
  29657. name: string;
  29658. /**
  29659. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29660. */
  29661. url: string;
  29662. /**
  29663. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29664. */
  29665. extensions?: string[] | undefined;
  29666. /**
  29667. * Defines if mipmaps should not be generated (default is false)
  29668. */
  29669. noMipmap?: boolean | undefined;
  29670. /**
  29671. * Defines the explicit list of files (undefined by default)
  29672. */
  29673. files?: string[] | undefined;
  29674. /**
  29675. * Gets the loaded texture
  29676. */
  29677. texture: CubeTexture;
  29678. /**
  29679. * Callback called when the task is successful
  29680. */
  29681. onSuccess: (task: CubeTextureAssetTask) => void;
  29682. /**
  29683. * Callback called when the task is successful
  29684. */
  29685. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  29686. /**
  29687. * Creates a new CubeTextureAssetTask
  29688. * @param name defines the name of the task
  29689. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29690. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29692. * @param files defines the explicit list of files (undefined by default)
  29693. */
  29694. constructor(
  29695. /**
  29696. * Defines the name of the task
  29697. */
  29698. name: string,
  29699. /**
  29700. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29701. */
  29702. url: string,
  29703. /**
  29704. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29705. */
  29706. extensions?: string[] | undefined,
  29707. /**
  29708. * Defines if mipmaps should not be generated (default is false)
  29709. */
  29710. noMipmap?: boolean | undefined,
  29711. /**
  29712. * Defines the explicit list of files (undefined by default)
  29713. */
  29714. files?: string[] | undefined);
  29715. /**
  29716. * Execute the current task
  29717. * @param scene defines the scene where you want your assets to be loaded
  29718. * @param onSuccess is a callback called when the task is successfully executed
  29719. * @param onError is a callback called if an error occurs
  29720. */
  29721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29722. }
  29723. /**
  29724. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  29725. */
  29726. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  29727. /**
  29728. * Defines the name of the task
  29729. */
  29730. name: string;
  29731. /**
  29732. * Defines the location of the file to load
  29733. */
  29734. url: string;
  29735. /**
  29736. * Defines the desired size (the more it increases the longer the generation will be)
  29737. */
  29738. size: number;
  29739. /**
  29740. * Defines if mipmaps should not be generated (default is false)
  29741. */
  29742. noMipmap: boolean;
  29743. /**
  29744. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29745. */
  29746. generateHarmonics: boolean;
  29747. /**
  29748. * 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)
  29749. */
  29750. gammaSpace: boolean;
  29751. /**
  29752. * Internal Use Only
  29753. */
  29754. reserved: boolean;
  29755. /**
  29756. * Gets the loaded texture
  29757. */
  29758. texture: HDRCubeTexture;
  29759. /**
  29760. * Callback called when the task is successful
  29761. */
  29762. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  29763. /**
  29764. * Callback called when the task is successful
  29765. */
  29766. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  29767. /**
  29768. * Creates a new HDRCubeTextureAssetTask object
  29769. * @param name defines the name of the task
  29770. * @param url defines the location of the file to load
  29771. * @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.
  29772. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29773. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29774. * @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)
  29775. * @param reserved Internal use only
  29776. */
  29777. constructor(
  29778. /**
  29779. * Defines the name of the task
  29780. */
  29781. name: string,
  29782. /**
  29783. * Defines the location of the file to load
  29784. */
  29785. url: string,
  29786. /**
  29787. * Defines the desired size (the more it increases the longer the generation will be)
  29788. */
  29789. size: number,
  29790. /**
  29791. * Defines if mipmaps should not be generated (default is false)
  29792. */
  29793. noMipmap?: boolean,
  29794. /**
  29795. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29796. */
  29797. generateHarmonics?: boolean,
  29798. /**
  29799. * 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)
  29800. */
  29801. gammaSpace?: boolean,
  29802. /**
  29803. * Internal Use Only
  29804. */
  29805. reserved?: boolean);
  29806. /**
  29807. * Execute the current task
  29808. * @param scene defines the scene where you want your assets to be loaded
  29809. * @param onSuccess is a callback called when the task is successfully executed
  29810. * @param onError is a callback called if an error occurs
  29811. */
  29812. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29813. }
  29814. /**
  29815. * This class can be used to easily import assets into a scene
  29816. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  29817. */
  29818. class AssetsManager {
  29819. private _scene;
  29820. private _isLoading;
  29821. protected _tasks: AbstractAssetTask[];
  29822. protected _waitingTasksCount: number;
  29823. protected _totalTasksCount: number;
  29824. /**
  29825. * Callback called when all tasks are processed
  29826. */
  29827. onFinish: (tasks: AbstractAssetTask[]) => void;
  29828. /**
  29829. * Callback called when a task is successful
  29830. */
  29831. onTaskSuccess: (task: AbstractAssetTask) => void;
  29832. /**
  29833. * Callback called when a task had an error
  29834. */
  29835. onTaskError: (task: AbstractAssetTask) => void;
  29836. /**
  29837. * Callback called when a task is done (whatever the result is)
  29838. */
  29839. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  29840. /**
  29841. * Observable called when all tasks are processed
  29842. */
  29843. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  29844. /**
  29845. * Observable called when a task had an error
  29846. */
  29847. onTaskErrorObservable: Observable<AbstractAssetTask>;
  29848. /**
  29849. * Observable called when a task is successful
  29850. */
  29851. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  29852. /**
  29853. * Observable called when a task is done (whatever the result is)
  29854. */
  29855. onProgressObservable: Observable<IAssetsProgressEvent>;
  29856. /**
  29857. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  29858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29859. */
  29860. useDefaultLoadingScreen: boolean;
  29861. /**
  29862. * Creates a new AssetsManager
  29863. * @param scene defines the scene to work on
  29864. */
  29865. constructor(scene: Scene);
  29866. /**
  29867. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  29868. * @param taskName defines the name of the new task
  29869. * @param meshesNames defines the name of meshes to load
  29870. * @param rootUrl defines the root url to use to locate files
  29871. * @param sceneFilename defines the filename of the scene file
  29872. * @returns a new {BABYLON.MeshAssetTask} object
  29873. */
  29874. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  29875. /**
  29876. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  29877. * @param taskName defines the name of the new task
  29878. * @param url defines the url of the file to load
  29879. * @returns a new {BABYLON.TextFileAssetTask} object
  29880. */
  29881. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  29882. /**
  29883. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  29884. * @param taskName defines the name of the new task
  29885. * @param url defines the url of the file to load
  29886. * @returns a new {BABYLON.BinaryFileAssetTask} object
  29887. */
  29888. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  29889. /**
  29890. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  29891. * @param taskName defines the name of the new task
  29892. * @param url defines the url of the file to load
  29893. * @returns a new {BABYLON.ImageAssetTask} object
  29894. */
  29895. addImageTask(taskName: string, url: string): ImageAssetTask;
  29896. /**
  29897. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29898. * @param taskName defines the name of the new task
  29899. * @param url defines the url of the file to load
  29900. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29901. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29902. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29903. * @returns a new {BABYLON.TextureAssetTask} object
  29904. */
  29905. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29906. /**
  29907. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29908. * @param taskName defines the name of the new task
  29909. * @param url defines the url of the file to load
  29910. * @param extensions defines the extension to use to load the cube map (can be null)
  29911. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29912. * @param files defines the list of files to load (can be null)
  29913. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29914. */
  29915. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29916. /**
  29917. *
  29918. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29919. * @param taskName defines the name of the new task
  29920. * @param url defines the url of the file to load
  29921. * @param size defines the size you want for the cubemap (can be null)
  29922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29923. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29924. * @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)
  29925. * @param reserved Internal use only
  29926. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29927. */
  29928. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29929. /**
  29930. * Remove a task from the assets manager.
  29931. * @param task the task to remove
  29932. */
  29933. removeTask(task: AbstractAssetTask): void;
  29934. private _decreaseWaitingTasksCount;
  29935. private _runTask;
  29936. /**
  29937. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29938. * @return the current instance of the {BABYLON.AssetsManager}
  29939. */
  29940. reset(): AssetsManager;
  29941. /**
  29942. * Start the loading process
  29943. * @return the current instance of the {BABYLON.AssetsManager}
  29944. */
  29945. load(): AssetsManager;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. /**
  29950. * Class used to enable access to IndexedDB
  29951. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29952. */
  29953. class Database {
  29954. private callbackManifestChecked;
  29955. private currentSceneUrl;
  29956. private db;
  29957. private _enableSceneOffline;
  29958. private _enableTexturesOffline;
  29959. private manifestVersionFound;
  29960. private mustUpdateRessources;
  29961. private hasReachedQuota;
  29962. private isSupported;
  29963. private idbFactory;
  29964. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29965. static IsUASupportingBlobStorage: boolean;
  29966. /** Gets a boolean indicating if Database storate is enabled */
  29967. static IDBStorageEnabled: boolean;
  29968. /**
  29969. * Gets a boolean indicating if scene must be saved in the database
  29970. */
  29971. readonly enableSceneOffline: boolean;
  29972. /**
  29973. * Gets a boolean indicating if textures must be saved in the database
  29974. */
  29975. readonly enableTexturesOffline: boolean;
  29976. /**
  29977. * Creates a new Database
  29978. * @param urlToScene defines the url to load the scene
  29979. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29980. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29981. */
  29982. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29983. private static _ParseURL;
  29984. private static _ReturnFullUrlLocation;
  29985. private _checkManifestFile;
  29986. /**
  29987. * Open the database and make it available
  29988. * @param successCallback defines the callback to call on success
  29989. * @param errorCallback defines the callback to call on error
  29990. */
  29991. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29992. /**
  29993. * Loads an image from the database
  29994. * @param url defines the url to load from
  29995. * @param image defines the target DOM image
  29996. */
  29997. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29998. private _loadImageFromDBAsync;
  29999. private _saveImageIntoDBAsync;
  30000. private _checkVersionFromDB;
  30001. private _loadVersionFromDBAsync;
  30002. private _saveVersionIntoDBAsync;
  30003. /**
  30004. * Loads a file from database
  30005. * @param url defines the URL to load from
  30006. * @param sceneLoaded defines a callback to call on success
  30007. * @param progressCallBack defines a callback to call when progress changed
  30008. * @param errorCallback defines a callback to call on error
  30009. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30010. */
  30011. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30012. private _loadFileFromDBAsync;
  30013. private _saveFileIntoDBAsync;
  30014. }
  30015. }
  30016. declare module BABYLON {
  30017. interface DDSInfo {
  30018. width: number;
  30019. height: number;
  30020. mipmapCount: number;
  30021. isFourCC: boolean;
  30022. isRGB: boolean;
  30023. isLuminance: boolean;
  30024. isCube: boolean;
  30025. isCompressed: boolean;
  30026. dxgiFormat: number;
  30027. textureType: number;
  30028. /** Sphericle polynomial created for the dds texture */
  30029. sphericalPolynomial?: SphericalPolynomial;
  30030. }
  30031. class DDSTools {
  30032. static StoreLODInAlphaChannel: boolean;
  30033. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30034. private static _FloatView;
  30035. private static _Int32View;
  30036. private static _ToHalfFloat;
  30037. private static _FromHalfFloat;
  30038. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30039. private static _GetHalfFloatRGBAArrayBuffer;
  30040. private static _GetFloatRGBAArrayBuffer;
  30041. private static _GetFloatAsUIntRGBAArrayBuffer;
  30042. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30043. private static _GetRGBAArrayBuffer;
  30044. private static _ExtractLongWordOrder;
  30045. private static _GetRGBArrayBuffer;
  30046. private static _GetLuminanceArrayBuffer;
  30047. /**
  30048. * Uploads DDS Levels to a Babylon Texture
  30049. * @hidden
  30050. */
  30051. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30052. }
  30053. }
  30054. declare module BABYLON {
  30055. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30056. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30061. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30062. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30063. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30064. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30065. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30067. /**
  30068. * Decorator used to define property that can be serialized as reference to a camera
  30069. * @param sourceName defines the name of the property to decorate
  30070. */
  30071. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. class SerializationHelper {
  30073. static Serialize<T>(entity: T, serializationObject?: any): any;
  30074. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30075. static Clone<T>(creationFunction: () => T, source: T): T;
  30076. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /**
  30081. * Wrapper class for promise with external resolve and reject.
  30082. */
  30083. class Deferred<T> {
  30084. /**
  30085. * The promise associated with this deferred object.
  30086. */
  30087. readonly promise: Promise<T>;
  30088. private _resolve;
  30089. private _reject;
  30090. /**
  30091. * The resolve method of the promise associated with this deferred object.
  30092. */
  30093. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30094. /**
  30095. * The reject method of the promise associated with this deferred object.
  30096. */
  30097. readonly reject: (reason?: any) => void;
  30098. /**
  30099. * Constructor for this deferred object.
  30100. */
  30101. constructor();
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. /**
  30106. * Raw texture data and descriptor sufficient for WebGL texture upload
  30107. */
  30108. interface EnvironmentTextureInfo {
  30109. /**
  30110. * Version of the environment map
  30111. */
  30112. version: number;
  30113. /**
  30114. * Width of image
  30115. */
  30116. width: number;
  30117. /**
  30118. * Irradiance information stored in the file.
  30119. */
  30120. irradiance: any;
  30121. /**
  30122. * Specular information stored in the file.
  30123. */
  30124. specular: any;
  30125. }
  30126. /**
  30127. * Sets of helpers addressing the serialization and deserialization of environment texture
  30128. * stored in a BabylonJS env file.
  30129. * Those files are usually stored as .env files.
  30130. */
  30131. class EnvironmentTextureTools {
  30132. /**
  30133. * Magic number identifying the env file.
  30134. */
  30135. private static _MagicBytes;
  30136. /**
  30137. * Gets the environment info from an env file.
  30138. * @param data The array buffer containing the .env bytes.
  30139. * @returns the environment file info (the json header) if successfully parsed.
  30140. */
  30141. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30142. /**
  30143. * Creates an environment texture from a loaded cube texture.
  30144. * @param texture defines the cube texture to convert in env file
  30145. * @return a promise containing the environment data if succesfull.
  30146. */
  30147. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30148. /**
  30149. * Creates a JSON representation of the spherical data.
  30150. * @param texture defines the texture containing the polynomials
  30151. * @return the JSON representation of the spherical info
  30152. */
  30153. private static _CreateEnvTextureIrradiance;
  30154. /**
  30155. * Uploads the texture info contained in the env file to the GPU.
  30156. * @param texture defines the internal texture to upload to
  30157. * @param arrayBuffer defines the buffer cotaining the data to load
  30158. * @param info defines the texture info retrieved through the GetEnvInfo method
  30159. * @returns a promise
  30160. */
  30161. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  30162. /**
  30163. * Uploads the levels of image data to the GPU.
  30164. * @param texture defines the internal texture to upload to
  30165. * @param imageData defines the array buffer views of image data [mipmap][face]
  30166. * @returns a promise
  30167. */
  30168. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  30169. /**
  30170. * Uploads spherical polynomials information to the texture.
  30171. * @param texture defines the texture we are trying to upload the information to
  30172. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  30173. */
  30174. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  30175. }
  30176. }
  30177. declare module BABYLON {
  30178. class FilesInput {
  30179. static FilesToLoad: {
  30180. [key: string]: File;
  30181. };
  30182. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  30183. private _engine;
  30184. private _currentScene;
  30185. private _sceneLoadedCallback;
  30186. private _progressCallback;
  30187. private _additionalRenderLoopLogicCallback;
  30188. private _textureLoadingCallback;
  30189. private _startingProcessingFilesCallback;
  30190. private _onReloadCallback;
  30191. private _errorCallback;
  30192. private _elementToMonitor;
  30193. private _sceneFileToLoad;
  30194. private _filesToLoad;
  30195. 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);
  30196. private _dragEnterHandler;
  30197. private _dragOverHandler;
  30198. private _dropHandler;
  30199. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  30200. dispose(): void;
  30201. private renderFunction;
  30202. private drag;
  30203. private drop;
  30204. private _traverseFolder;
  30205. private _processFiles;
  30206. loadFiles(event: any): void;
  30207. private _processReload;
  30208. reload(): void;
  30209. }
  30210. }
  30211. declare module BABYLON {
  30212. /**
  30213. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30214. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30215. */
  30216. class KhronosTextureContainer {
  30217. arrayBuffer: any;
  30218. static HEADER_LEN: number;
  30219. static COMPRESSED_2D: number;
  30220. static COMPRESSED_3D: number;
  30221. static TEX_2D: number;
  30222. static TEX_3D: number;
  30223. glType: number;
  30224. glTypeSize: number;
  30225. glFormat: number;
  30226. glInternalFormat: number;
  30227. glBaseInternalFormat: number;
  30228. pixelWidth: number;
  30229. pixelHeight: number;
  30230. pixelDepth: number;
  30231. numberOfArrayElements: number;
  30232. numberOfFaces: number;
  30233. numberOfMipmapLevels: number;
  30234. bytesOfKeyValueData: number;
  30235. loadType: number;
  30236. /**
  30237. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  30238. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  30239. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  30240. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  30241. */
  30242. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  30243. switchEndainness(val: number): number;
  30244. /**
  30245. * Uploads KTX content to a Babylon Texture.
  30246. * It is assumed that the texture has already been created & is currently bound
  30247. * @hidden
  30248. */
  30249. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  30250. private _upload2DCompressedLevels;
  30251. }
  30252. }
  30253. declare module BABYLON {
  30254. /**
  30255. * A class serves as a medium between the observable and its observers
  30256. */
  30257. class EventState {
  30258. /**
  30259. * Create a new EventState
  30260. * @param mask defines the mask associated with this state
  30261. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30262. * @param target defines the original target of the state
  30263. * @param currentTarget defines the current target of the state
  30264. */
  30265. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  30266. /**
  30267. * Initialize the current event state
  30268. * @param mask defines the mask associated with this state
  30269. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  30270. * @param target defines the original target of the state
  30271. * @param currentTarget defines the current target of the state
  30272. * @returns the current event state
  30273. */
  30274. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  30275. /**
  30276. * An Observer can set this property to true to prevent subsequent observers of being notified
  30277. */
  30278. skipNextObservers: boolean;
  30279. /**
  30280. * Get the mask value that were used to trigger the event corresponding to this EventState object
  30281. */
  30282. mask: number;
  30283. /**
  30284. * The object that originally notified the event
  30285. */
  30286. target?: any;
  30287. /**
  30288. * The current object in the bubbling phase
  30289. */
  30290. currentTarget?: any;
  30291. /**
  30292. * This will be populated with the return value of the last function that was executed.
  30293. * If it is the first function in the callback chain it will be the event data.
  30294. */
  30295. lastReturnValue?: any;
  30296. }
  30297. /**
  30298. * Represent an Observer registered to a given Observable object.
  30299. */
  30300. class Observer<T> {
  30301. /**
  30302. * Defines the callback to call when the observer is notified
  30303. */
  30304. callback: (eventData: T, eventState: EventState) => void;
  30305. /**
  30306. * Defines the mask of the observer (used to filter notifications)
  30307. */
  30308. mask: number;
  30309. /**
  30310. * Defines the current scope used to restore the JS context
  30311. */
  30312. scope: any;
  30313. /** @hidden */
  30314. _willBeUnregistered: boolean;
  30315. /**
  30316. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  30317. */
  30318. unregisterOnNextCall: boolean;
  30319. /**
  30320. * Creates a new observer
  30321. * @param callback defines the callback to call when the observer is notified
  30322. * @param mask defines the mask of the observer (used to filter notifications)
  30323. * @param scope defines the current scope used to restore the JS context
  30324. */
  30325. constructor(
  30326. /**
  30327. * Defines the callback to call when the observer is notified
  30328. */
  30329. callback: (eventData: T, eventState: EventState) => void,
  30330. /**
  30331. * Defines the mask of the observer (used to filter notifications)
  30332. */
  30333. mask: number,
  30334. /**
  30335. * Defines the current scope used to restore the JS context
  30336. */
  30337. scope?: any);
  30338. }
  30339. /**
  30340. * Represent a list of observers registered to multiple Observables object.
  30341. */
  30342. class MultiObserver<T> {
  30343. private _observers;
  30344. private _observables;
  30345. /**
  30346. * Release associated resources
  30347. */
  30348. dispose(): void;
  30349. /**
  30350. * Raise a callback when one of the observable will notify
  30351. * @param observables defines a list of observables to watch
  30352. * @param callback defines the callback to call on notification
  30353. * @param mask defines the mask used to filter notifications
  30354. * @param scope defines the current scope used to restore the JS context
  30355. * @returns the new MultiObserver
  30356. */
  30357. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  30358. }
  30359. /**
  30360. * The Observable class is a simple implementation of the Observable pattern.
  30361. *
  30362. * 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.
  30363. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  30364. * 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).
  30365. * 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.
  30366. */
  30367. class Observable<T> {
  30368. private _observers;
  30369. private _eventState;
  30370. private _onObserverAdded;
  30371. /**
  30372. * Creates a new observable
  30373. * @param onObserverAdded defines a callback to call when a new observer is added
  30374. */
  30375. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  30376. /**
  30377. * Create a new Observer with the specified callback
  30378. * @param callback the callback that will be executed for that Observer
  30379. * @param mask the mask used to filter observers
  30380. * @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.
  30381. * @param scope optional scope for the callback to be called from
  30382. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  30383. * @returns the new observer created for the callback
  30384. */
  30385. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  30386. /**
  30387. * Create a new Observer with the specified callback and unregisters after the next notification
  30388. * @param callback the callback that will be executed for that Observer
  30389. * @returns the new observer created for the callback
  30390. */
  30391. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  30392. /**
  30393. * Remove an Observer from the Observable object
  30394. * @param observer the instance of the Observer to remove
  30395. * @returns false if it doesn't belong to this Observable
  30396. */
  30397. remove(observer: Nullable<Observer<T>>): boolean;
  30398. /**
  30399. * Remove a callback from the Observable object
  30400. * @param callback the callback to remove
  30401. * @param scope optional scope. If used only the callbacks with this scope will be removed
  30402. * @returns false if it doesn't belong to this Observable
  30403. */
  30404. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  30405. private _deferUnregister;
  30406. private _remove;
  30407. /**
  30408. * Notify all Observers by calling their respective callback with the given data
  30409. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  30410. * @param eventData defines the data to send to all observers
  30411. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  30412. * @param target defines the original target of the state
  30413. * @param currentTarget defines the current target of the state
  30414. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  30415. */
  30416. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  30417. /**
  30418. * Calling this will execute each callback, expecting it to be a promise or return a value.
  30419. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  30420. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  30421. * and it is crucial that all callbacks will be executed.
  30422. * The order of the callbacks is kept, callbacks are not executed parallel.
  30423. *
  30424. * @param eventData The data to be sent to each callback
  30425. * @param mask is used to filter observers defaults to -1
  30426. * @param target defines the callback target (see EventState)
  30427. * @param currentTarget defines he current object in the bubbling phase
  30428. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  30429. */
  30430. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  30431. /**
  30432. * Notify a specific observer
  30433. * @param observer defines the observer to notify
  30434. * @param eventData defines the data to be sent to each callback
  30435. * @param mask is used to filter observers defaults to -1
  30436. */
  30437. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  30438. /**
  30439. * Gets a boolean indicating if the observable has at least one observer
  30440. * @returns true is the Observable has at least one Observer registered
  30441. */
  30442. hasObservers(): boolean;
  30443. /**
  30444. * Clear the list of observers
  30445. */
  30446. clear(): void;
  30447. /**
  30448. * Clone the current observable
  30449. * @returns a new observable
  30450. */
  30451. clone(): Observable<T>;
  30452. /**
  30453. * Does this observable handles observer registered with a given mask
  30454. * @param mask defines the mask to be tested
  30455. * @return whether or not one observer registered with the given mask is handeled
  30456. **/
  30457. hasSpecificMask(mask?: number): boolean;
  30458. }
  30459. }
  30460. declare module BABYLON {
  30461. /**
  30462. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30463. */
  30464. class PerformanceMonitor {
  30465. private _enabled;
  30466. private _rollingFrameTime;
  30467. private _lastFrameTimeMs;
  30468. /**
  30469. * constructor
  30470. * @param frameSampleSize The number of samples required to saturate the sliding window
  30471. */
  30472. constructor(frameSampleSize?: number);
  30473. /**
  30474. * Samples current frame
  30475. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30476. */
  30477. sampleFrame(timeMs?: number): void;
  30478. /**
  30479. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30480. * @return Average frame time in milliseconds
  30481. */
  30482. readonly averageFrameTime: number;
  30483. /**
  30484. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30485. * @return Frame time variance in milliseconds squared
  30486. */
  30487. readonly averageFrameTimeVariance: number;
  30488. /**
  30489. * Returns the frame time of the most recent frame
  30490. * @return Frame time in milliseconds
  30491. */
  30492. readonly instantaneousFrameTime: number;
  30493. /**
  30494. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30495. * @return Framerate in frames per second
  30496. */
  30497. readonly averageFPS: number;
  30498. /**
  30499. * Returns the average framerate in frames per second using the most recent frame time
  30500. * @return Framerate in frames per second
  30501. */
  30502. readonly instantaneousFPS: number;
  30503. /**
  30504. * Returns true if enough samples have been taken to completely fill the sliding window
  30505. * @return true if saturated
  30506. */
  30507. readonly isSaturated: boolean;
  30508. /**
  30509. * Enables contributions to the sliding window sample set
  30510. */
  30511. enable(): void;
  30512. /**
  30513. * Disables contributions to the sliding window sample set
  30514. * Samples will not be interpolated over the disabled period
  30515. */
  30516. disable(): void;
  30517. /**
  30518. * Returns true if sampling is enabled
  30519. * @return true if enabled
  30520. */
  30521. readonly isEnabled: boolean;
  30522. /**
  30523. * Resets performance monitor
  30524. */
  30525. reset(): void;
  30526. }
  30527. /**
  30528. * RollingAverage
  30529. *
  30530. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30531. */
  30532. class RollingAverage {
  30533. /**
  30534. * Current average
  30535. */
  30536. average: number;
  30537. /**
  30538. * Current variance
  30539. */
  30540. variance: number;
  30541. protected _samples: Array<number>;
  30542. protected _sampleCount: number;
  30543. protected _pos: number;
  30544. protected _m2: number;
  30545. /**
  30546. * constructor
  30547. * @param length The number of samples required to saturate the sliding window
  30548. */
  30549. constructor(length: number);
  30550. /**
  30551. * Adds a sample to the sample set
  30552. * @param v The sample value
  30553. */
  30554. add(v: number): void;
  30555. /**
  30556. * Returns previously added values or null if outside of history or outside the sliding window domain
  30557. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30558. * @return Value previously recorded with add() or null if outside of range
  30559. */
  30560. history(i: number): number;
  30561. /**
  30562. * Returns true if enough samples have been taken to completely fill the sliding window
  30563. * @return true if sample-set saturated
  30564. */
  30565. isSaturated(): boolean;
  30566. /**
  30567. * Resets the rolling average (equivalent to 0 samples taken so far)
  30568. */
  30569. reset(): void;
  30570. /**
  30571. * Wraps a value around the sample range boundaries
  30572. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30573. * @return Wrapped position in sample range
  30574. */
  30575. protected _wrapPosition(i: number): number;
  30576. }
  30577. }
  30578. declare module BABYLON {
  30579. /**
  30580. * Helper class that provides a small promise polyfill
  30581. */
  30582. class PromisePolyfill {
  30583. /**
  30584. * Static function used to check if the polyfill is required
  30585. * If this is the case then the function will inject the polyfill to window.Promise
  30586. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30587. */
  30588. static Apply(force?: boolean): void;
  30589. }
  30590. }
  30591. declare module BABYLON {
  30592. /**
  30593. * Defines the root class used to create scene optimization to use with SceneOptimizer
  30594. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30595. */
  30596. class SceneOptimization {
  30597. /**
  30598. * Defines the priority of this optimization (0 by default which means first in the list)
  30599. */
  30600. priority: number;
  30601. /**
  30602. * Gets a string describing the action executed by the current optimization
  30603. * @returns description string
  30604. */
  30605. getDescription(): string;
  30606. /**
  30607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30608. * @param scene defines the current scene where to apply this optimization
  30609. * @param optimizer defines the current optimizer
  30610. * @returns true if everything that can be done was applied
  30611. */
  30612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30613. /**
  30614. * Creates the SceneOptimization object
  30615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30616. * @param desc defines the description associated with the optimization
  30617. */
  30618. constructor(
  30619. /**
  30620. * Defines the priority of this optimization (0 by default which means first in the list)
  30621. */
  30622. priority?: number);
  30623. }
  30624. /**
  30625. * Defines an optimization used to reduce the size of render target textures
  30626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30627. */
  30628. class TextureOptimization extends SceneOptimization {
  30629. /**
  30630. * Defines the priority of this optimization (0 by default which means first in the list)
  30631. */
  30632. priority: number;
  30633. /**
  30634. * 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
  30635. */
  30636. maximumSize: number;
  30637. /**
  30638. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30639. */
  30640. step: number;
  30641. /**
  30642. * Gets a string describing the action executed by the current optimization
  30643. * @returns description string
  30644. */
  30645. getDescription(): string;
  30646. /**
  30647. * Creates the TextureOptimization object
  30648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30649. * @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
  30650. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30651. */
  30652. constructor(
  30653. /**
  30654. * Defines the priority of this optimization (0 by default which means first in the list)
  30655. */
  30656. priority?: number,
  30657. /**
  30658. * 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
  30659. */
  30660. maximumSize?: number,
  30661. /**
  30662. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  30663. */
  30664. step?: number);
  30665. /**
  30666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30667. * @param scene defines the current scene where to apply this optimization
  30668. * @param optimizer defines the current optimizer
  30669. * @returns true if everything that can be done was applied
  30670. */
  30671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30672. }
  30673. /**
  30674. * Defines an optimization used to increase or decrease the rendering resolution
  30675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30676. */
  30677. class HardwareScalingOptimization extends SceneOptimization {
  30678. /**
  30679. * Defines the priority of this optimization (0 by default which means first in the list)
  30680. */
  30681. priority: number;
  30682. /**
  30683. * Defines the maximum scale to use (2 by default)
  30684. */
  30685. maximumScale: number;
  30686. /**
  30687. * Defines the step to use between two passes (0.5 by default)
  30688. */
  30689. step: number;
  30690. private _currentScale;
  30691. private _directionOffset;
  30692. /**
  30693. * Gets a string describing the action executed by the current optimization
  30694. * @return description string
  30695. */
  30696. getDescription(): string;
  30697. /**
  30698. * Creates the HardwareScalingOptimization object
  30699. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30700. * @param maximumScale defines the maximum scale to use (2 by default)
  30701. * @param step defines the step to use between two passes (0.5 by default)
  30702. */
  30703. constructor(
  30704. /**
  30705. * Defines the priority of this optimization (0 by default which means first in the list)
  30706. */
  30707. priority?: number,
  30708. /**
  30709. * Defines the maximum scale to use (2 by default)
  30710. */
  30711. maximumScale?: number,
  30712. /**
  30713. * Defines the step to use between two passes (0.5 by default)
  30714. */
  30715. step?: number);
  30716. /**
  30717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30718. * @param scene defines the current scene where to apply this optimization
  30719. * @param optimizer defines the current optimizer
  30720. * @returns true if everything that can be done was applied
  30721. */
  30722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30723. }
  30724. /**
  30725. * Defines an optimization used to remove shadows
  30726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30727. */
  30728. class ShadowsOptimization extends SceneOptimization {
  30729. /**
  30730. * Gets a string describing the action executed by the current optimization
  30731. * @return description string
  30732. */
  30733. getDescription(): string;
  30734. /**
  30735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30736. * @param scene defines the current scene where to apply this optimization
  30737. * @param optimizer defines the current optimizer
  30738. * @returns true if everything that can be done was applied
  30739. */
  30740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30741. }
  30742. /**
  30743. * Defines an optimization used to turn post-processes off
  30744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30745. */
  30746. class PostProcessesOptimization extends SceneOptimization {
  30747. /**
  30748. * Gets a string describing the action executed by the current optimization
  30749. * @return description string
  30750. */
  30751. getDescription(): string;
  30752. /**
  30753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30754. * @param scene defines the current scene where to apply this optimization
  30755. * @param optimizer defines the current optimizer
  30756. * @returns true if everything that can be done was applied
  30757. */
  30758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30759. }
  30760. /**
  30761. * Defines an optimization used to turn lens flares off
  30762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30763. */
  30764. class LensFlaresOptimization extends SceneOptimization {
  30765. /**
  30766. * Gets a string describing the action executed by the current optimization
  30767. * @return description string
  30768. */
  30769. getDescription(): string;
  30770. /**
  30771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30772. * @param scene defines the current scene where to apply this optimization
  30773. * @param optimizer defines the current optimizer
  30774. * @returns true if everything that can be done was applied
  30775. */
  30776. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30777. }
  30778. /**
  30779. * Defines an optimization based on user defined callback.
  30780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30781. */
  30782. class CustomOptimization extends SceneOptimization {
  30783. /**
  30784. * Callback called to apply the custom optimization.
  30785. */
  30786. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  30787. /**
  30788. * Callback called to get custom description
  30789. */
  30790. onGetDescription: () => string;
  30791. /**
  30792. * Gets a string describing the action executed by the current optimization
  30793. * @returns description string
  30794. */
  30795. getDescription(): string;
  30796. /**
  30797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30798. * @param scene defines the current scene where to apply this optimization
  30799. * @param optimizer defines the current optimizer
  30800. * @returns true if everything that can be done was applied
  30801. */
  30802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30803. }
  30804. /**
  30805. * Defines an optimization used to turn particles off
  30806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30807. */
  30808. class ParticlesOptimization extends SceneOptimization {
  30809. /**
  30810. * Gets a string describing the action executed by the current optimization
  30811. * @return description string
  30812. */
  30813. getDescription(): string;
  30814. /**
  30815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30816. * @param scene defines the current scene where to apply this optimization
  30817. * @param optimizer defines the current optimizer
  30818. * @returns true if everything that can be done was applied
  30819. */
  30820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30821. }
  30822. /**
  30823. * Defines an optimization used to turn render targets off
  30824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30825. */
  30826. class RenderTargetsOptimization extends SceneOptimization {
  30827. /**
  30828. * Gets a string describing the action executed by the current optimization
  30829. * @return description string
  30830. */
  30831. getDescription(): string;
  30832. /**
  30833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30834. * @param scene defines the current scene where to apply this optimization
  30835. * @param optimizer defines the current optimizer
  30836. * @returns true if everything that can be done was applied
  30837. */
  30838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30839. }
  30840. /**
  30841. * Defines an optimization used to merge meshes with compatible materials
  30842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30843. */
  30844. class MergeMeshesOptimization extends SceneOptimization {
  30845. private static _UpdateSelectionTree;
  30846. /**
  30847. * Gets or sets a boolean which defines if optimization octree has to be updated
  30848. */
  30849. /**
  30850. * Gets or sets a boolean which defines if optimization octree has to be updated
  30851. */
  30852. static UpdateSelectionTree: boolean;
  30853. /**
  30854. * Gets a string describing the action executed by the current optimization
  30855. * @return description string
  30856. */
  30857. getDescription(): string;
  30858. private _canBeMerged;
  30859. /**
  30860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30861. * @param scene defines the current scene where to apply this optimization
  30862. * @param optimizer defines the current optimizer
  30863. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  30864. * @returns true if everything that can be done was applied
  30865. */
  30866. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  30867. }
  30868. /**
  30869. * Defines a list of options used by SceneOptimizer
  30870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30871. */
  30872. class SceneOptimizerOptions {
  30873. /**
  30874. * Defines the target frame rate to reach (60 by default)
  30875. */
  30876. targetFrameRate: number;
  30877. /**
  30878. * Defines the interval between two checkes (2000ms by default)
  30879. */
  30880. trackerDuration: number;
  30881. /**
  30882. * Gets the list of optimizations to apply
  30883. */
  30884. optimizations: SceneOptimization[];
  30885. /**
  30886. * Creates a new list of options used by SceneOptimizer
  30887. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  30888. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  30889. */
  30890. constructor(
  30891. /**
  30892. * Defines the target frame rate to reach (60 by default)
  30893. */
  30894. targetFrameRate?: number,
  30895. /**
  30896. * Defines the interval between two checkes (2000ms by default)
  30897. */
  30898. trackerDuration?: number);
  30899. /**
  30900. * Add a new optimization
  30901. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30902. * @returns the current SceneOptimizerOptions
  30903. */
  30904. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30905. /**
  30906. * Add a new custom optimization
  30907. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30908. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30909. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30910. * @returns the current SceneOptimizerOptions
  30911. */
  30912. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30913. /**
  30914. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30915. * @param targetFrameRate defines the target frame rate (60 by default)
  30916. * @returns a SceneOptimizerOptions object
  30917. */
  30918. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30919. /**
  30920. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30921. * @param targetFrameRate defines the target frame rate (60 by default)
  30922. * @returns a SceneOptimizerOptions object
  30923. */
  30924. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30925. /**
  30926. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30927. * @param targetFrameRate defines the target frame rate (60 by default)
  30928. * @returns a SceneOptimizerOptions object
  30929. */
  30930. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30931. }
  30932. /**
  30933. * Class used to run optimizations in order to reach a target frame rate
  30934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30935. */
  30936. class SceneOptimizer implements IDisposable {
  30937. private _isRunning;
  30938. private _options;
  30939. private _scene;
  30940. private _currentPriorityLevel;
  30941. private _targetFrameRate;
  30942. private _trackerDuration;
  30943. private _currentFrameRate;
  30944. private _sceneDisposeObserver;
  30945. private _improvementMode;
  30946. /**
  30947. * Defines an observable called when the optimizer reaches the target frame rate
  30948. */
  30949. onSuccessObservable: Observable<SceneOptimizer>;
  30950. /**
  30951. * Defines an observable called when the optimizer enables an optimization
  30952. */
  30953. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30954. /**
  30955. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30956. */
  30957. onFailureObservable: Observable<SceneOptimizer>;
  30958. /**
  30959. * Gets a boolean indicating if the optimizer is in improvement mode
  30960. */
  30961. readonly isInImprovementMode: boolean;
  30962. /**
  30963. * Gets the current priority level (0 at start)
  30964. */
  30965. readonly currentPriorityLevel: number;
  30966. /**
  30967. * Gets the current frame rate checked by the SceneOptimizer
  30968. */
  30969. readonly currentFrameRate: number;
  30970. /**
  30971. * Gets or sets the current target frame rate (60 by default)
  30972. */
  30973. /**
  30974. * Gets or sets the current target frame rate (60 by default)
  30975. */
  30976. targetFrameRate: number;
  30977. /**
  30978. * Gets or sets the current interval between two checks (every 2000ms by default)
  30979. */
  30980. /**
  30981. * Gets or sets the current interval between two checks (every 2000ms by default)
  30982. */
  30983. trackerDuration: number;
  30984. /**
  30985. * Gets the list of active optimizations
  30986. */
  30987. readonly optimizations: SceneOptimization[];
  30988. /**
  30989. * Creates a new SceneOptimizer
  30990. * @param scene defines the scene to work on
  30991. * @param options defines the options to use with the SceneOptimizer
  30992. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30993. * @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)
  30994. */
  30995. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30996. /**
  30997. * Stops the current optimizer
  30998. */
  30999. stop(): void;
  31000. /**
  31001. * Reset the optimizer to initial step (current priority level = 0)
  31002. */
  31003. reset(): void;
  31004. /**
  31005. * Start the optimizer. By default it will try to reach a specific framerate
  31006. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31007. */
  31008. start(): void;
  31009. private _checkCurrentState;
  31010. /**
  31011. * Release all resources
  31012. */
  31013. dispose(): void;
  31014. /**
  31015. * Helper function to create a SceneOptimizer with one single line of code
  31016. * @param scene defines the scene to work on
  31017. * @param options defines the options to use with the SceneOptimizer
  31018. * @param onSuccess defines a callback to call on success
  31019. * @param onFailure defines a callback to call on failure
  31020. * @returns the new SceneOptimizer object
  31021. */
  31022. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31023. }
  31024. }
  31025. declare module BABYLON {
  31026. class SceneSerializer {
  31027. static ClearCache(): void;
  31028. static Serialize(scene: Scene): any;
  31029. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31030. }
  31031. }
  31032. declare module BABYLON {
  31033. class SmartArray<T> {
  31034. data: Array<T>;
  31035. length: number;
  31036. protected _id: number;
  31037. [index: number]: T;
  31038. constructor(capacity: number);
  31039. push(value: T): void;
  31040. forEach(func: (content: T) => void): void;
  31041. sort(compareFn: (a: T, b: T) => number): void;
  31042. reset(): void;
  31043. dispose(): void;
  31044. concat(array: any): void;
  31045. indexOf(value: T): number;
  31046. contains(value: T): boolean;
  31047. private static _GlobalId;
  31048. }
  31049. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31050. private _duplicateId;
  31051. [index: number]: T;
  31052. push(value: T): void;
  31053. pushNoDuplicate(value: T): boolean;
  31054. reset(): void;
  31055. concatWithNoDuplicate(array: any): void;
  31056. }
  31057. }
  31058. declare module BABYLON {
  31059. /**
  31060. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31061. * The underlying implementation relies on an associative array to ensure the best performances.
  31062. * The value can be anything including 'null' but except 'undefined'
  31063. */
  31064. class StringDictionary<T> {
  31065. /**
  31066. * This will clear this dictionary and copy the content from the 'source' one.
  31067. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31068. * @param source the dictionary to take the content from and copy to this dictionary
  31069. */
  31070. copyFrom(source: StringDictionary<T>): void;
  31071. /**
  31072. * Get a value based from its key
  31073. * @param key the given key to get the matching value from
  31074. * @return the value if found, otherwise undefined is returned
  31075. */
  31076. get(key: string): T | undefined;
  31077. /**
  31078. * Get a value from its key or add it if it doesn't exist.
  31079. * This method will ensure you that a given key/data will be present in the dictionary.
  31080. * @param key the given key to get the matching value from
  31081. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31082. * The factory will only be invoked if there's no data for the given key.
  31083. * @return the value corresponding to the key.
  31084. */
  31085. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31086. /**
  31087. * Get a value from its key if present in the dictionary otherwise add it
  31088. * @param key the key to get the value from
  31089. * @param val if there's no such key/value pair in the dictionary add it with this value
  31090. * @return the value corresponding to the key
  31091. */
  31092. getOrAdd(key: string, val: T): T;
  31093. /**
  31094. * Check if there's a given key in the dictionary
  31095. * @param key the key to check for
  31096. * @return true if the key is present, false otherwise
  31097. */
  31098. contains(key: string): boolean;
  31099. /**
  31100. * Add a new key and its corresponding value
  31101. * @param key the key to add
  31102. * @param value the value corresponding to the key
  31103. * @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
  31104. */
  31105. add(key: string, value: T): boolean;
  31106. set(key: string, value: T): boolean;
  31107. /**
  31108. * Get the element of the given key and remove it from the dictionary
  31109. * @param key
  31110. */
  31111. getAndRemove(key: string): Nullable<T>;
  31112. /**
  31113. * Remove a key/value from the dictionary.
  31114. * @param key the key to remove
  31115. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31116. */
  31117. remove(key: string): boolean;
  31118. /**
  31119. * Clear the whole content of the dictionary
  31120. */
  31121. clear(): void;
  31122. readonly count: number;
  31123. /**
  31124. * Execute a callback on each key/val of the dictionary.
  31125. * Note that you can remove any element in this dictionary in the callback implementation
  31126. * @param callback the callback to execute on a given key/value pair
  31127. */
  31128. forEach(callback: (key: string, val: T) => void): void;
  31129. /**
  31130. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31131. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31132. * Note that you can remove any element in this dictionary in the callback implementation
  31133. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31134. */
  31135. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31136. private _count;
  31137. private _data;
  31138. }
  31139. }
  31140. declare module BABYLON {
  31141. class Tags {
  31142. static EnableFor(obj: any): void;
  31143. static DisableFor(obj: any): void;
  31144. static HasTags(obj: any): boolean;
  31145. static GetTags(obj: any, asString?: boolean): any;
  31146. static AddTagsTo(obj: any, tagsString: string): void;
  31147. static _AddTagTo(obj: any, tag: string): void;
  31148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  31149. static _RemoveTagFrom(obj: any, tag: string): void;
  31150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  31151. }
  31152. }
  31153. declare module BABYLON {
  31154. class TextureTools {
  31155. /**
  31156. * Uses the GPU to create a copy texture rescaled at a given size
  31157. * @param texture Texture to copy from
  31158. * @param width Desired width
  31159. * @param height Desired height
  31160. * @return Generated texture
  31161. */
  31162. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  31163. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  31164. private static _environmentBRDFBase64Texture;
  31165. }
  31166. }
  31167. declare module BABYLON {
  31168. class TGATools {
  31169. private static _TYPE_INDEXED;
  31170. private static _TYPE_RGB;
  31171. private static _TYPE_GREY;
  31172. private static _TYPE_RLE_INDEXED;
  31173. private static _TYPE_RLE_RGB;
  31174. private static _TYPE_RLE_GREY;
  31175. private static _ORIGIN_MASK;
  31176. private static _ORIGIN_SHIFT;
  31177. private static _ORIGIN_BL;
  31178. private static _ORIGIN_BR;
  31179. private static _ORIGIN_UL;
  31180. private static _ORIGIN_UR;
  31181. static GetTGAHeader(data: Uint8Array): any;
  31182. /**
  31183. * Uploads TGA content to a Babylon Texture
  31184. * @hidden
  31185. */
  31186. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  31187. 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;
  31188. 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;
  31189. 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;
  31190. 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;
  31191. 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;
  31192. 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;
  31193. }
  31194. }
  31195. declare module BABYLON {
  31196. interface IAnimatable {
  31197. animations: Array<Animation>;
  31198. }
  31199. /** Interface used by value gradients (color, factor, ...) */
  31200. interface IValueGradient {
  31201. /**
  31202. * Gets or sets the gradient value (between 0 and 1)
  31203. */
  31204. gradient: number;
  31205. }
  31206. /** Class used to store color gradient */
  31207. class ColorGradient implements IValueGradient {
  31208. /**
  31209. * Gets or sets the gradient value (between 0 and 1)
  31210. */
  31211. gradient: number;
  31212. /**
  31213. * Gets or sets first associated color
  31214. */
  31215. color1: Color4;
  31216. /**
  31217. * Gets or sets second associated color
  31218. */
  31219. color2?: Color4;
  31220. /**
  31221. * Will get a color picked randomly between color1 and color2.
  31222. * If color2 is undefined then color1 will be used
  31223. * @param result defines the target Color4 to store the result in
  31224. */
  31225. getColorToRef(result: Color4): void;
  31226. }
  31227. /** Class used to store factor gradient */
  31228. class FactorGradient implements IValueGradient {
  31229. /**
  31230. * Gets or sets the gradient value (between 0 and 1)
  31231. */
  31232. gradient: number;
  31233. /**
  31234. * Gets or sets first associated factor
  31235. */
  31236. factor1: number;
  31237. /**
  31238. * Gets or sets second associated factor
  31239. */
  31240. factor2?: number;
  31241. /**
  31242. * Will get a number picked randomly between factor1 and factor2.
  31243. * If factor2 is undefined then factor1 will be used
  31244. * @returns the picked number
  31245. */
  31246. getFactor(): number;
  31247. }
  31248. class LoadFileError extends Error {
  31249. request?: XMLHttpRequest | undefined;
  31250. private static _setPrototypeOf;
  31251. constructor(message: string, request?: XMLHttpRequest | undefined);
  31252. }
  31253. class RetryStrategy {
  31254. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31255. }
  31256. interface IFileRequest {
  31257. /**
  31258. * Raised when the request is complete (success or error).
  31259. */
  31260. onCompleteObservable: Observable<IFileRequest>;
  31261. /**
  31262. * Aborts the request for a file.
  31263. */
  31264. abort: () => void;
  31265. }
  31266. class Tools {
  31267. static BaseUrl: string;
  31268. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31269. /**
  31270. * Default behaviour for cors in the application.
  31271. * It can be a string if the expected behavior is identical in the entire app.
  31272. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31273. */
  31274. static CorsBehavior: string | ((url: string | string[]) => string);
  31275. static UseFallbackTexture: boolean;
  31276. /**
  31277. * Use this object to register external classes like custom textures or material
  31278. * to allow the laoders to instantiate them
  31279. */
  31280. static RegisteredExternalClasses: {
  31281. [key: string]: Object;
  31282. };
  31283. static fallbackTexture: string;
  31284. /**
  31285. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31286. * @param u defines the coordinate on X axis
  31287. * @param v defines the coordinate on Y axis
  31288. * @param width defines the width of the source data
  31289. * @param height defines the height of the source data
  31290. * @param pixels defines the source byte array
  31291. * @param color defines the output color
  31292. */
  31293. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31294. /**
  31295. * Interpolates between a and b via alpha
  31296. * @param a The lower value (returned when alpha = 0)
  31297. * @param b The upper value (returned when alpha = 1)
  31298. * @param alpha The interpolation-factor
  31299. * @return The mixed value
  31300. */
  31301. static Mix(a: number, b: number, alpha: number): number;
  31302. static Instantiate(className: string): any;
  31303. /**
  31304. * Provides a slice function that will work even on IE
  31305. * @param data defines the array to slice
  31306. * @param start defines the start of the data (optional)
  31307. * @param end defines the end of the data (optional)
  31308. * @returns the new sliced array
  31309. */
  31310. static Slice<T>(data: T, start?: number, end?: number): T;
  31311. static SetImmediate(action: () => void): void;
  31312. static IsExponentOfTwo(value: number): boolean;
  31313. private static _tmpFloatArray;
  31314. /**
  31315. * Returns the nearest 32-bit single precision float representation of a Number
  31316. * @param value A Number. If the parameter is of a different type, it will get converted
  31317. * to a number or to NaN if it cannot be converted
  31318. * @returns number
  31319. */
  31320. static FloatRound(value: number): number;
  31321. /**
  31322. * Find the next highest power of two.
  31323. * @param x Number to start search from.
  31324. * @return Next highest power of two.
  31325. */
  31326. static CeilingPOT(x: number): number;
  31327. /**
  31328. * Find the next lowest power of two.
  31329. * @param x Number to start search from.
  31330. * @return Next lowest power of two.
  31331. */
  31332. static FloorPOT(x: number): number;
  31333. /**
  31334. * Find the nearest power of two.
  31335. * @param x Number to start search from.
  31336. * @return Next nearest power of two.
  31337. */
  31338. static NearestPOT(x: number): number;
  31339. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31340. static GetFilename(path: string): string;
  31341. /**
  31342. * Extracts the "folder" part of a path (everything before the filename).
  31343. * @param uri The URI to extract the info from
  31344. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31345. * @returns The "folder" part of the path
  31346. */
  31347. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31348. static GetDOMTextContent(element: HTMLElement): string;
  31349. static ToDegrees(angle: number): number;
  31350. static ToRadians(angle: number): number;
  31351. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31352. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31353. minimum: Vector3;
  31354. maximum: Vector3;
  31355. };
  31356. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31357. minimum: Vector3;
  31358. maximum: Vector3;
  31359. };
  31360. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  31361. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  31362. minimum: Vector2;
  31363. maximum: Vector2;
  31364. };
  31365. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31366. static GetPointerPrefix(): string;
  31367. /**
  31368. * @param func - the function to be called
  31369. * @param requester - the object that will request the next frame. Falls back to window.
  31370. */
  31371. static QueueNewFrame(func: () => void, requester?: any): number;
  31372. static RequestFullscreen(element: HTMLElement): void;
  31373. static ExitFullscreen(): void;
  31374. static SetCorsBehavior(url: string | string[], element: {
  31375. crossOrigin: string | null;
  31376. }): void;
  31377. static CleanUrl(url: string): string;
  31378. static PreprocessUrl: (url: string) => string;
  31379. /**
  31380. * Loads an image as an HTMLImageElement.
  31381. * @param input url string, ArrayBuffer, or Blob to load
  31382. * @param onLoad callback called when the image successfully loads
  31383. * @param onError callback called when the image fails to load
  31384. * @param database database for caching
  31385. * @returns the HTMLImageElement of the loaded image
  31386. */
  31387. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  31388. 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;
  31389. /**
  31390. * Load a script (identified by an url). When the url returns, the
  31391. * content of this file is added into a new script element, attached to the DOM (body element)
  31392. */
  31393. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31394. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31395. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31396. static FileAsURL(content: string): string;
  31397. static Format(value: number, decimals?: number): string;
  31398. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31399. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31400. static IsEmpty(obj: any): boolean;
  31401. static RegisterTopRootEvents(events: {
  31402. name: string;
  31403. handler: Nullable<(e: FocusEvent) => any>;
  31404. }[]): void;
  31405. static UnregisterTopRootEvents(events: {
  31406. name: string;
  31407. handler: Nullable<(e: FocusEvent) => any>;
  31408. }[]): void;
  31409. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31410. /**
  31411. * Converts the canvas data to blob.
  31412. * This acts as a polyfill for browsers not supporting the to blob function.
  31413. * @param canvas Defines the canvas to extract the data from
  31414. * @param successCallback Defines the callback triggered once the data are available
  31415. * @param mimeType Defines the mime type of the result
  31416. */
  31417. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31418. /**
  31419. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31420. * @param successCallback Defines the callback triggered once the data are available
  31421. * @param mimeType Defines the mime type of the result
  31422. * @param fileName The filename to download. If present, the result will automatically be downloaded
  31423. */
  31424. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31425. /**
  31426. * Downloads a blob in the browser
  31427. * @param blob defines the blob to download
  31428. * @param fileName defines the name of the downloaded file
  31429. */
  31430. static Download(blob: Blob, fileName: string): void;
  31431. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31432. /**
  31433. * Generates an image screenshot from the specified camera.
  31434. *
  31435. * @param engine The engine to use for rendering
  31436. * @param camera The camera to use for rendering
  31437. * @param size This parameter can be set to a single number or to an object with the
  31438. * following (optional) properties: precision, width, height. If a single number is passed,
  31439. * it will be used for both width and height. If an object is passed, the screenshot size
  31440. * will be derived from the parameters. The precision property is a multiplier allowing
  31441. * rendering at a higher or lower resolution.
  31442. * @param successCallback The callback receives a single parameter which contains the
  31443. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31444. * src parameter of an <img> to display it.
  31445. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31446. * Check your browser for supported MIME types.
  31447. * @param samples Texture samples (default: 1)
  31448. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31449. * @param fileName A name for for the downloaded file.
  31450. * @constructor
  31451. */
  31452. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31453. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  31454. /**
  31455. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31456. * Be aware Math.random() could cause collisions, but:
  31457. * "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"
  31458. */
  31459. static RandomId(): string;
  31460. /**
  31461. * Test if the given uri is a base64 string.
  31462. * @param uri The uri to test
  31463. * @return True if the uri is a base64 string or false otherwise.
  31464. */
  31465. static IsBase64(uri: string): boolean;
  31466. /**
  31467. * Decode the given base64 uri.
  31468. * @param uri The uri to decode
  31469. * @return The decoded base64 data.
  31470. */
  31471. static DecodeBase64(uri: string): ArrayBuffer;
  31472. private static _NoneLogLevel;
  31473. private static _MessageLogLevel;
  31474. private static _WarningLogLevel;
  31475. private static _ErrorLogLevel;
  31476. private static _LogCache;
  31477. static errorsCount: number;
  31478. static OnNewCacheEntry: (entry: string) => void;
  31479. static readonly NoneLogLevel: number;
  31480. static readonly MessageLogLevel: number;
  31481. static readonly WarningLogLevel: number;
  31482. static readonly ErrorLogLevel: number;
  31483. static readonly AllLogLevel: number;
  31484. private static _AddLogEntry;
  31485. private static _FormatMessage;
  31486. private static _LogDisabled;
  31487. private static _LogEnabled;
  31488. private static _WarnDisabled;
  31489. private static _WarnEnabled;
  31490. private static _ErrorDisabled;
  31491. private static _ErrorEnabled;
  31492. static Log: (message: string) => void;
  31493. static Warn: (message: string) => void;
  31494. static Error: (message: string) => void;
  31495. static readonly LogCache: string;
  31496. static ClearLogCache(): void;
  31497. static LogLevels: number;
  31498. /**
  31499. * Check if the loaded document was accessed via `file:`-Protocol.
  31500. * @returns boolean
  31501. */
  31502. static IsFileURL(): boolean;
  31503. static IsWindowObjectExist(): boolean;
  31504. private static _PerformanceNoneLogLevel;
  31505. private static _PerformanceUserMarkLogLevel;
  31506. private static _PerformanceConsoleLogLevel;
  31507. private static _performance;
  31508. static readonly PerformanceNoneLogLevel: number;
  31509. static readonly PerformanceUserMarkLogLevel: number;
  31510. static readonly PerformanceConsoleLogLevel: number;
  31511. static PerformanceLogLevel: number;
  31512. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31513. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  31514. static _StartUserMark(counterName: string, condition?: boolean): void;
  31515. static _EndUserMark(counterName: string, condition?: boolean): void;
  31516. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  31517. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  31518. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31519. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31520. static readonly Now: number;
  31521. /**
  31522. * This method will return the name of the class used to create the instance of the given object.
  31523. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31524. * @param object the object to get the class name from
  31525. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  31526. */
  31527. static GetClassName(object: any, isType?: boolean): string;
  31528. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31529. /**
  31530. * This method will return the name of the full name of the class, including its owning module (if any).
  31531. * 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).
  31532. * @param object the object to get the class name from
  31533. * @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.
  31534. */
  31535. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31536. /**
  31537. * 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.
  31538. * @param array
  31539. */
  31540. static arrayOrStringFeeder(array: any): (i: number) => number;
  31541. /**
  31542. * Compute the hashCode of a stream of number
  31543. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  31544. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  31545. * @return the hash code computed
  31546. */
  31547. static hashCodeFromStream(feeder: (index: number) => number): number;
  31548. /**
  31549. * Returns a promise that resolves after the given amount of time.
  31550. * @param delay Number of milliseconds to delay
  31551. * @returns Promise that resolves after the given amount of time
  31552. */
  31553. static DelayAsync(delay: number): Promise<void>;
  31554. /**
  31555. * Gets the current gradient from an array of IValueGradient
  31556. * @param ratio defines the current ratio to get
  31557. * @param gradients defines the array of IValueGradient
  31558. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31559. */
  31560. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31561. }
  31562. /**
  31563. * This class is used to track a performance counter which is number based.
  31564. * The user has access to many properties which give statistics of different nature
  31565. *
  31566. * The implementer can track two kinds of Performance Counter: time and count
  31567. * 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.
  31568. * 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.
  31569. */
  31570. class PerfCounter {
  31571. static Enabled: boolean;
  31572. /**
  31573. * Returns the smallest value ever
  31574. */
  31575. readonly min: number;
  31576. /**
  31577. * Returns the biggest value ever
  31578. */
  31579. readonly max: number;
  31580. /**
  31581. * Returns the average value since the performance counter is running
  31582. */
  31583. readonly average: number;
  31584. /**
  31585. * Returns the average value of the last second the counter was monitored
  31586. */
  31587. readonly lastSecAverage: number;
  31588. /**
  31589. * Returns the current value
  31590. */
  31591. readonly current: number;
  31592. readonly total: number;
  31593. readonly count: number;
  31594. constructor();
  31595. /**
  31596. * Call this method to start monitoring a new frame.
  31597. * 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.
  31598. */
  31599. fetchNewFrame(): void;
  31600. /**
  31601. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31602. * @param newCount the count value to add to the monitored count
  31603. * @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.
  31604. */
  31605. addCount(newCount: number, fetchResult: boolean): void;
  31606. /**
  31607. * Start monitoring this performance counter
  31608. */
  31609. beginMonitoring(): void;
  31610. /**
  31611. * Compute the time lapsed since the previous beginMonitoring() call.
  31612. * @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
  31613. */
  31614. endMonitoring(newFrame?: boolean): void;
  31615. private _fetchResult;
  31616. private _startMonitoringTime;
  31617. private _min;
  31618. private _max;
  31619. private _average;
  31620. private _current;
  31621. private _totalValueCount;
  31622. private _totalAccumulated;
  31623. private _lastSecAverage;
  31624. private _lastSecAccumulated;
  31625. private _lastSecTime;
  31626. private _lastSecValueCount;
  31627. }
  31628. /**
  31629. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31630. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31631. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31632. * @param name The name of the class, case should be preserved
  31633. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31634. */
  31635. function className(name: string, module?: string): (target: Object) => void;
  31636. /**
  31637. * An implementation of a loop for asynchronous functions.
  31638. */
  31639. class AsyncLoop {
  31640. iterations: number;
  31641. private _fn;
  31642. private _successCallback;
  31643. index: number;
  31644. private _done;
  31645. /**
  31646. * Constroctor.
  31647. * @param iterations the number of iterations.
  31648. * @param _fn the function to run each iteration
  31649. * @param _successCallback the callback that will be called upon succesful execution
  31650. * @param offset starting offset.
  31651. */
  31652. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  31653. /**
  31654. * Execute the next iteration. Must be called after the last iteration was finished.
  31655. */
  31656. executeNext(): void;
  31657. /**
  31658. * Break the loop and run the success callback.
  31659. */
  31660. breakLoop(): void;
  31661. /**
  31662. * Helper function
  31663. */
  31664. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  31665. /**
  31666. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31667. * @param iterations total number of iterations
  31668. * @param syncedIterations number of synchronous iterations in each async iteration.
  31669. * @param fn the function to call each iteration.
  31670. * @param callback a success call back that will be called when iterating stops.
  31671. * @param breakFunction a break condition (optional)
  31672. * @param timeout timeout settings for the setTimeout function. default - 0.
  31673. * @constructor
  31674. */
  31675. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  31676. }
  31677. }
  31678. interface HTMLCanvasElement {
  31679. /** Track wether a record is in progress */
  31680. isRecording: boolean;
  31681. /** Capture Stream method defined by some browsers */
  31682. captureStream(fps?: number): MediaStream;
  31683. }
  31684. interface MediaRecorder {
  31685. /** Starts recording */
  31686. start(timeSlice: number): void;
  31687. /** Stops recording */
  31688. stop(): void;
  31689. /** Event raised when an error arised. */
  31690. onerror: (event: ErrorEvent) => void;
  31691. /** Event raised when the recording stops. */
  31692. onstop: (event: Event) => void;
  31693. /** Event raised when a new chunk of data is available and should be tracked. */
  31694. ondataavailable: (event: Event) => void;
  31695. }
  31696. interface MediaRecorderOptions {
  31697. /** The mime type you want to use as the recording container for the new MediaRecorder */
  31698. mimeType?: string;
  31699. /** The chosen bitrate for the audio component of the media. */
  31700. audioBitsPerSecond?: number;
  31701. /** The chosen bitrate for the video component of the media. */
  31702. videoBitsPerSecond?: number;
  31703. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  31704. bitsPerSecond?: number;
  31705. }
  31706. interface MediaRecorderConstructor {
  31707. /**
  31708. * A reference to the prototype.
  31709. */
  31710. readonly prototype: MediaRecorder;
  31711. /**
  31712. * Creates a new MediaRecorder.
  31713. * @param stream Defines the stream to record.
  31714. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  31715. */
  31716. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  31717. }
  31718. /**
  31719. * MediaRecoreder object available in some browsers.
  31720. */
  31721. declare var MediaRecorder: MediaRecorderConstructor;
  31722. declare module BABYLON {
  31723. /**
  31724. * This represents the different options avilable for the video capture.
  31725. */
  31726. interface VideoRecorderOptions {
  31727. /** Defines the mime type of the video */
  31728. mimeType: string;
  31729. /** Defines the video the video should be recorded at */
  31730. fps: number;
  31731. /** Defines the chunk size for the recording data */
  31732. recordChunckSize: number;
  31733. }
  31734. /**
  31735. * This can helps recording videos from BabylonJS.
  31736. * This is based on the available WebRTC functionalities of the browser.
  31737. *
  31738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  31739. */
  31740. class VideoRecorder {
  31741. private static readonly _defaultOptions;
  31742. /**
  31743. * Returns wehther or not the VideoRecorder is available in your browser.
  31744. * @param engine Defines the Babylon Engine to check the support for
  31745. * @returns true if supported otherwise false
  31746. */
  31747. static IsSupported(engine: Engine): boolean;
  31748. private readonly _options;
  31749. private _canvas;
  31750. private _mediaRecorder;
  31751. private _recordedChunks;
  31752. private _fileName;
  31753. private _resolve;
  31754. private _reject;
  31755. /**
  31756. * True wether a recording is already in progress.
  31757. */
  31758. readonly isRecording: boolean;
  31759. /**
  31760. * Create a new VideoCapture object which can help converting what you see in Babylon to
  31761. * a video file.
  31762. * @param engine Defines the BabylonJS Engine you wish to record
  31763. * @param options Defines options that can be used to customized the capture
  31764. */
  31765. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  31766. /**
  31767. * Stops the current recording before the default capture timeout passed in the startRecording
  31768. * functions.
  31769. */
  31770. stopRecording(): void;
  31771. /**
  31772. * Starts recording the canvas for a max duration specified in parameters.
  31773. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  31774. * @param maxDuration Defines the maximum recording time in seconds.
  31775. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  31776. * @return a promise callback at the end of the recording with the video data in Blob.
  31777. */
  31778. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  31779. /**
  31780. * Releases internal resources used during the recording.
  31781. */
  31782. dispose(): void;
  31783. private _handleDataAvailable;
  31784. private _handleError;
  31785. private _handleStop;
  31786. }
  31787. }
  31788. declare module BABYLON {
  31789. /**
  31790. * Defines the potential axis of a Joystick
  31791. */
  31792. enum JoystickAxis {
  31793. /** X axis */
  31794. X = 0,
  31795. /** Y axis */
  31796. Y = 1,
  31797. /** Z axis */
  31798. Z = 2
  31799. }
  31800. /**
  31801. * Class used to define virtual joystick (used in touch mode)
  31802. */
  31803. class VirtualJoystick {
  31804. /**
  31805. * Gets or sets a boolean indicating that left and right values must be inverted
  31806. */
  31807. reverseLeftRight: boolean;
  31808. /**
  31809. * Gets or sets a boolean indicating that up and down values must be inverted
  31810. */
  31811. reverseUpDown: boolean;
  31812. /**
  31813. * Gets the offset value for the position (ie. the change of the position value)
  31814. */
  31815. deltaPosition: Vector3;
  31816. /**
  31817. * Gets a boolean indicating if the virtual joystick was pressed
  31818. */
  31819. pressed: boolean;
  31820. private static _globalJoystickIndex;
  31821. private static vjCanvas;
  31822. private static vjCanvasContext;
  31823. private static vjCanvasWidth;
  31824. private static vjCanvasHeight;
  31825. private static halfWidth;
  31826. private _action;
  31827. private _axisTargetedByLeftAndRight;
  31828. private _axisTargetedByUpAndDown;
  31829. private _joystickSensibility;
  31830. private _inversedSensibility;
  31831. private _joystickPointerID;
  31832. private _joystickColor;
  31833. private _joystickPointerPos;
  31834. private _joystickPreviousPointerPos;
  31835. private _joystickPointerStartPos;
  31836. private _deltaJoystickVector;
  31837. private _leftJoystick;
  31838. private _touches;
  31839. private _onPointerDownHandlerRef;
  31840. private _onPointerMoveHandlerRef;
  31841. private _onPointerUpHandlerRef;
  31842. private _onResize;
  31843. /**
  31844. * Creates a new virtual joystick
  31845. * @param leftJoystick defines that the joystick is for left hand (false by default)
  31846. */
  31847. constructor(leftJoystick?: boolean);
  31848. /**
  31849. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  31850. * @param newJoystickSensibility defines the new sensibility
  31851. */
  31852. setJoystickSensibility(newJoystickSensibility: number): void;
  31853. private _onPointerDown;
  31854. private _onPointerMove;
  31855. private _onPointerUp;
  31856. /**
  31857. * Change the color of the virtual joystick
  31858. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  31859. */
  31860. setJoystickColor(newColor: string): void;
  31861. /**
  31862. * Defines a callback to call when the joystick is touched
  31863. * @param action defines the callback
  31864. */
  31865. setActionOnTouch(action: () => any): void;
  31866. /**
  31867. * Defines which axis you'd like to control for left & right
  31868. * @param axis defines the axis to use
  31869. */
  31870. setAxisForLeftRight(axis: JoystickAxis): void;
  31871. /**
  31872. * Defines which axis you'd like to control for up & down
  31873. * @param axis defines the axis to use
  31874. */
  31875. setAxisForUpDown(axis: JoystickAxis): void;
  31876. private _drawVirtualJoystick;
  31877. /**
  31878. * Release internal HTML canvas
  31879. */
  31880. releaseCanvas(): void;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * Helper class to push actions to a pool of workers.
  31886. */
  31887. class WorkerPool implements IDisposable {
  31888. private _workerInfos;
  31889. private _pendingActions;
  31890. /**
  31891. * Constructor
  31892. * @param workers Array of workers to use for actions
  31893. */
  31894. constructor(workers: Array<Worker>);
  31895. /**
  31896. * Terminates all workers and clears any pending actions.
  31897. */
  31898. dispose(): void;
  31899. /**
  31900. * Pushes an action to the worker pool. If all the workers are active, the action will be
  31901. * pended until a worker has completed its action.
  31902. * @param action The action to perform. Call onComplete when the action is complete.
  31903. */
  31904. push(action: (worker: Worker, onComplete: () => void) => void): void;
  31905. private _execute;
  31906. }
  31907. }
  31908. declare module BABYLON {
  31909. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  31910. readonly name: string;
  31911. private _zoomStopsAnimation;
  31912. private _idleRotationSpeed;
  31913. private _idleRotationWaitTime;
  31914. private _idleRotationSpinupTime;
  31915. /**
  31916. * Sets the flag that indicates if user zooming should stop animation.
  31917. */
  31918. /**
  31919. * Gets the flag that indicates if user zooming should stop animation.
  31920. */
  31921. zoomStopsAnimation: boolean;
  31922. /**
  31923. * Sets the default speed at which the camera rotates around the model.
  31924. */
  31925. /**
  31926. * Gets the default speed at which the camera rotates around the model.
  31927. */
  31928. idleRotationSpeed: number;
  31929. /**
  31930. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  31931. */
  31932. /**
  31933. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  31934. */
  31935. idleRotationWaitTime: number;
  31936. /**
  31937. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31938. */
  31939. /**
  31940. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31941. */
  31942. idleRotationSpinupTime: number;
  31943. /**
  31944. * Gets a value indicating if the camera is currently rotating because of this behavior
  31945. */
  31946. readonly rotationInProgress: boolean;
  31947. private _onPrePointerObservableObserver;
  31948. private _onAfterCheckInputsObserver;
  31949. private _attachedCamera;
  31950. private _isPointerDown;
  31951. private _lastFrameTime;
  31952. private _lastInteractionTime;
  31953. private _cameraRotationSpeed;
  31954. init(): void;
  31955. attach(camera: ArcRotateCamera): void;
  31956. detach(): void;
  31957. /**
  31958. * Returns true if user is scrolling.
  31959. * @return true if user is scrolling.
  31960. */
  31961. private _userIsZooming;
  31962. private _lastFrameRadius;
  31963. private _shouldAnimationStopForInteraction;
  31964. /**
  31965. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31966. */
  31967. private _applyUserInteraction;
  31968. private _userIsMoving;
  31969. }
  31970. }
  31971. declare module BABYLON {
  31972. /**
  31973. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  31974. */
  31975. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  31976. readonly name: string;
  31977. /**
  31978. * The easing function used by animations
  31979. */
  31980. static EasingFunction: BackEase;
  31981. /**
  31982. * The easing mode used by animations
  31983. */
  31984. static EasingMode: number;
  31985. /**
  31986. * The duration of the animation, in milliseconds
  31987. */
  31988. transitionDuration: number;
  31989. /**
  31990. * Length of the distance animated by the transition when lower radius is reached
  31991. */
  31992. lowerRadiusTransitionRange: number;
  31993. /**
  31994. * Length of the distance animated by the transition when upper radius is reached
  31995. */
  31996. upperRadiusTransitionRange: number;
  31997. private _autoTransitionRange;
  31998. /**
  31999. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32000. */
  32001. /**
  32002. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32003. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32004. */
  32005. autoTransitionRange: boolean;
  32006. private _attachedCamera;
  32007. private _onAfterCheckInputsObserver;
  32008. private _onMeshTargetChangedObserver;
  32009. init(): void;
  32010. attach(camera: ArcRotateCamera): void;
  32011. detach(): void;
  32012. private _radiusIsAnimating;
  32013. private _radiusBounceTransition;
  32014. private _animatables;
  32015. private _cachedWheelPrecision;
  32016. /**
  32017. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32018. * @param radiusLimit The limit to check against.
  32019. * @return Bool to indicate if at limit.
  32020. */
  32021. private _isRadiusAtLimit;
  32022. /**
  32023. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32024. * @param radiusDelta The delta by which to animate to. Can be negative.
  32025. */
  32026. private _applyBoundRadiusAnimation;
  32027. /**
  32028. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32029. */
  32030. protected _clearAnimationLocks(): void;
  32031. /**
  32032. * Stops and removes all animations that have been applied to the camera
  32033. */
  32034. stopAllAnimations(): void;
  32035. }
  32036. }
  32037. declare module BABYLON {
  32038. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32039. readonly name: string;
  32040. private _mode;
  32041. private _radiusScale;
  32042. private _positionScale;
  32043. private _defaultElevation;
  32044. private _elevationReturnTime;
  32045. private _elevationReturnWaitTime;
  32046. private _zoomStopsAnimation;
  32047. private _framingTime;
  32048. /**
  32049. * The easing function used by animations
  32050. */
  32051. static EasingFunction: ExponentialEase;
  32052. /**
  32053. * The easing mode used by animations
  32054. */
  32055. static EasingMode: number;
  32056. /**
  32057. * Sets the current mode used by the behavior
  32058. */
  32059. /**
  32060. * Gets current mode used by the behavior.
  32061. */
  32062. mode: number;
  32063. /**
  32064. * Sets the scale applied to the radius (1 by default)
  32065. */
  32066. /**
  32067. * Gets the scale applied to the radius
  32068. */
  32069. radiusScale: number;
  32070. /**
  32071. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32072. */
  32073. /**
  32074. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32075. */
  32076. positionScale: number;
  32077. /**
  32078. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32079. * behaviour is triggered, in radians.
  32080. */
  32081. /**
  32082. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  32083. * behaviour is triggered, in radians.
  32084. */
  32085. defaultElevation: number;
  32086. /**
  32087. * Sets the time (in milliseconds) taken to return to the default beta position.
  32088. * Negative value indicates camera should not return to default.
  32089. */
  32090. /**
  32091. * Gets the time (in milliseconds) taken to return to the default beta position.
  32092. * Negative value indicates camera should not return to default.
  32093. */
  32094. elevationReturnTime: number;
  32095. /**
  32096. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32097. */
  32098. /**
  32099. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  32100. */
  32101. elevationReturnWaitTime: number;
  32102. /**
  32103. * Sets the flag that indicates if user zooming should stop animation.
  32104. */
  32105. /**
  32106. * Gets the flag that indicates if user zooming should stop animation.
  32107. */
  32108. zoomStopsAnimation: boolean;
  32109. /**
  32110. * Sets the transition time when framing the mesh, in milliseconds
  32111. */
  32112. /**
  32113. * Gets the transition time when framing the mesh, in milliseconds
  32114. */
  32115. framingTime: number;
  32116. private _onPrePointerObservableObserver;
  32117. private _onAfterCheckInputsObserver;
  32118. private _onMeshTargetChangedObserver;
  32119. private _attachedCamera;
  32120. private _isPointerDown;
  32121. private _lastInteractionTime;
  32122. init(): void;
  32123. attach(camera: ArcRotateCamera): void;
  32124. detach(): void;
  32125. private _animatables;
  32126. private _betaIsAnimating;
  32127. private _betaTransition;
  32128. private _radiusTransition;
  32129. private _vectorTransition;
  32130. /**
  32131. * Targets the given mesh and updates zoom level accordingly.
  32132. * @param mesh The mesh to target.
  32133. * @param radius Optional. If a cached radius position already exists, overrides default.
  32134. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32137. */
  32138. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32139. /**
  32140. * Targets the given mesh with its children and updates zoom level accordingly.
  32141. * @param mesh The mesh to target.
  32142. * @param radius Optional. If a cached radius position already exists, overrides default.
  32143. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32146. */
  32147. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32148. /**
  32149. * Targets the given meshes with their children and updates zoom level accordingly.
  32150. * @param meshes The mesh to target.
  32151. * @param radius Optional. If a cached radius position already exists, overrides default.
  32152. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32155. */
  32156. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32157. /**
  32158. * Targets the given mesh and updates zoom level accordingly.
  32159. * @param mesh The mesh to target.
  32160. * @param radius Optional. If a cached radius position already exists, overrides default.
  32161. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  32162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  32163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  32164. */
  32165. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  32166. /**
  32167. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  32168. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  32169. * frustum width.
  32170. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  32171. * to fully enclose the mesh in the viewing frustum.
  32172. */
  32173. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  32174. /**
  32175. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  32176. * is automatically returned to its default position (expected to be above ground plane).
  32177. */
  32178. private _maintainCameraAboveGround;
  32179. /**
  32180. * Returns the frustum slope based on the canvas ratio and camera FOV
  32181. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  32182. */
  32183. private _getFrustumSlope;
  32184. /**
  32185. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  32186. */
  32187. private _clearAnimationLocks;
  32188. /**
  32189. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32190. */
  32191. private _applyUserInteraction;
  32192. /**
  32193. * Stops and removes all animations that have been applied to the camera
  32194. */
  32195. stopAllAnimations(): void;
  32196. /**
  32197. * Gets a value indicating if the user is moving the camera
  32198. */
  32199. readonly isUserIsMoving: boolean;
  32200. /**
  32201. * The camera can move all the way towards the mesh.
  32202. */
  32203. static IgnoreBoundsSizeMode: number;
  32204. /**
  32205. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  32206. */
  32207. static FitFrustumSidesMode: number;
  32208. }
  32209. }
  32210. declare module BABYLON {
  32211. /**
  32212. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  32213. */
  32214. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  32215. private ui;
  32216. /**
  32217. * The name of the behavior
  32218. */
  32219. name: string;
  32220. /**
  32221. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  32222. */
  32223. distanceAwayFromFace: number;
  32224. /**
  32225. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  32226. */
  32227. distanceAwayFromBottomOfFace: number;
  32228. private _faceVectors;
  32229. private _target;
  32230. private _scene;
  32231. private _onRenderObserver;
  32232. private _tmpMatrix;
  32233. private _tmpVector;
  32234. /**
  32235. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  32236. * @param ui The transform node that should be attched to the mesh
  32237. */
  32238. constructor(ui: BABYLON.TransformNode);
  32239. /**
  32240. * Initializes the behavior
  32241. */
  32242. init(): void;
  32243. private _closestFace;
  32244. private _zeroVector;
  32245. private _lookAtTmpMatrix;
  32246. private _lookAtToRef;
  32247. /**
  32248. * Attaches the AttachToBoxBehavior to the passed in mesh
  32249. * @param target The mesh that the specified node will be attached to
  32250. */
  32251. attach(target: BABYLON.Mesh): void;
  32252. /**
  32253. * Detaches the behavior from the mesh
  32254. */
  32255. detach(): void;
  32256. }
  32257. }
  32258. declare module BABYLON {
  32259. /**
  32260. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  32261. */
  32262. class FadeInOutBehavior implements Behavior<Mesh> {
  32263. /**
  32264. * Time in milliseconds to delay before fading in (Default: 0)
  32265. */
  32266. delay: number;
  32267. /**
  32268. * Time in milliseconds for the mesh to fade in (Default: 300)
  32269. */
  32270. fadeInTime: number;
  32271. private _millisecondsPerFrame;
  32272. private _hovered;
  32273. private _hoverValue;
  32274. private _ownerNode;
  32275. /**
  32276. * Instatiates the FadeInOutBehavior
  32277. */
  32278. constructor();
  32279. /**
  32280. * The name of the behavior
  32281. */
  32282. readonly name: string;
  32283. /**
  32284. * Initializes the behavior
  32285. */
  32286. init(): void;
  32287. /**
  32288. * Attaches the fade behavior on the passed in mesh
  32289. * @param ownerNode The mesh that will be faded in/out once attached
  32290. */
  32291. attach(ownerNode: Mesh): void;
  32292. /**
  32293. * Detaches the behavior from the mesh
  32294. */
  32295. detach(): void;
  32296. /**
  32297. * Triggers the mesh to begin fading in or out
  32298. * @param value if the object should fade in or out (true to fade in)
  32299. */
  32300. fadeIn(value: boolean): void;
  32301. private _update;
  32302. private _setAllVisibility;
  32303. }
  32304. }
  32305. declare module BABYLON {
  32306. /**
  32307. * A behavior that when attached to a mesh will allow the mesh to be scaled
  32308. */
  32309. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  32310. private _dragBehaviorA;
  32311. private _dragBehaviorB;
  32312. private _startDistance;
  32313. private _initialScale;
  32314. private _targetScale;
  32315. private _ownerNode;
  32316. private _sceneRenderObserver;
  32317. constructor();
  32318. /**
  32319. * The name of the behavior
  32320. */
  32321. readonly name: string;
  32322. /**
  32323. * Initializes the behavior
  32324. */
  32325. init(): void;
  32326. private _getCurrentDistance;
  32327. /**
  32328. * Attaches the scale behavior the passed in mesh
  32329. * @param ownerNode The mesh that will be scaled around once attached
  32330. */
  32331. attach(ownerNode: Mesh): void;
  32332. /**
  32333. * Detaches the behavior from the mesh
  32334. */
  32335. detach(): void;
  32336. }
  32337. }
  32338. declare module BABYLON {
  32339. /**
  32340. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  32341. */
  32342. class PointerDragBehavior implements Behavior<Mesh> {
  32343. private _attachedNode;
  32344. private _dragPlane;
  32345. private _scene;
  32346. private _pointerObserver;
  32347. private _beforeRenderObserver;
  32348. private static _planeScene;
  32349. /**
  32350. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  32351. */
  32352. maxDragAngle: number;
  32353. /**
  32354. * @hidden
  32355. */
  32356. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  32357. /**
  32358. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32359. */
  32360. currentDraggingPointerID: number;
  32361. /**
  32362. * The last position where the pointer hit the drag plane in world space
  32363. */
  32364. lastDragPosition: Vector3;
  32365. /**
  32366. * If the behavior is currently in a dragging state
  32367. */
  32368. dragging: boolean;
  32369. /**
  32370. * 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)
  32371. */
  32372. dragDeltaRatio: number;
  32373. /**
  32374. * If the drag plane orientation should be updated during the dragging (Default: true)
  32375. */
  32376. updateDragPlane: boolean;
  32377. private _debugMode;
  32378. private _moving;
  32379. /**
  32380. * Fires each time the attached mesh is dragged with the pointer
  32381. * * delta between last drag position and current drag position in world space
  32382. * * dragDistance along the drag axis
  32383. * * dragPlaneNormal normal of the current drag plane used during the drag
  32384. * * dragPlanePoint in world space where the drag intersects the drag plane
  32385. */
  32386. onDragObservable: Observable<{
  32387. delta: Vector3;
  32388. dragPlanePoint: Vector3;
  32389. dragPlaneNormal: Vector3;
  32390. dragDistance: number;
  32391. pointerId: number;
  32392. }>;
  32393. /**
  32394. * Fires each time a drag begins (eg. mouse down on mesh)
  32395. */
  32396. onDragStartObservable: Observable<{
  32397. dragPlanePoint: Vector3;
  32398. pointerId: number;
  32399. }>;
  32400. /**
  32401. * Fires each time a drag ends (eg. mouse release after drag)
  32402. */
  32403. onDragEndObservable: Observable<{
  32404. dragPlanePoint: Vector3;
  32405. pointerId: number;
  32406. }>;
  32407. /**
  32408. * If the attached mesh should be moved when dragged
  32409. */
  32410. moveAttached: boolean;
  32411. /**
  32412. * If the drag behavior will react to drag events (Default: true)
  32413. */
  32414. enabled: boolean;
  32415. /**
  32416. * If camera controls should be detached during the drag
  32417. */
  32418. detachCameraControls: boolean;
  32419. /**
  32420. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32421. */
  32422. useObjectOrienationForDragging: boolean;
  32423. private _options;
  32424. /**
  32425. * Creates a pointer drag behavior that can be attached to a mesh
  32426. * @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)
  32427. */
  32428. constructor(options?: {
  32429. dragAxis?: Vector3;
  32430. dragPlaneNormal?: Vector3;
  32431. });
  32432. /**
  32433. * The name of the behavior
  32434. */
  32435. readonly name: string;
  32436. /**
  32437. * Initializes the behavior
  32438. */
  32439. init(): void;
  32440. private _tmpVector;
  32441. private _alternatePickedPoint;
  32442. private _worldDragAxis;
  32443. /**
  32444. * Attaches the drag behavior the passed in mesh
  32445. * @param ownerNode The mesh that will be dragged around once attached
  32446. */
  32447. attach(ownerNode: Mesh): void;
  32448. releaseDrag(): void;
  32449. private _pickWithRayOnDragPlane;
  32450. private _pointA;
  32451. private _pointB;
  32452. private _pointC;
  32453. private _lineA;
  32454. private _lineB;
  32455. private _localAxis;
  32456. private _lookAt;
  32457. private _updateDragPlanePosition;
  32458. /**
  32459. * Detaches the behavior from the mesh
  32460. */
  32461. detach(): void;
  32462. }
  32463. }
  32464. declare module BABYLON {
  32465. /**
  32466. * 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
  32467. */
  32468. class SixDofDragBehavior implements Behavior<Mesh> {
  32469. private static _virtualScene;
  32470. private _ownerNode;
  32471. private _sceneRenderObserver;
  32472. private _scene;
  32473. private _targetPosition;
  32474. private _virtualOriginMesh;
  32475. private _virtualDragMesh;
  32476. private _pointerObserver;
  32477. private _moving;
  32478. private _startingOrientation;
  32479. /**
  32480. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  32481. */
  32482. private zDragFactor;
  32483. /**
  32484. * If the behavior is currently in a dragging state
  32485. */
  32486. dragging: boolean;
  32487. /**
  32488. * 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)
  32489. */
  32490. dragDeltaRatio: number;
  32491. /**
  32492. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32493. */
  32494. currentDraggingPointerID: number;
  32495. /**
  32496. * If camera controls should be detached during the drag
  32497. */
  32498. detachCameraControls: boolean;
  32499. constructor();
  32500. /**
  32501. * The name of the behavior
  32502. */
  32503. readonly name: string;
  32504. /**
  32505. * Initializes the behavior
  32506. */
  32507. init(): void;
  32508. /**
  32509. * Attaches the scale behavior the passed in mesh
  32510. * @param ownerNode The mesh that will be scaled around once attached
  32511. */
  32512. attach(ownerNode: Mesh): void;
  32513. /**
  32514. * Detaches the behavior from the mesh
  32515. */
  32516. detach(): void;
  32517. }
  32518. }
  32519. declare module BABYLON {
  32520. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  32521. camera: ArcRotateCamera;
  32522. gamepad: Nullable<Gamepad>;
  32523. private _onGamepadConnectedObserver;
  32524. private _onGamepadDisconnectedObserver;
  32525. gamepadRotationSensibility: number;
  32526. gamepadMoveSensibility: number;
  32527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32528. detachControl(element: Nullable<HTMLElement>): void;
  32529. checkInputs(): void;
  32530. getClassName(): string;
  32531. getSimpleName(): string;
  32532. }
  32533. }
  32534. declare module BABYLON {
  32535. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  32536. camera: ArcRotateCamera;
  32537. private _keys;
  32538. keysUp: number[];
  32539. keysDown: number[];
  32540. keysLeft: number[];
  32541. keysRight: number[];
  32542. keysReset: number[];
  32543. panningSensibility: number;
  32544. zoomingSensibility: number;
  32545. useAltToZoom: boolean;
  32546. private _ctrlPressed;
  32547. private _altPressed;
  32548. private _onCanvasBlurObserver;
  32549. private _onKeyboardObserver;
  32550. private _engine;
  32551. private _scene;
  32552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32553. detachControl(element: Nullable<HTMLElement>): void;
  32554. checkInputs(): void;
  32555. getClassName(): string;
  32556. getSimpleName(): string;
  32557. }
  32558. }
  32559. declare module BABYLON {
  32560. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  32561. camera: ArcRotateCamera;
  32562. private _wheel;
  32563. private _observer;
  32564. wheelPrecision: number;
  32565. /**
  32566. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  32567. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  32568. */
  32569. wheelDeltaPercentage: number;
  32570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32571. detachControl(element: Nullable<HTMLElement>): void;
  32572. getClassName(): string;
  32573. getSimpleName(): string;
  32574. }
  32575. }
  32576. declare module BABYLON {
  32577. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  32578. camera: ArcRotateCamera;
  32579. buttons: number[];
  32580. angularSensibilityX: number;
  32581. angularSensibilityY: number;
  32582. pinchPrecision: number;
  32583. /**
  32584. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  32585. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  32586. */
  32587. pinchDeltaPercentage: number;
  32588. panningSensibility: number;
  32589. multiTouchPanning: boolean;
  32590. multiTouchPanAndZoom: boolean;
  32591. private _isPanClick;
  32592. pinchInwards: boolean;
  32593. private _pointerInput;
  32594. private _observer;
  32595. private _onMouseMove;
  32596. private _onGestureStart;
  32597. private _onGesture;
  32598. private _MSGestureHandler;
  32599. private _onLostFocus;
  32600. private _onContextMenu;
  32601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32602. detachControl(element: Nullable<HTMLElement>): void;
  32603. getClassName(): string;
  32604. getSimpleName(): string;
  32605. }
  32606. }
  32607. declare module BABYLON {
  32608. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32609. camera: ArcRotateCamera;
  32610. alphaCorrection: number;
  32611. betaCorrection: number;
  32612. gammaCorrection: number;
  32613. private _alpha;
  32614. private _gamma;
  32615. private _dirty;
  32616. private _deviceOrientationHandler;
  32617. constructor();
  32618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32619. /** @hidden */
  32620. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  32621. checkInputs(): void;
  32622. detachControl(element: Nullable<HTMLElement>): void;
  32623. getClassName(): string;
  32624. getSimpleName(): string;
  32625. }
  32626. }
  32627. declare module BABYLON {
  32628. /**
  32629. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32630. * Screen rotation is taken into account.
  32631. */
  32632. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32633. private _camera;
  32634. private _screenOrientationAngle;
  32635. private _constantTranform;
  32636. private _screenQuaternion;
  32637. private _alpha;
  32638. private _beta;
  32639. private _gamma;
  32640. constructor();
  32641. camera: FreeCamera;
  32642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32643. private _orientationChanged;
  32644. private _deviceOrientation;
  32645. detachControl(element: Nullable<HTMLElement>): void;
  32646. checkInputs(): void;
  32647. getClassName(): string;
  32648. getSimpleName(): string;
  32649. }
  32650. }
  32651. declare module BABYLON {
  32652. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32653. camera: FreeCamera;
  32654. gamepad: Nullable<Gamepad>;
  32655. private _onGamepadConnectedObserver;
  32656. private _onGamepadDisconnectedObserver;
  32657. gamepadAngularSensibility: number;
  32658. gamepadMoveSensibility: number;
  32659. private _cameraTransform;
  32660. private _deltaTransform;
  32661. private _vector3;
  32662. private _vector2;
  32663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32664. detachControl(element: Nullable<HTMLElement>): void;
  32665. checkInputs(): void;
  32666. getClassName(): string;
  32667. getSimpleName(): string;
  32668. }
  32669. }
  32670. declare module BABYLON {
  32671. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  32672. camera: FreeCamera;
  32673. private _keys;
  32674. private _onCanvasBlurObserver;
  32675. private _onKeyboardObserver;
  32676. private _engine;
  32677. private _scene;
  32678. keysUp: number[];
  32679. keysDown: number[];
  32680. keysLeft: number[];
  32681. keysRight: number[];
  32682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32683. detachControl(element: Nullable<HTMLElement>): void;
  32684. checkInputs(): void;
  32685. getClassName(): string;
  32686. /** @hidden */
  32687. _onLostFocus(e: FocusEvent): void;
  32688. getSimpleName(): string;
  32689. }
  32690. }
  32691. declare module BABYLON {
  32692. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  32693. touchEnabled: boolean;
  32694. camera: FreeCamera;
  32695. buttons: number[];
  32696. angularSensibility: number;
  32697. private _pointerInput;
  32698. private _onMouseMove;
  32699. private _observer;
  32700. private previousPosition;
  32701. constructor(touchEnabled?: boolean);
  32702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32703. detachControl(element: Nullable<HTMLElement>): void;
  32704. getClassName(): string;
  32705. getSimpleName(): string;
  32706. }
  32707. }
  32708. declare module BABYLON {
  32709. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  32710. camera: FreeCamera;
  32711. private _offsetX;
  32712. private _offsetY;
  32713. private _pointerPressed;
  32714. private _pointerInput;
  32715. private _observer;
  32716. private _onLostFocus;
  32717. touchAngularSensibility: number;
  32718. touchMoveSensibility: number;
  32719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32720. detachControl(element: Nullable<HTMLElement>): void;
  32721. checkInputs(): void;
  32722. getClassName(): string;
  32723. getSimpleName(): string;
  32724. }
  32725. }
  32726. declare module BABYLON {
  32727. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  32728. camera: FreeCamera;
  32729. private _leftjoystick;
  32730. private _rightjoystick;
  32731. getLeftJoystick(): VirtualJoystick;
  32732. getRightJoystick(): VirtualJoystick;
  32733. checkInputs(): void;
  32734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32735. detachControl(element: Nullable<HTMLElement>): void;
  32736. getClassName(): string;
  32737. getSimpleName(): string;
  32738. }
  32739. }
  32740. declare module BABYLON {
  32741. /**
  32742. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  32743. */
  32744. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  32745. /**
  32746. * Creates a new AnaglyphArcRotateCamera
  32747. * @param name defines camera name
  32748. * @param alpha defines alpha angle (in radians)
  32749. * @param beta defines beta angle (in radians)
  32750. * @param radius defines radius
  32751. * @param target defines camera target
  32752. * @param interaxialDistance defines distance between each color axis
  32753. * @param scene defines the hosting scene
  32754. */
  32755. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  32756. /**
  32757. * Gets camera class name
  32758. * @returns AnaglyphArcRotateCamera
  32759. */
  32760. getClassName(): string;
  32761. }
  32762. }
  32763. declare module BABYLON {
  32764. /**
  32765. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  32766. */
  32767. class AnaglyphFreeCamera extends FreeCamera {
  32768. /**
  32769. * Creates a new AnaglyphFreeCamera
  32770. * @param name defines camera name
  32771. * @param position defines initial position
  32772. * @param interaxialDistance defines distance between each color axis
  32773. * @param scene defines the hosting scene
  32774. */
  32775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32776. /**
  32777. * Gets camera class name
  32778. * @returns AnaglyphFreeCamera
  32779. */
  32780. getClassName(): string;
  32781. }
  32782. }
  32783. declare module BABYLON {
  32784. /**
  32785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  32786. */
  32787. class AnaglyphGamepadCamera extends GamepadCamera {
  32788. /**
  32789. * Creates a new AnaglyphGamepadCamera
  32790. * @param name defines camera name
  32791. * @param position defines initial position
  32792. * @param interaxialDistance defines distance between each color axis
  32793. * @param scene defines the hosting scene
  32794. */
  32795. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32796. /**
  32797. * Gets camera class name
  32798. * @returns AnaglyphGamepadCamera
  32799. */
  32800. getClassName(): string;
  32801. }
  32802. }
  32803. declare module BABYLON {
  32804. /**
  32805. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  32806. */
  32807. class AnaglyphUniversalCamera extends UniversalCamera {
  32808. /**
  32809. * Creates a new AnaglyphUniversalCamera
  32810. * @param name defines camera name
  32811. * @param position defines initial position
  32812. * @param interaxialDistance defines distance between each color axis
  32813. * @param scene defines the hosting scene
  32814. */
  32815. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32816. /**
  32817. * Gets camera class name
  32818. * @returns AnaglyphUniversalCamera
  32819. */
  32820. getClassName(): string;
  32821. }
  32822. }
  32823. declare module BABYLON {
  32824. /**
  32825. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32826. */
  32827. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32828. /**
  32829. * Creates a new StereoscopicArcRotateCamera
  32830. * @param name defines camera name
  32831. * @param alpha defines alpha angle (in radians)
  32832. * @param beta defines beta angle (in radians)
  32833. * @param radius defines radius
  32834. * @param target defines camera target
  32835. * @param interaxialDistance defines distance between each color axis
  32836. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32837. * @param scene defines the hosting scene
  32838. */
  32839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32840. /**
  32841. * Gets camera class name
  32842. * @returns StereoscopicArcRotateCamera
  32843. */
  32844. getClassName(): string;
  32845. }
  32846. }
  32847. declare module BABYLON {
  32848. /**
  32849. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  32850. */
  32851. class StereoscopicFreeCamera extends FreeCamera {
  32852. /**
  32853. * Creates a new StereoscopicFreeCamera
  32854. * @param name defines camera name
  32855. * @param position defines initial position
  32856. * @param interaxialDistance defines distance between each color axis
  32857. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32858. * @param scene defines the hosting scene
  32859. */
  32860. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32861. /**
  32862. * Gets camera class name
  32863. * @returns StereoscopicFreeCamera
  32864. */
  32865. getClassName(): string;
  32866. }
  32867. }
  32868. declare module BABYLON {
  32869. /**
  32870. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  32871. */
  32872. class StereoscopicGamepadCamera extends GamepadCamera {
  32873. /**
  32874. * Creates a new StereoscopicGamepadCamera
  32875. * @param name defines camera name
  32876. * @param position defines initial position
  32877. * @param interaxialDistance defines distance between each color axis
  32878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32879. * @param scene defines the hosting scene
  32880. */
  32881. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32882. /**
  32883. * Gets camera class name
  32884. * @returns StereoscopicGamepadCamera
  32885. */
  32886. getClassName(): string;
  32887. }
  32888. }
  32889. declare module BABYLON {
  32890. /**
  32891. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  32892. */
  32893. class StereoscopicUniversalCamera extends UniversalCamera {
  32894. /**
  32895. * Creates a new StereoscopicUniversalCamera
  32896. * @param name defines camera name
  32897. * @param position defines initial position
  32898. * @param interaxialDistance defines distance between each color axis
  32899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32900. * @param scene defines the hosting scene
  32901. */
  32902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32903. /**
  32904. * Gets camera class name
  32905. * @returns StereoscopicUniversalCamera
  32906. */
  32907. getClassName(): string;
  32908. }
  32909. }
  32910. declare module BABYLON {
  32911. class VRCameraMetrics {
  32912. hResolution: number;
  32913. vResolution: number;
  32914. hScreenSize: number;
  32915. vScreenSize: number;
  32916. vScreenCenter: number;
  32917. eyeToScreenDistance: number;
  32918. lensSeparationDistance: number;
  32919. interpupillaryDistance: number;
  32920. distortionK: number[];
  32921. chromaAbCorrection: number[];
  32922. postProcessScaleFactor: number;
  32923. lensCenterOffset: number;
  32924. compensateDistortion: boolean;
  32925. readonly aspectRatio: number;
  32926. readonly aspectRatioFov: number;
  32927. readonly leftHMatrix: Matrix;
  32928. readonly rightHMatrix: Matrix;
  32929. readonly leftPreViewMatrix: Matrix;
  32930. readonly rightPreViewMatrix: Matrix;
  32931. static GetDefault(): VRCameraMetrics;
  32932. }
  32933. }
  32934. declare module BABYLON {
  32935. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  32936. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32937. getClassName(): string;
  32938. }
  32939. }
  32940. declare module BABYLON {
  32941. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  32942. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32943. getClassName(): string;
  32944. }
  32945. }
  32946. declare module BABYLON {
  32947. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  32948. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32949. getClassName(): string;
  32950. }
  32951. }
  32952. declare module BABYLON {
  32953. /**
  32954. * Options to modify the vr teleportation behavior.
  32955. */
  32956. interface VRTeleportationOptions {
  32957. /**
  32958. * The name of the mesh which should be used as the teleportation floor. (default: null)
  32959. */
  32960. floorMeshName?: string;
  32961. /**
  32962. * A list of meshes to be used as the teleportation floor. (default: empty)
  32963. */
  32964. floorMeshes?: Mesh[];
  32965. }
  32966. /**
  32967. * Options to modify the vr experience helper's behavior.
  32968. */
  32969. interface VRExperienceHelperOptions extends WebVROptions {
  32970. /**
  32971. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  32972. */
  32973. createDeviceOrientationCamera?: boolean;
  32974. /**
  32975. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  32976. */
  32977. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  32978. /**
  32979. * Uses the main button on the controller to toggle the laser casted. (default: true)
  32980. */
  32981. laserToggle?: boolean;
  32982. /**
  32983. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  32984. */
  32985. floorMeshes?: Mesh[];
  32986. }
  32987. /**
  32988. * Helps to quickly add VR support to an existing scene.
  32989. * See http://doc.babylonjs.com/how_to/webvr_helper
  32990. */
  32991. class VRExperienceHelper {
  32992. /** Options to modify the vr experience helper's behavior. */
  32993. webVROptions: VRExperienceHelperOptions;
  32994. private _scene;
  32995. private _position;
  32996. private _btnVR;
  32997. private _btnVRDisplayed;
  32998. private _webVRsupported;
  32999. private _webVRready;
  33000. private _webVRrequesting;
  33001. private _webVRpresenting;
  33002. private _hasEnteredVR;
  33003. private _fullscreenVRpresenting;
  33004. private _canvas;
  33005. private _webVRCamera;
  33006. private _vrDeviceOrientationCamera;
  33007. private _deviceOrientationCamera;
  33008. private _existingCamera;
  33009. private _onKeyDown;
  33010. private _onVrDisplayPresentChange;
  33011. private _onVRDisplayChanged;
  33012. private _onVRRequestPresentStart;
  33013. private _onVRRequestPresentComplete;
  33014. /**
  33015. * Observable raised when entering VR.
  33016. */
  33017. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33018. /**
  33019. * Observable raised when exiting VR.
  33020. */
  33021. onExitingVRObservable: Observable<VRExperienceHelper>;
  33022. /**
  33023. * Observable raised when controller mesh is loaded.
  33024. */
  33025. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33026. /** Return this.onEnteringVRObservable
  33027. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33028. */
  33029. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33030. /** Return this.onExitingVRObservable
  33031. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33032. */
  33033. readonly onExitingVR: Observable<VRExperienceHelper>;
  33034. /** Return this.onControllerMeshLoadedObservable
  33035. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33036. */
  33037. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33038. private _rayLength;
  33039. private _useCustomVRButton;
  33040. private _teleportationRequested;
  33041. private _teleportActive;
  33042. private _floorMeshName;
  33043. private _floorMeshesCollection;
  33044. private _rotationAllowed;
  33045. private _teleportBackwardsVector;
  33046. private _teleportationTarget;
  33047. private _isDefaultTeleportationTarget;
  33048. private _postProcessMove;
  33049. private _teleportationFillColor;
  33050. private _teleportationBorderColor;
  33051. private _rotationAngle;
  33052. private _haloCenter;
  33053. private _cameraGazer;
  33054. private _padSensibilityUp;
  33055. private _padSensibilityDown;
  33056. private _leftController;
  33057. private _rightController;
  33058. /**
  33059. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  33060. */
  33061. onNewMeshSelected: Observable<AbstractMesh>;
  33062. /**
  33063. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  33064. */
  33065. onNewMeshPicked: Observable<PickingInfo>;
  33066. private _circleEase;
  33067. /**
  33068. * Observable raised before camera teleportation
  33069. */
  33070. onBeforeCameraTeleport: Observable<Vector3>;
  33071. /**
  33072. * Observable raised after camera teleportation
  33073. */
  33074. onAfterCameraTeleport: Observable<Vector3>;
  33075. /**
  33076. * Observable raised when current selected mesh gets unselected
  33077. */
  33078. onSelectedMeshUnselected: Observable<AbstractMesh>;
  33079. private _raySelectionPredicate;
  33080. /**
  33081. * To be optionaly changed by user to define custom ray selection
  33082. */
  33083. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  33084. /**
  33085. * To be optionaly changed by user to define custom selection logic (after ray selection)
  33086. */
  33087. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  33088. /**
  33089. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  33090. */
  33091. teleportationEnabled: boolean;
  33092. private _defaultHeight;
  33093. private _teleportationInitialized;
  33094. private _interactionsEnabled;
  33095. private _interactionsRequested;
  33096. private _displayGaze;
  33097. private _displayLaserPointer;
  33098. /**
  33099. * The mesh used to display where the user is going to teleport.
  33100. */
  33101. /**
  33102. * Sets the mesh to be used to display where the user is going to teleport.
  33103. */
  33104. teleportationTarget: Mesh;
  33105. /**
  33106. * The mesh used to display where the user is selecting,
  33107. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  33108. * See http://doc.babylonjs.com/resources/baking_transformations
  33109. */
  33110. gazeTrackerMesh: Mesh;
  33111. /**
  33112. * If the ray of the gaze should be displayed.
  33113. */
  33114. /**
  33115. * Sets if the ray of the gaze should be displayed.
  33116. */
  33117. displayGaze: boolean;
  33118. /**
  33119. * If the ray of the LaserPointer should be displayed.
  33120. */
  33121. /**
  33122. * Sets if the ray of the LaserPointer should be displayed.
  33123. */
  33124. displayLaserPointer: boolean;
  33125. /**
  33126. * The deviceOrientationCamera used as the camera when not in VR.
  33127. */
  33128. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  33129. /**
  33130. * Based on the current WebVR support, returns the current VR camera used.
  33131. */
  33132. readonly currentVRCamera: Nullable<Camera>;
  33133. /**
  33134. * The webVRCamera which is used when in VR.
  33135. */
  33136. readonly webVRCamera: WebVRFreeCamera;
  33137. /**
  33138. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  33139. */
  33140. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  33141. private readonly _teleportationRequestInitiated;
  33142. /**
  33143. * Instantiates a VRExperienceHelper.
  33144. * Helps to quickly add VR support to an existing scene.
  33145. * @param scene The scene the VRExperienceHelper belongs to.
  33146. * @param webVROptions Options to modify the vr experience helper's behavior.
  33147. */
  33148. constructor(scene: Scene,
  33149. /** Options to modify the vr experience helper's behavior. */
  33150. webVROptions?: VRExperienceHelperOptions);
  33151. private _onDefaultMeshLoaded;
  33152. private _onResize;
  33153. private _onFullscreenChange;
  33154. /**
  33155. * Gets a value indicating if we are currently in VR mode.
  33156. */
  33157. readonly isInVRMode: boolean;
  33158. private onVrDisplayPresentChange;
  33159. private onVRDisplayChanged;
  33160. private moveButtonToBottomRight;
  33161. private displayVRButton;
  33162. private updateButtonVisibility;
  33163. /**
  33164. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  33165. * Otherwise, will use the fullscreen API.
  33166. */
  33167. enterVR(): void;
  33168. /**
  33169. * Attempt to exit VR, or fullscreen.
  33170. */
  33171. exitVR(): void;
  33172. /**
  33173. * The position of the vr experience helper.
  33174. */
  33175. /**
  33176. * Sets the position of the vr experience helper.
  33177. */
  33178. position: Vector3;
  33179. /**
  33180. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  33181. */
  33182. enableInteractions(): void;
  33183. private readonly _noControllerIsActive;
  33184. private beforeRender;
  33185. private _isTeleportationFloor;
  33186. /**
  33187. * Adds a floor mesh to be used for teleportation.
  33188. * @param floorMesh the mesh to be used for teleportation.
  33189. */
  33190. addFloorMesh(floorMesh: Mesh): void;
  33191. /**
  33192. * Removes a floor mesh from being used for teleportation.
  33193. * @param floorMesh the mesh to be removed.
  33194. */
  33195. removeFloorMesh(floorMesh: Mesh): void;
  33196. /**
  33197. * Enables interactions and teleportation using the VR controllers and gaze.
  33198. * @param vrTeleportationOptions options to modify teleportation behavior.
  33199. */
  33200. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  33201. private _onNewGamepadConnected;
  33202. private _tryEnableInteractionOnController;
  33203. private _onNewGamepadDisconnected;
  33204. private _enableInteractionOnController;
  33205. private _checkTeleportWithRay;
  33206. private _checkRotate;
  33207. private _checkTeleportBackwards;
  33208. private _enableTeleportationOnController;
  33209. private _createTeleportationCircles;
  33210. private _displayTeleportationTarget;
  33211. private _hideTeleportationTarget;
  33212. private _rotateCamera;
  33213. private _moveTeleportationSelectorTo;
  33214. private _workingVector;
  33215. private _workingQuaternion;
  33216. private _workingMatrix;
  33217. private _teleportCamera;
  33218. private _convertNormalToDirectionOfRay;
  33219. private _castRayAndSelectObject;
  33220. private _notifySelectedMeshUnselected;
  33221. /**
  33222. * Sets the color of the laser ray from the vr controllers.
  33223. * @param color new color for the ray.
  33224. */
  33225. changeLaserColor(color: Color3): void;
  33226. /**
  33227. * Sets the color of the ray from the vr headsets gaze.
  33228. * @param color new color for the ray.
  33229. */
  33230. changeGazeColor(color: Color3): void;
  33231. /**
  33232. * Exits VR and disposes of the vr experience helper
  33233. */
  33234. dispose(): void;
  33235. /**
  33236. * Gets the name of the VRExperienceHelper class
  33237. * @returns "VRExperienceHelper"
  33238. */
  33239. getClassName(): string;
  33240. }
  33241. }
  33242. declare module BABYLON {
  33243. /**
  33244. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  33245. * IMPORTANT!! The data is right-hand data.
  33246. * @export
  33247. * @interface DevicePose
  33248. */
  33249. interface DevicePose {
  33250. /**
  33251. * The position of the device, values in array are [x,y,z].
  33252. */
  33253. readonly position: Nullable<Float32Array>;
  33254. /**
  33255. * The linearVelocity of the device, values in array are [x,y,z].
  33256. */
  33257. readonly linearVelocity: Nullable<Float32Array>;
  33258. /**
  33259. * The linearAcceleration of the device, values in array are [x,y,z].
  33260. */
  33261. readonly linearAcceleration: Nullable<Float32Array>;
  33262. /**
  33263. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  33264. */
  33265. readonly orientation: Nullable<Float32Array>;
  33266. /**
  33267. * The angularVelocity of the device, values in array are [x,y,z].
  33268. */
  33269. readonly angularVelocity: Nullable<Float32Array>;
  33270. /**
  33271. * The angularAcceleration of the device, values in array are [x,y,z].
  33272. */
  33273. readonly angularAcceleration: Nullable<Float32Array>;
  33274. }
  33275. /**
  33276. * Interface representing a pose controlled object in Babylon.
  33277. * A pose controlled object has both regular pose values as well as pose values
  33278. * from an external device such as a VR head mounted display
  33279. */
  33280. interface PoseControlled {
  33281. /**
  33282. * The position of the object in babylon space.
  33283. */
  33284. position: Vector3;
  33285. /**
  33286. * The rotation quaternion of the object in babylon space.
  33287. */
  33288. rotationQuaternion: Quaternion;
  33289. /**
  33290. * The position of the device in babylon space.
  33291. */
  33292. devicePosition?: Vector3;
  33293. /**
  33294. * The rotation quaternion of the device in babylon space.
  33295. */
  33296. deviceRotationQuaternion: Quaternion;
  33297. /**
  33298. * The raw pose coming from the device.
  33299. */
  33300. rawPose: Nullable<DevicePose>;
  33301. /**
  33302. * The scale of the device to be used when translating from device space to babylon space.
  33303. */
  33304. deviceScaleFactor: number;
  33305. /**
  33306. * Updates the poseControlled values based on the input device pose.
  33307. * @param poseData the pose data to update the object with
  33308. */
  33309. updateFromDevice(poseData: DevicePose): void;
  33310. }
  33311. /**
  33312. * Set of options to customize the webVRCamera
  33313. */
  33314. interface WebVROptions {
  33315. /**
  33316. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  33317. */
  33318. trackPosition?: boolean;
  33319. /**
  33320. * Sets the scale of the vrDevice in babylon space. (default: 1)
  33321. */
  33322. positionScale?: number;
  33323. /**
  33324. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  33325. */
  33326. displayName?: string;
  33327. /**
  33328. * Should the native controller meshes be initialized. (default: true)
  33329. */
  33330. controllerMeshes?: boolean;
  33331. /**
  33332. * Creating a default HemiLight only on controllers. (default: true)
  33333. */
  33334. defaultLightingOnControllers?: boolean;
  33335. /**
  33336. * If you don't want to use the default VR button of the helper. (default: false)
  33337. */
  33338. useCustomVRButton?: boolean;
  33339. /**
  33340. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  33341. */
  33342. customVRButton?: HTMLButtonElement;
  33343. /**
  33344. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  33345. */
  33346. rayLength?: number;
  33347. /**
  33348. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  33349. */
  33350. defaultHeight?: number;
  33351. }
  33352. /**
  33353. * This represents a WebVR camera.
  33354. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  33355. * @example http://doc.babylonjs.com/how_to/webvr_camera
  33356. */
  33357. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  33358. private webVROptions;
  33359. /**
  33360. * @hidden
  33361. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  33362. */
  33363. _vrDevice: any;
  33364. /**
  33365. * The rawPose of the vrDevice.
  33366. */
  33367. rawPose: Nullable<DevicePose>;
  33368. private _onVREnabled;
  33369. private _specsVersion;
  33370. private _attached;
  33371. private _frameData;
  33372. protected _descendants: Array<Node>;
  33373. private _deviceRoomPosition;
  33374. /** @hidden */
  33375. _deviceRoomRotationQuaternion: Quaternion;
  33376. private _standingMatrix;
  33377. /**
  33378. * Represents device position in babylon space.
  33379. */
  33380. devicePosition: Vector3;
  33381. /**
  33382. * Represents device rotation in babylon space.
  33383. */
  33384. deviceRotationQuaternion: Quaternion;
  33385. /**
  33386. * The scale of the device to be used when translating from device space to babylon space.
  33387. */
  33388. deviceScaleFactor: number;
  33389. private _deviceToWorld;
  33390. private _worldToDevice;
  33391. /**
  33392. * References to the webVR controllers for the vrDevice.
  33393. */
  33394. controllers: Array<WebVRController>;
  33395. /**
  33396. * Emits an event when a controller is attached.
  33397. */
  33398. onControllersAttachedObservable: Observable<WebVRController[]>;
  33399. /**
  33400. * Emits an event when a controller's mesh has been loaded;
  33401. */
  33402. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33403. /**
  33404. * Emits an event when the HMD's pose has been updated.
  33405. */
  33406. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33407. private _poseSet;
  33408. /**
  33409. * If the rig cameras be used as parent instead of this camera.
  33410. */
  33411. rigParenting: boolean;
  33412. private _lightOnControllers;
  33413. private _defaultHeight?;
  33414. /**
  33415. * Instantiates a WebVRFreeCamera.
  33416. * @param name The name of the WebVRFreeCamera
  33417. * @param position The starting anchor position for the camera
  33418. * @param scene The scene the camera belongs to
  33419. * @param webVROptions a set of customizable options for the webVRCamera
  33420. */
  33421. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33422. /**
  33423. * Gets the device distance from the ground in meters.
  33424. * @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.
  33425. */
  33426. deviceDistanceToRoomGround(): number;
  33427. /**
  33428. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33429. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33430. */
  33431. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33432. /**
  33433. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33434. * @returns A promise with a boolean set to if the standing matrix is supported.
  33435. */
  33436. useStandingMatrixAsync(): Promise<boolean>;
  33437. /**
  33438. * Disposes the camera
  33439. */
  33440. dispose(): void;
  33441. /**
  33442. * Gets a vrController by name.
  33443. * @param name The name of the controller to retreive
  33444. * @returns the controller matching the name specified or null if not found
  33445. */
  33446. getControllerByName(name: string): Nullable<WebVRController>;
  33447. private _leftController;
  33448. /**
  33449. * The controller corrisponding to the users left hand.
  33450. */
  33451. readonly leftController: Nullable<WebVRController>;
  33452. private _rightController;
  33453. /**
  33454. * The controller corrisponding to the users right hand.
  33455. */
  33456. readonly rightController: Nullable<WebVRController>;
  33457. /**
  33458. * Casts a ray forward from the vrCamera's gaze.
  33459. * @param length Length of the ray (default: 100)
  33460. * @returns the ray corrisponding to the gaze
  33461. */
  33462. getForwardRay(length?: number): Ray;
  33463. /**
  33464. * @hidden
  33465. * Updates the camera based on device's frame data
  33466. */
  33467. _checkInputs(): void;
  33468. /**
  33469. * Updates the poseControlled values based on the input device pose.
  33470. * @param poseData Pose coming from the device
  33471. */
  33472. updateFromDevice(poseData: DevicePose): void;
  33473. private _htmlElementAttached;
  33474. private _detachIfAttached;
  33475. /**
  33476. * WebVR's attach control will start broadcasting frames to the device.
  33477. * Note that in certain browsers (chrome for example) this function must be called
  33478. * within a user-interaction callback. Example:
  33479. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  33480. *
  33481. * @param element html element to attach the vrDevice to
  33482. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  33483. */
  33484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33485. /**
  33486. * Detaches the camera from the html element and disables VR
  33487. *
  33488. * @param element html element to detach from
  33489. */
  33490. detachControl(element: HTMLElement): void;
  33491. /**
  33492. * @returns the name of this class
  33493. */
  33494. getClassName(): string;
  33495. /**
  33496. * Calls resetPose on the vrDisplay
  33497. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  33498. */
  33499. resetToCurrentRotation(): void;
  33500. /**
  33501. * @hidden
  33502. * Updates the rig cameras (left and right eye)
  33503. */
  33504. _updateRigCameras(): void;
  33505. private _workingVector;
  33506. private _oneVector;
  33507. private _workingMatrix;
  33508. private updateCacheCalled;
  33509. /**
  33510. * @hidden
  33511. * Updates the cached values of the camera
  33512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  33513. */
  33514. _updateCache(ignoreParentClass?: boolean): void;
  33515. /**
  33516. * Updates the current device position and rotation in the babylon world
  33517. */
  33518. update(): void;
  33519. /**
  33520. * @hidden
  33521. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  33522. * @returns an identity matrix
  33523. */
  33524. _getViewMatrix(): Matrix;
  33525. /**
  33526. * This function is called by the two RIG cameras.
  33527. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  33528. */
  33529. protected _getWebVRViewMatrix(): Matrix;
  33530. protected _getWebVRProjectionMatrix(): Matrix;
  33531. private _onGamepadConnectedObserver;
  33532. private _onGamepadDisconnectedObserver;
  33533. /**
  33534. * Initializes the controllers and their meshes
  33535. */
  33536. initControllers(): void;
  33537. }
  33538. }
  33539. declare module BABYLON {
  33540. interface IOctreeContainer<T> {
  33541. blocks: Array<OctreeBlock<T>>;
  33542. }
  33543. class Octree<T> {
  33544. maxDepth: number;
  33545. blocks: Array<OctreeBlock<T>>;
  33546. dynamicContent: T[];
  33547. private _maxBlockCapacity;
  33548. private _selectionContent;
  33549. private _creationFunc;
  33550. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33551. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33552. addMesh(entry: T): void;
  33553. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33554. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33555. intersectsRay(ray: Ray): SmartArray<T>;
  33556. 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;
  33557. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33558. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33559. }
  33560. }
  33561. declare module BABYLON {
  33562. class OctreeBlock<T> {
  33563. entries: T[];
  33564. blocks: Array<OctreeBlock<T>>;
  33565. private _depth;
  33566. private _maxDepth;
  33567. private _capacity;
  33568. private _minPoint;
  33569. private _maxPoint;
  33570. private _boundingVectors;
  33571. private _creationFunc;
  33572. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33573. readonly capacity: number;
  33574. readonly minPoint: Vector3;
  33575. readonly maxPoint: Vector3;
  33576. addEntry(entry: T): void;
  33577. addEntries(entries: T[]): void;
  33578. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33579. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33580. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33581. createInnerBlocks(): void;
  33582. }
  33583. }
  33584. declare module BABYLON {
  33585. interface Engine {
  33586. /**
  33587. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  33588. * @return the new query
  33589. */
  33590. createQuery(): WebGLQuery;
  33591. /**
  33592. * Delete and release a webGL query
  33593. * @param query defines the query to delete
  33594. * @return the current engine
  33595. */
  33596. deleteQuery(query: WebGLQuery): Engine;
  33597. /**
  33598. * Check if a given query has resolved and got its value
  33599. * @param query defines the query to check
  33600. * @returns true if the query got its value
  33601. */
  33602. isQueryResultAvailable(query: WebGLQuery): boolean;
  33603. /**
  33604. * Gets the value of a given query
  33605. * @param query defines the query to check
  33606. * @returns the value of the query
  33607. */
  33608. getQueryResult(query: WebGLQuery): number;
  33609. /**
  33610. * Initiates an occlusion query
  33611. * @param algorithmType defines the algorithm to use
  33612. * @param query defines the query to use
  33613. * @returns the current engine
  33614. * @see http://doc.babylonjs.com/features/occlusionquery
  33615. */
  33616. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33617. /**
  33618. * Ends an occlusion query
  33619. * @see http://doc.babylonjs.com/features/occlusionquery
  33620. * @param algorithmType defines the algorithm to use
  33621. * @returns the current engine
  33622. */
  33623. endOcclusionQuery(algorithmType: number): Engine;
  33624. /**
  33625. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33626. * Please note that only one query can be issued at a time
  33627. * @returns a time token used to track the time span
  33628. */
  33629. startTimeQuery(): Nullable<_TimeToken>;
  33630. /**
  33631. * Ends a time query
  33632. * @param token defines the token used to measure the time span
  33633. * @returns the time spent (in ns)
  33634. */
  33635. endTimeQuery(token: _TimeToken): int;
  33636. /** @hidden */
  33637. _currentNonTimestampToken: Nullable<_TimeToken>;
  33638. /** @hidden */
  33639. _createTimeQuery(): WebGLQuery;
  33640. /** @hidden */
  33641. _deleteTimeQuery(query: WebGLQuery): void;
  33642. /** @hidden */
  33643. _getGlAlgorithmType(algorithmType: number): number;
  33644. /** @hidden */
  33645. _getTimeQueryResult(query: WebGLQuery): any;
  33646. /** @hidden */
  33647. _getTimeQueryAvailability(query: WebGLQuery): any;
  33648. }
  33649. }
  33650. declare module BABYLON {
  33651. interface Engine {
  33652. /**
  33653. * Creates a webGL transform feedback object
  33654. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  33655. * @returns the webGL transform feedback object
  33656. */
  33657. createTransformFeedback(): WebGLTransformFeedback;
  33658. /**
  33659. * Delete a webGL transform feedback object
  33660. * @param value defines the webGL transform feedback object to delete
  33661. */
  33662. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  33663. /**
  33664. * Bind a webGL transform feedback object to the webgl context
  33665. * @param value defines the webGL transform feedback object to bind
  33666. */
  33667. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  33668. /**
  33669. * Begins a transform feedback operation
  33670. * @param usePoints defines if points or triangles must be used
  33671. */
  33672. beginTransformFeedback(usePoints: boolean): void;
  33673. /**
  33674. * Ends a transform feedback operation
  33675. */
  33676. endTransformFeedback(): void;
  33677. /**
  33678. * Specify the varyings to use with transform feedback
  33679. * @param program defines the associated webGL program
  33680. * @param value defines the list of strings representing the varying names
  33681. */
  33682. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  33683. /**
  33684. * Bind a webGL buffer for a transform feedback operation
  33685. * @param value defines the webGL buffer to bind
  33686. */
  33687. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  33688. }
  33689. }
  33690. declare module BABYLON {
  33691. /**
  33692. * Google Daydream controller
  33693. */
  33694. class DaydreamController extends WebVRController {
  33695. /**
  33696. * Base Url for the controller model.
  33697. */
  33698. static MODEL_BASE_URL: string;
  33699. /**
  33700. * File name for the controller model.
  33701. */
  33702. static MODEL_FILENAME: string;
  33703. /**
  33704. * Gamepad Id prefix used to identify Daydream Controller.
  33705. */
  33706. static readonly GAMEPAD_ID_PREFIX: string;
  33707. /**
  33708. * Creates a new DaydreamController from a gamepad
  33709. * @param vrGamepad the gamepad that the controller should be created from
  33710. */
  33711. constructor(vrGamepad: any);
  33712. /**
  33713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33714. * @param scene scene in which to add meshes
  33715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33716. */
  33717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33718. /**
  33719. * Called once for each button that changed state since the last frame
  33720. * @param buttonIdx Which button index changed
  33721. * @param state New state of the button
  33722. * @param changes Which properties on the state changed since last frame
  33723. */
  33724. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33725. }
  33726. }
  33727. declare module BABYLON {
  33728. /**
  33729. * Gear VR Controller
  33730. */
  33731. class GearVRController extends WebVRController {
  33732. /**
  33733. * Base Url for the controller model.
  33734. */
  33735. static MODEL_BASE_URL: string;
  33736. /**
  33737. * File name for the controller model.
  33738. */
  33739. static MODEL_FILENAME: string;
  33740. private _maxRotationDistFromHeadset;
  33741. private _draggedRoomRotation;
  33742. private _tmpVector;
  33743. /**
  33744. * Gamepad Id prefix used to identify this controller.
  33745. */
  33746. static readonly GAMEPAD_ID_PREFIX: string;
  33747. private readonly _buttonIndexToObservableNameMap;
  33748. /**
  33749. * Creates a new GearVRController from a gamepad
  33750. * @param vrGamepad the gamepad that the controller should be created from
  33751. */
  33752. constructor(vrGamepad: any);
  33753. /**
  33754. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33755. * @param poseData raw pose fromthe device
  33756. */
  33757. updateFromDevice(poseData: DevicePose): void;
  33758. /**
  33759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33760. * @param scene scene in which to add meshes
  33761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33762. */
  33763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33764. /**
  33765. * Called once for each button that changed state since the last frame
  33766. * @param buttonIdx Which button index changed
  33767. * @param state New state of the button
  33768. * @param changes Which properties on the state changed since last frame
  33769. */
  33770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33771. }
  33772. }
  33773. declare module BABYLON {
  33774. /**
  33775. * Generic Controller
  33776. */
  33777. class GenericController extends WebVRController {
  33778. /**
  33779. * Base Url for the controller model.
  33780. */
  33781. static readonly MODEL_BASE_URL: string;
  33782. /**
  33783. * File name for the controller model.
  33784. */
  33785. static readonly MODEL_FILENAME: string;
  33786. /**
  33787. * Creates a new GenericController from a gamepad
  33788. * @param vrGamepad the gamepad that the controller should be created from
  33789. */
  33790. constructor(vrGamepad: any);
  33791. /**
  33792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33793. * @param scene scene in which to add meshes
  33794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33795. */
  33796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33797. /**
  33798. * Called once for each button that changed state since the last frame
  33799. * @param buttonIdx Which button index changed
  33800. * @param state New state of the button
  33801. * @param changes Which properties on the state changed since last frame
  33802. */
  33803. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33804. }
  33805. }
  33806. declare module BABYLON {
  33807. /**
  33808. * Oculus Touch Controller
  33809. */
  33810. class OculusTouchController extends WebVRController {
  33811. /**
  33812. * Base Url for the controller model.
  33813. */
  33814. static MODEL_BASE_URL: string;
  33815. /**
  33816. * File name for the left controller model.
  33817. */
  33818. static MODEL_LEFT_FILENAME: string;
  33819. /**
  33820. * File name for the right controller model.
  33821. */
  33822. static MODEL_RIGHT_FILENAME: string;
  33823. /**
  33824. * Fired when the secondary trigger on this controller is modified
  33825. */
  33826. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33827. /**
  33828. * Fired when the thumb rest on this controller is modified
  33829. */
  33830. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  33831. /**
  33832. * Creates a new OculusTouchController from a gamepad
  33833. * @param vrGamepad the gamepad that the controller should be created from
  33834. */
  33835. constructor(vrGamepad: any);
  33836. /**
  33837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33838. * @param scene scene in which to add meshes
  33839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33840. */
  33841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33842. /**
  33843. * Fired when the A button on this controller is modified
  33844. */
  33845. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33846. /**
  33847. * Fired when the B button on this controller is modified
  33848. */
  33849. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33850. /**
  33851. * Fired when the X button on this controller is modified
  33852. */
  33853. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33854. /**
  33855. * Fired when the Y button on this controller is modified
  33856. */
  33857. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33858. /**
  33859. * Called once for each button that changed state since the last frame
  33860. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  33861. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  33862. * 2) secondary trigger (same)
  33863. * 3) A (right) X (left), touch, pressed = value
  33864. * 4) B / Y
  33865. * 5) thumb rest
  33866. * @param buttonIdx Which button index changed
  33867. * @param state New state of the button
  33868. * @param changes Which properties on the state changed since last frame
  33869. */
  33870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33871. }
  33872. }
  33873. declare module BABYLON {
  33874. /**
  33875. * Defines the types of pose enabled controllers that are supported
  33876. */
  33877. enum PoseEnabledControllerType {
  33878. /**
  33879. * HTC Vive
  33880. */
  33881. VIVE = 0,
  33882. /**
  33883. * Oculus Rift
  33884. */
  33885. OCULUS = 1,
  33886. /**
  33887. * Windows mixed reality
  33888. */
  33889. WINDOWS = 2,
  33890. /**
  33891. * Samsung gear VR
  33892. */
  33893. GEAR_VR = 3,
  33894. /**
  33895. * Google Daydream
  33896. */
  33897. DAYDREAM = 4,
  33898. /**
  33899. * Generic
  33900. */
  33901. GENERIC = 5
  33902. }
  33903. /**
  33904. * Defines the MutableGamepadButton interface for the state of a gamepad button
  33905. */
  33906. interface MutableGamepadButton {
  33907. /**
  33908. * Value of the button/trigger
  33909. */
  33910. value: number;
  33911. /**
  33912. * If the button/trigger is currently touched
  33913. */
  33914. touched: boolean;
  33915. /**
  33916. * If the button/trigger is currently pressed
  33917. */
  33918. pressed: boolean;
  33919. }
  33920. /**
  33921. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  33922. * @hidden
  33923. */
  33924. interface ExtendedGamepadButton extends GamepadButton {
  33925. /**
  33926. * If the button/trigger is currently pressed
  33927. */
  33928. readonly pressed: boolean;
  33929. /**
  33930. * If the button/trigger is currently touched
  33931. */
  33932. readonly touched: boolean;
  33933. /**
  33934. * Value of the button/trigger
  33935. */
  33936. readonly value: number;
  33937. }
  33938. /**
  33939. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33940. */
  33941. class PoseEnabledControllerHelper {
  33942. /**
  33943. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33944. * @param vrGamepad the gamepad to initialized
  33945. * @returns a vr controller of the type the gamepad identified as
  33946. */
  33947. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  33948. }
  33949. /**
  33950. * Defines the PoseEnabledController object that contains state of a vr capable controller
  33951. */
  33952. class PoseEnabledController extends Gamepad implements PoseControlled {
  33953. private _deviceRoomPosition;
  33954. private _deviceRoomRotationQuaternion;
  33955. /**
  33956. * The device position in babylon space
  33957. */
  33958. devicePosition: Vector3;
  33959. /**
  33960. * The device rotation in babylon space
  33961. */
  33962. deviceRotationQuaternion: Quaternion;
  33963. /**
  33964. * The scale factor of the device in babylon space
  33965. */
  33966. deviceScaleFactor: number;
  33967. /**
  33968. * (Likely devicePosition should be used instead) The device position in its room space
  33969. */
  33970. position: Vector3;
  33971. /**
  33972. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  33973. */
  33974. rotationQuaternion: Quaternion;
  33975. /**
  33976. * The type of controller (Eg. Windows mixed reality)
  33977. */
  33978. controllerType: PoseEnabledControllerType;
  33979. protected _calculatedPosition: Vector3;
  33980. private _calculatedRotation;
  33981. /**
  33982. * The raw pose from the device
  33983. */
  33984. rawPose: DevicePose;
  33985. /**
  33986. * Internal, the mesh attached to the controller
  33987. * @hidden
  33988. */
  33989. _mesh: Nullable<AbstractMesh>;
  33990. private _poseControlledCamera;
  33991. private _leftHandSystemQuaternion;
  33992. /**
  33993. * Internal, matrix used to convert room space to babylon space
  33994. * @hidden
  33995. */
  33996. _deviceToWorld: Matrix;
  33997. /**
  33998. * Node to be used when casting a ray from the controller
  33999. * @hidden
  34000. */
  34001. _pointingPoseNode: Nullable<AbstractMesh>;
  34002. /**
  34003. * Name of the child mesh that can be used to cast a ray from the controller
  34004. */
  34005. static readonly POINTING_POSE: string;
  34006. /**
  34007. * Creates a new PoseEnabledController from a gamepad
  34008. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34009. */
  34010. constructor(browserGamepad: any);
  34011. private _workingMatrix;
  34012. /**
  34013. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34014. */
  34015. update(): void;
  34016. /**
  34017. * Updates only the pose device and mesh without doing any button event checking
  34018. */
  34019. protected _updatePoseAndMesh(): void;
  34020. /**
  34021. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34022. * @param poseData raw pose fromthe device
  34023. */
  34024. updateFromDevice(poseData: DevicePose): void;
  34025. /**
  34026. * @hidden
  34027. */
  34028. _meshAttachedObservable: Observable<AbstractMesh>;
  34029. /**
  34030. * Attaches a mesh to the controller
  34031. * @param mesh the mesh to be attached
  34032. */
  34033. attachToMesh(mesh: AbstractMesh): void;
  34034. /**
  34035. * Attaches the controllers mesh to a camera
  34036. * @param camera the camera the mesh should be attached to
  34037. */
  34038. attachToPoseControlledCamera(camera: TargetCamera): void;
  34039. /**
  34040. * Disposes of the controller
  34041. */
  34042. dispose(): void;
  34043. /**
  34044. * The mesh that is attached to the controller
  34045. */
  34046. readonly mesh: Nullable<AbstractMesh>;
  34047. /**
  34048. * Gets the ray of the controller in the direction the controller is pointing
  34049. * @param length the length the resulting ray should be
  34050. * @returns a ray in the direction the controller is pointing
  34051. */
  34052. getForwardRay(length?: number): Ray;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * Vive Controller
  34058. */
  34059. class ViveController extends WebVRController {
  34060. /**
  34061. * Base Url for the controller model.
  34062. */
  34063. static MODEL_BASE_URL: string;
  34064. /**
  34065. * File name for the controller model.
  34066. */
  34067. static MODEL_FILENAME: string;
  34068. /**
  34069. * Creates a new ViveController from a gamepad
  34070. * @param vrGamepad the gamepad that the controller should be created from
  34071. */
  34072. constructor(vrGamepad: any);
  34073. /**
  34074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34075. * @param scene scene in which to add meshes
  34076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34077. */
  34078. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34079. /**
  34080. * Fired when the left button on this controller is modified
  34081. */
  34082. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34083. /**
  34084. * Fired when the right button on this controller is modified
  34085. */
  34086. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34087. /**
  34088. * Fired when the menu button on this controller is modified
  34089. */
  34090. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34091. /**
  34092. * Called once for each button that changed state since the last frame
  34093. * Vive mapping:
  34094. * 0: touchpad
  34095. * 1: trigger
  34096. * 2: left AND right buttons
  34097. * 3: menu button
  34098. * @param buttonIdx Which button index changed
  34099. * @param state New state of the button
  34100. * @param changes Which properties on the state changed since last frame
  34101. */
  34102. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34103. }
  34104. }
  34105. declare module BABYLON {
  34106. /**
  34107. * Defines the WebVRController object that represents controllers tracked in 3D space
  34108. */
  34109. abstract class WebVRController extends PoseEnabledController {
  34110. /**
  34111. * Internal, the default controller model for the controller
  34112. */
  34113. protected _defaultModel: AbstractMesh;
  34114. /**
  34115. * Fired when the trigger state has changed
  34116. */
  34117. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34118. /**
  34119. * Fired when the main button state has changed
  34120. */
  34121. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34122. /**
  34123. * Fired when the secondary button state has changed
  34124. */
  34125. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34126. /**
  34127. * Fired when the pad state has changed
  34128. */
  34129. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  34130. /**
  34131. * Fired when controllers stick values have changed
  34132. */
  34133. onPadValuesChangedObservable: Observable<StickValues>;
  34134. /**
  34135. * Array of button availible on the controller
  34136. */
  34137. protected _buttons: Array<MutableGamepadButton>;
  34138. private _onButtonStateChange;
  34139. /**
  34140. * Fired when a controller button's state has changed
  34141. * @param callback the callback containing the button that was modified
  34142. */
  34143. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  34144. /**
  34145. * X and Y axis corrisponding to the controllers joystick
  34146. */
  34147. pad: StickValues;
  34148. /**
  34149. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  34150. */
  34151. hand: string;
  34152. /**
  34153. * The default controller model for the controller
  34154. */
  34155. readonly defaultModel: AbstractMesh;
  34156. /**
  34157. * Creates a new WebVRController from a gamepad
  34158. * @param vrGamepad the gamepad that the WebVRController should be created from
  34159. */
  34160. constructor(vrGamepad: any);
  34161. /**
  34162. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34163. */
  34164. update(): void;
  34165. /**
  34166. * Function to be called when a button is modified
  34167. */
  34168. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34169. /**
  34170. * Loads a mesh and attaches it to the controller
  34171. * @param scene the scene the mesh should be added to
  34172. * @param meshLoaded callback for when the mesh has been loaded
  34173. */
  34174. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34175. private _setButtonValue;
  34176. private _changes;
  34177. private _checkChanges;
  34178. /**
  34179. * Disposes of th webVRCOntroller
  34180. */
  34181. dispose(): void;
  34182. }
  34183. }
  34184. declare module BABYLON {
  34185. /**
  34186. * Defines the WindowsMotionController object that the state of the windows motion controller
  34187. */
  34188. class WindowsMotionController extends WebVRController {
  34189. /**
  34190. * The base url used to load the left and right controller models
  34191. */
  34192. static MODEL_BASE_URL: string;
  34193. /**
  34194. * The name of the left controller model file
  34195. */
  34196. static MODEL_LEFT_FILENAME: string;
  34197. /**
  34198. * The name of the right controller model file
  34199. */
  34200. static MODEL_RIGHT_FILENAME: string;
  34201. /**
  34202. * The controller name prefix for this controller type
  34203. */
  34204. static readonly GAMEPAD_ID_PREFIX: string;
  34205. /**
  34206. * The controller id pattern for this controller type
  34207. */
  34208. private static readonly GAMEPAD_ID_PATTERN;
  34209. private _loadedMeshInfo;
  34210. private readonly _mapping;
  34211. /**
  34212. * Fired when the trackpad on this controller is clicked
  34213. */
  34214. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  34215. /**
  34216. * Fired when the trackpad on this controller is modified
  34217. */
  34218. onTrackpadValuesChangedObservable: Observable<StickValues>;
  34219. /**
  34220. * The current x and y values of this controller's trackpad
  34221. */
  34222. trackpad: StickValues;
  34223. /**
  34224. * Creates a new WindowsMotionController from a gamepad
  34225. * @param vrGamepad the gamepad that the controller should be created from
  34226. */
  34227. constructor(vrGamepad: any);
  34228. /**
  34229. * Fired when the trigger on this controller is modified
  34230. */
  34231. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34232. /**
  34233. * Fired when the menu button on this controller is modified
  34234. */
  34235. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34236. /**
  34237. * Fired when the grip button on this controller is modified
  34238. */
  34239. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34240. /**
  34241. * Fired when the thumbstick button on this controller is modified
  34242. */
  34243. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34244. /**
  34245. * Fired when the touchpad button on this controller is modified
  34246. */
  34247. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34248. /**
  34249. * Fired when the touchpad values on this controller are modified
  34250. */
  34251. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  34252. private _updateTrackpad;
  34253. /**
  34254. * Called once per frame by the engine.
  34255. */
  34256. update(): void;
  34257. /**
  34258. * Called once for each button that changed state since the last frame
  34259. * @param buttonIdx Which button index changed
  34260. * @param state New state of the button
  34261. * @param changes Which properties on the state changed since last frame
  34262. */
  34263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34264. /**
  34265. * Moves the buttons on the controller mesh based on their current state
  34266. * @param buttonName the name of the button to move
  34267. * @param buttonValue the value of the button which determines the buttons new position
  34268. */
  34269. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  34270. /**
  34271. * Moves the axis on the controller mesh based on its current state
  34272. * @param axis the index of the axis
  34273. * @param axisValue the value of the axis which determines the meshes new position
  34274. * @hidden
  34275. */
  34276. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  34277. /**
  34278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34279. * @param scene scene in which to add meshes
  34280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34281. */
  34282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  34283. /**
  34284. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  34285. * can be transformed by button presses and axes values, based on this._mapping.
  34286. *
  34287. * @param scene scene in which the meshes exist
  34288. * @param meshes list of meshes that make up the controller model to process
  34289. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  34290. */
  34291. private processModel;
  34292. private createMeshInfo;
  34293. /**
  34294. * Gets the ray of the controller in the direction the controller is pointing
  34295. * @param length the length the resulting ray should be
  34296. * @returns a ray in the direction the controller is pointing
  34297. */
  34298. getForwardRay(length?: number): Ray;
  34299. /**
  34300. * Disposes of the controller
  34301. */
  34302. dispose(): void;
  34303. }
  34304. }
  34305. declare module BABYLON {
  34306. /**
  34307. * Interface to implement to create a shadow generator compatible with BJS.
  34308. */
  34309. interface IShadowGenerator {
  34310. /**
  34311. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34312. * @returns The render target texture if present otherwise, null
  34313. */
  34314. getShadowMap(): Nullable<RenderTargetTexture>;
  34315. /**
  34316. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34317. * @returns The render target texture if the shadow map is present otherwise, null
  34318. */
  34319. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34320. /**
  34321. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34322. * @param subMesh The submesh we want to render in the shadow map
  34323. * @param useInstances Defines wether will draw in the map using instances
  34324. * @returns true if ready otherwise, false
  34325. */
  34326. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34327. /**
  34328. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34329. * @param defines Defines of the material we want to update
  34330. * @param lightIndex Index of the light in the enabled light list of the material
  34331. */
  34332. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  34333. /**
  34334. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34335. * defined in the generator but impacting the effect).
  34336. * It implies the unifroms available on the materials are the standard BJS ones.
  34337. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34338. * @param effect The effect we are binfing the information for
  34339. */
  34340. bindShadowLight(lightIndex: string, effect: Effect): void;
  34341. /**
  34342. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34343. * (eq to shadow prjection matrix * light transform matrix)
  34344. * @returns The transform matrix used to create the shadow map
  34345. */
  34346. getTransformMatrix(): Matrix;
  34347. /**
  34348. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34349. * Cube and 2D textures for instance.
  34350. */
  34351. recreateShadowMap(): void;
  34352. /**
  34353. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34354. * @param onCompiled Callback triggered at the and of the effects compilation
  34355. * @param options Sets of optional options forcing the compilation with different modes
  34356. */
  34357. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34358. useInstances: boolean;
  34359. }>): void;
  34360. /**
  34361. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34362. * @param options Sets of optional options forcing the compilation with different modes
  34363. * @returns A promise that resolves when the compilation completes
  34364. */
  34365. forceCompilationAsync(options?: Partial<{
  34366. useInstances: boolean;
  34367. }>): Promise<void>;
  34368. /**
  34369. * Serializes the shadow generator setup to a json object.
  34370. * @returns The serialized JSON object
  34371. */
  34372. serialize(): any;
  34373. /**
  34374. * Disposes the Shadow map and related Textures and effects.
  34375. */
  34376. dispose(): void;
  34377. }
  34378. /**
  34379. * Default implementation IShadowGenerator.
  34380. * This is the main object responsible of generating shadows in the framework.
  34381. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  34382. */
  34383. class ShadowGenerator implements IShadowGenerator {
  34384. /**
  34385. * Shadow generator mode None: no filtering applied.
  34386. */
  34387. static readonly FILTER_NONE: number;
  34388. /**
  34389. * Shadow generator mode ESM: Exponential Shadow Mapping.
  34390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34391. */
  34392. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  34393. /**
  34394. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  34395. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  34396. */
  34397. static readonly FILTER_POISSONSAMPLING: number;
  34398. /**
  34399. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  34400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34401. */
  34402. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  34403. /**
  34404. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  34405. * edge artifacts on steep falloff.
  34406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34407. */
  34408. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34409. /**
  34410. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34411. * edge artifacts on steep falloff.
  34412. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34413. */
  34414. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34415. /**
  34416. * Shadow generator mode PCF: Percentage Closer Filtering
  34417. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34418. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34419. */
  34420. static readonly FILTER_PCF: number;
  34421. /**
  34422. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34423. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34424. * Contact Hardening
  34425. */
  34426. static readonly FILTER_PCSS: number;
  34427. /**
  34428. * Reserved for PCF and PCSS
  34429. * Highest Quality.
  34430. *
  34431. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34432. *
  34433. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34434. */
  34435. static readonly QUALITY_HIGH: number;
  34436. /**
  34437. * Reserved for PCF and PCSS
  34438. * Good tradeoff for quality/perf cross devices
  34439. *
  34440. * Execute PCF on a 3*3 kernel.
  34441. *
  34442. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34443. */
  34444. static readonly QUALITY_MEDIUM: number;
  34445. /**
  34446. * Reserved for PCF and PCSS
  34447. * The lowest quality but the fastest.
  34448. *
  34449. * Execute PCF on a 1*1 kernel.
  34450. *
  34451. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34452. */
  34453. static readonly QUALITY_LOW: number;
  34454. private _bias;
  34455. /**
  34456. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34457. */
  34458. /**
  34459. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34460. */
  34461. bias: number;
  34462. private _normalBias;
  34463. /**
  34464. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34465. */
  34466. /**
  34467. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34468. */
  34469. normalBias: number;
  34470. private _blurBoxOffset;
  34471. /**
  34472. * Gets the blur box offset: offset applied during the blur pass.
  34473. * Only usefull if useKernelBlur = false
  34474. */
  34475. /**
  34476. * Sets the blur box offset: offset applied during the blur pass.
  34477. * Only usefull if useKernelBlur = false
  34478. */
  34479. blurBoxOffset: number;
  34480. private _blurScale;
  34481. /**
  34482. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34483. * 2 means half of the size.
  34484. */
  34485. /**
  34486. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34487. * 2 means half of the size.
  34488. */
  34489. blurScale: number;
  34490. private _blurKernel;
  34491. /**
  34492. * Gets the blur kernel: kernel size of the blur pass.
  34493. * Only usefull if useKernelBlur = true
  34494. */
  34495. /**
  34496. * Sets the blur kernel: kernel size of the blur pass.
  34497. * Only usefull if useKernelBlur = true
  34498. */
  34499. blurKernel: number;
  34500. private _useKernelBlur;
  34501. /**
  34502. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34503. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34504. */
  34505. /**
  34506. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34507. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34508. */
  34509. useKernelBlur: boolean;
  34510. private _depthScale;
  34511. /**
  34512. * Gets the depth scale used in ESM mode.
  34513. */
  34514. /**
  34515. * Sets the depth scale used in ESM mode.
  34516. * This can override the scale stored on the light.
  34517. */
  34518. depthScale: number;
  34519. private _filter;
  34520. /**
  34521. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34522. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34523. */
  34524. /**
  34525. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34526. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34527. */
  34528. filter: number;
  34529. /**
  34530. * Gets if the current filter is set to Poisson Sampling.
  34531. */
  34532. /**
  34533. * Sets the current filter to Poisson Sampling.
  34534. */
  34535. usePoissonSampling: boolean;
  34536. /**
  34537. * Gets if the current filter is set to VSM.
  34538. * DEPRECATED. Should use useExponentialShadowMap instead.
  34539. */
  34540. /**
  34541. * Sets the current filter is to VSM.
  34542. * DEPRECATED. Should use useExponentialShadowMap instead.
  34543. */
  34544. useVarianceShadowMap: boolean;
  34545. /**
  34546. * Gets if the current filter is set to blurred VSM.
  34547. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34548. */
  34549. /**
  34550. * Sets the current filter is to blurred VSM.
  34551. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34552. */
  34553. useBlurVarianceShadowMap: boolean;
  34554. /**
  34555. * Gets if the current filter is set to ESM.
  34556. */
  34557. /**
  34558. * Sets the current filter is to ESM.
  34559. */
  34560. useExponentialShadowMap: boolean;
  34561. /**
  34562. * Gets if the current filter is set to filtered ESM.
  34563. */
  34564. /**
  34565. * Gets if the current filter is set to filtered ESM.
  34566. */
  34567. useBlurExponentialShadowMap: boolean;
  34568. /**
  34569. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34570. * exponential to prevent steep falloff artifacts).
  34571. */
  34572. /**
  34573. * Sets the current filter to "close ESM" (using the inverse of the
  34574. * exponential to prevent steep falloff artifacts).
  34575. */
  34576. useCloseExponentialShadowMap: boolean;
  34577. /**
  34578. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34579. * exponential to prevent steep falloff artifacts).
  34580. */
  34581. /**
  34582. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34583. * exponential to prevent steep falloff artifacts).
  34584. */
  34585. useBlurCloseExponentialShadowMap: boolean;
  34586. /**
  34587. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34588. */
  34589. /**
  34590. * Sets the current filter to "PCF" (percentage closer filtering).
  34591. */
  34592. usePercentageCloserFiltering: boolean;
  34593. private _filteringQuality;
  34594. /**
  34595. * Gets the PCF or PCSS Quality.
  34596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34597. */
  34598. /**
  34599. * Sets the PCF or PCSS Quality.
  34600. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34601. */
  34602. filteringQuality: number;
  34603. /**
  34604. * Gets if the current filter is set to "PCSS" (contact hardening).
  34605. */
  34606. /**
  34607. * Sets the current filter to "PCSS" (contact hardening).
  34608. */
  34609. useContactHardeningShadow: boolean;
  34610. private _contactHardeningLightSizeUVRatio;
  34611. /**
  34612. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34613. * Using a ratio helps keeping shape stability independently of the map size.
  34614. *
  34615. * It does not account for the light projection as it was having too much
  34616. * instability during the light setup or during light position changes.
  34617. *
  34618. * Only valid if useContactHardeningShadow is true.
  34619. */
  34620. /**
  34621. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34622. * Using a ratio helps keeping shape stability independently of the map size.
  34623. *
  34624. * It does not account for the light projection as it was having too much
  34625. * instability during the light setup or during light position changes.
  34626. *
  34627. * Only valid if useContactHardeningShadow is true.
  34628. */
  34629. contactHardeningLightSizeUVRatio: number;
  34630. private _darkness;
  34631. /**
  34632. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34633. * 0 means strongest and 1 would means no shadow.
  34634. * @returns the darkness.
  34635. */
  34636. getDarkness(): number;
  34637. /**
  34638. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34639. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34640. * @returns the shadow generator allowing fluent coding.
  34641. */
  34642. setDarkness(darkness: number): ShadowGenerator;
  34643. private _transparencyShadow;
  34644. /**
  34645. * Sets the ability to have transparent shadow (boolean).
  34646. * @param transparent True if transparent else False
  34647. * @returns the shadow generator allowing fluent coding
  34648. */
  34649. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34650. private _shadowMap;
  34651. private _shadowMap2;
  34652. /**
  34653. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34654. * @returns The render target texture if present otherwise, null
  34655. */
  34656. getShadowMap(): Nullable<RenderTargetTexture>;
  34657. /**
  34658. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34659. * @returns The render target texture if the shadow map is present otherwise, null
  34660. */
  34661. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34662. /**
  34663. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34664. * @param mesh Mesh to add
  34665. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34666. * @returns the Shadow Generator itself
  34667. */
  34668. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34669. /**
  34670. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34671. * @param mesh Mesh to remove
  34672. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34673. * @returns the Shadow Generator itself
  34674. */
  34675. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34676. /**
  34677. * Controls the extent to which the shadows fade out at the edge of the frustum
  34678. * Used only by directionals and spots
  34679. */
  34680. frustumEdgeFalloff: number;
  34681. private _light;
  34682. /**
  34683. * Returns the associated light object.
  34684. * @returns the light generating the shadow
  34685. */
  34686. getLight(): IShadowLight;
  34687. /**
  34688. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34689. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34690. * It might on the other hand introduce peter panning.
  34691. */
  34692. forceBackFacesOnly: boolean;
  34693. private _scene;
  34694. private _lightDirection;
  34695. private _effect;
  34696. private _viewMatrix;
  34697. private _projectionMatrix;
  34698. private _transformMatrix;
  34699. private _cachedPosition;
  34700. private _cachedDirection;
  34701. private _cachedDefines;
  34702. private _currentRenderID;
  34703. private _boxBlurPostprocess;
  34704. private _kernelBlurXPostprocess;
  34705. private _kernelBlurYPostprocess;
  34706. private _blurPostProcesses;
  34707. private _mapSize;
  34708. private _currentFaceIndex;
  34709. private _currentFaceIndexCache;
  34710. private _textureType;
  34711. private _defaultTextureMatrix;
  34712. /**
  34713. * Creates a ShadowGenerator object.
  34714. * A ShadowGenerator is the required tool to use the shadows.
  34715. * Each light casting shadows needs to use its own ShadowGenerator.
  34716. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34717. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34718. * @param light The light object generating the shadows.
  34719. * @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.
  34720. */
  34721. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34722. private _initializeGenerator;
  34723. private _initializeShadowMap;
  34724. private _initializeBlurRTTAndPostProcesses;
  34725. private _renderForShadowMap;
  34726. private _renderSubMeshForShadowMap;
  34727. private _applyFilterValues;
  34728. /**
  34729. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34730. * @param onCompiled Callback triggered at the and of the effects compilation
  34731. * @param options Sets of optional options forcing the compilation with different modes
  34732. */
  34733. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34734. useInstances: boolean;
  34735. }>): void;
  34736. /**
  34737. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34738. * @param options Sets of optional options forcing the compilation with different modes
  34739. * @returns A promise that resolves when the compilation completes
  34740. */
  34741. forceCompilationAsync(options?: Partial<{
  34742. useInstances: boolean;
  34743. }>): Promise<void>;
  34744. /**
  34745. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34746. * @param subMesh The submesh we want to render in the shadow map
  34747. * @param useInstances Defines wether will draw in the map using instances
  34748. * @returns true if ready otherwise, false
  34749. */
  34750. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34751. /**
  34752. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34753. * @param defines Defines of the material we want to update
  34754. * @param lightIndex Index of the light in the enabled light list of the material
  34755. */
  34756. prepareDefines(defines: any, lightIndex: number): void;
  34757. /**
  34758. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34759. * defined in the generator but impacting the effect).
  34760. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34761. * @param effect The effect we are binfing the information for
  34762. */
  34763. bindShadowLight(lightIndex: string, effect: Effect): void;
  34764. /**
  34765. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34766. * (eq to shadow prjection matrix * light transform matrix)
  34767. * @returns The transform matrix used to create the shadow map
  34768. */
  34769. getTransformMatrix(): Matrix;
  34770. /**
  34771. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34772. * Cube and 2D textures for instance.
  34773. */
  34774. recreateShadowMap(): void;
  34775. private _disposeBlurPostProcesses;
  34776. private _disposeRTTandPostProcesses;
  34777. /**
  34778. * Disposes the ShadowGenerator.
  34779. * Returns nothing.
  34780. */
  34781. dispose(): void;
  34782. /**
  34783. * Serializes the shadow generator setup to a json object.
  34784. * @returns The serialized JSON object
  34785. */
  34786. serialize(): any;
  34787. /**
  34788. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  34789. * @param parsedShadowGenerator The JSON object to parse
  34790. * @param scene The scene to create the shadow map for
  34791. * @returns The parsed shadow generator
  34792. */
  34793. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. }
  34798. declare module BABYLON {
  34799. /**
  34800. * Background material used to create an efficient environement around your scene.
  34801. */
  34802. class BackgroundMaterial extends PushMaterial {
  34803. /**
  34804. * Standard reflectance value at parallel view angle.
  34805. */
  34806. static StandardReflectance0: number;
  34807. /**
  34808. * Standard reflectance value at grazing angle.
  34809. */
  34810. static StandardReflectance90: number;
  34811. protected _primaryColor: Color3;
  34812. /**
  34813. * Key light Color (multiply against the environement texture)
  34814. */
  34815. primaryColor: Color3;
  34816. protected __perceptualColor: Nullable<Color3>;
  34817. /**
  34818. * Experimental Internal Use Only.
  34819. *
  34820. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  34821. * This acts as a helper to set the primary color to a more "human friendly" value.
  34822. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  34823. * output color as close as possible from the chosen value.
  34824. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  34825. * part of lighting setup.)
  34826. */
  34827. _perceptualColor: Nullable<Color3>;
  34828. protected _primaryColorShadowLevel: float;
  34829. /**
  34830. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  34831. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  34832. */
  34833. primaryColorShadowLevel: float;
  34834. protected _primaryColorHighlightLevel: float;
  34835. /**
  34836. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  34837. * The primary color is used at the level chosen to define what the white area would look.
  34838. */
  34839. primaryColorHighlightLevel: float;
  34840. protected _reflectionTexture: Nullable<BaseTexture>;
  34841. /**
  34842. * Reflection Texture used in the material.
  34843. * Should be author in a specific way for the best result (refer to the documentation).
  34844. */
  34845. reflectionTexture: Nullable<BaseTexture>;
  34846. protected _reflectionBlur: float;
  34847. /**
  34848. * Reflection Texture level of blur.
  34849. *
  34850. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  34851. * texture twice.
  34852. */
  34853. reflectionBlur: float;
  34854. protected _diffuseTexture: Nullable<BaseTexture>;
  34855. /**
  34856. * Diffuse Texture used in the material.
  34857. * Should be author in a specific way for the best result (refer to the documentation).
  34858. */
  34859. diffuseTexture: Nullable<BaseTexture>;
  34860. protected _shadowLights: Nullable<IShadowLight[]>;
  34861. /**
  34862. * Specify the list of lights casting shadow on the material.
  34863. * All scene shadow lights will be included if null.
  34864. */
  34865. shadowLights: Nullable<IShadowLight[]>;
  34866. protected _shadowLevel: float;
  34867. /**
  34868. * Helps adjusting the shadow to a softer level if required.
  34869. * 0 means black shadows and 1 means no shadows.
  34870. */
  34871. shadowLevel: float;
  34872. protected _sceneCenter: Vector3;
  34873. /**
  34874. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  34875. * It is usually zero but might be interesting to modify according to your setup.
  34876. */
  34877. sceneCenter: Vector3;
  34878. protected _opacityFresnel: boolean;
  34879. /**
  34880. * This helps specifying that the material is falling off to the sky box at grazing angle.
  34881. * This helps ensuring a nice transition when the camera goes under the ground.
  34882. */
  34883. opacityFresnel: boolean;
  34884. protected _reflectionFresnel: boolean;
  34885. /**
  34886. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  34887. * This helps adding a mirror texture on the ground.
  34888. */
  34889. reflectionFresnel: boolean;
  34890. protected _reflectionFalloffDistance: number;
  34891. /**
  34892. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  34893. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  34894. */
  34895. reflectionFalloffDistance: number;
  34896. protected _reflectionAmount: number;
  34897. /**
  34898. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  34899. */
  34900. reflectionAmount: number;
  34901. protected _reflectionReflectance0: number;
  34902. /**
  34903. * This specifies the weight of the reflection at grazing angle.
  34904. */
  34905. reflectionReflectance0: number;
  34906. protected _reflectionReflectance90: number;
  34907. /**
  34908. * This specifies the weight of the reflection at a perpendicular point of view.
  34909. */
  34910. reflectionReflectance90: number;
  34911. /**
  34912. * Sets the reflection reflectance fresnel values according to the default standard
  34913. * empirically know to work well :-)
  34914. */
  34915. reflectionStandardFresnelWeight: number;
  34916. protected _useRGBColor: boolean;
  34917. /**
  34918. * Helps to directly use the maps channels instead of their level.
  34919. */
  34920. useRGBColor: boolean;
  34921. protected _enableNoise: boolean;
  34922. /**
  34923. * This helps reducing the banding effect that could occur on the background.
  34924. */
  34925. enableNoise: boolean;
  34926. /**
  34927. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  34928. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  34929. * Recommended to be keep at 1.0 except for special cases.
  34930. */
  34931. fovMultiplier: number;
  34932. private _fovMultiplier;
  34933. /**
  34934. * Enable the FOV adjustment feature controlled by fovMultiplier.
  34935. */
  34936. useEquirectangularFOV: boolean;
  34937. private _maxSimultaneousLights;
  34938. /**
  34939. * Number of Simultaneous lights allowed on the material.
  34940. */
  34941. maxSimultaneousLights: int;
  34942. /**
  34943. * Default configuration related to image processing available in the Background Material.
  34944. */
  34945. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34946. /**
  34947. * Keep track of the image processing observer to allow dispose and replace.
  34948. */
  34949. private _imageProcessingObserver;
  34950. /**
  34951. * Attaches a new image processing configuration to the PBR Material.
  34952. * @param configuration (if null the scene configuration will be use)
  34953. */
  34954. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34955. /**
  34956. * Gets the image processing configuration used either in this material.
  34957. */
  34958. /**
  34959. * Sets the Default image processing configuration used either in the this material.
  34960. *
  34961. * If sets to null, the scene one is in use.
  34962. */
  34963. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  34964. /**
  34965. * Gets wether the color curves effect is enabled.
  34966. */
  34967. /**
  34968. * Sets wether the color curves effect is enabled.
  34969. */
  34970. cameraColorCurvesEnabled: boolean;
  34971. /**
  34972. * Gets wether the color grading effect is enabled.
  34973. */
  34974. /**
  34975. * Gets wether the color grading effect is enabled.
  34976. */
  34977. cameraColorGradingEnabled: boolean;
  34978. /**
  34979. * Gets wether tonemapping is enabled or not.
  34980. */
  34981. /**
  34982. * Sets wether tonemapping is enabled or not
  34983. */
  34984. cameraToneMappingEnabled: boolean;
  34985. /**
  34986. * The camera exposure used on this material.
  34987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34988. * This corresponds to a photographic exposure.
  34989. */
  34990. /**
  34991. * The camera exposure used on this material.
  34992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34993. * This corresponds to a photographic exposure.
  34994. */
  34995. cameraExposure: float;
  34996. /**
  34997. * Gets The camera contrast used on this material.
  34998. */
  34999. /**
  35000. * Sets The camera contrast used on this material.
  35001. */
  35002. cameraContrast: float;
  35003. /**
  35004. * Gets the Color Grading 2D Lookup Texture.
  35005. */
  35006. /**
  35007. * Sets the Color Grading 2D Lookup Texture.
  35008. */
  35009. cameraColorGradingTexture: Nullable<BaseTexture>;
  35010. /**
  35011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35013. * 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;
  35014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35015. */
  35016. /**
  35017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35019. * 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;
  35020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35021. */
  35022. cameraColorCurves: Nullable<ColorCurves>;
  35023. /**
  35024. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  35025. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  35026. */
  35027. switchToBGR: boolean;
  35028. private _renderTargets;
  35029. private _reflectionControls;
  35030. private _white;
  35031. private _primaryShadowColor;
  35032. private _primaryHighlightColor;
  35033. /**
  35034. * Instantiates a Background Material in the given scene
  35035. * @param name The friendly name of the material
  35036. * @param scene The scene to add the material to
  35037. */
  35038. constructor(name: string, scene: Scene);
  35039. /**
  35040. * The entire material has been created in order to prevent overdraw.
  35041. * @returns false
  35042. */
  35043. needAlphaTesting(): boolean;
  35044. /**
  35045. * The entire material has been created in order to prevent overdraw.
  35046. * @returns true if blending is enable
  35047. */
  35048. needAlphaBlending(): boolean;
  35049. /**
  35050. * Checks wether the material is ready to be rendered for a given mesh.
  35051. * @param mesh The mesh to render
  35052. * @param subMesh The submesh to check against
  35053. * @param useInstances Specify wether or not the material is used with instances
  35054. * @returns true if all the dependencies are ready (Textures, Effects...)
  35055. */
  35056. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35057. /**
  35058. * Compute the primary color according to the chosen perceptual color.
  35059. */
  35060. private _computePrimaryColorFromPerceptualColor;
  35061. /**
  35062. * Compute the highlights and shadow colors according to their chosen levels.
  35063. */
  35064. private _computePrimaryColors;
  35065. /**
  35066. * Build the uniform buffer used in the material.
  35067. */
  35068. buildUniformLayout(): void;
  35069. /**
  35070. * Unbind the material.
  35071. */
  35072. unbind(): void;
  35073. /**
  35074. * Bind only the world matrix to the material.
  35075. * @param world The world matrix to bind.
  35076. */
  35077. bindOnlyWorldMatrix(world: Matrix): void;
  35078. /**
  35079. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  35080. * @param world The world matrix to bind.
  35081. * @param subMesh The submesh to bind for.
  35082. */
  35083. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35084. /**
  35085. * Dispose the material.
  35086. * @param forceDisposeEffect Force disposal of the associated effect.
  35087. * @param forceDisposeTextures Force disposal of the associated textures.
  35088. */
  35089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35090. /**
  35091. * Clones the material.
  35092. * @param name The cloned name.
  35093. * @returns The cloned material.
  35094. */
  35095. clone(name: string): BackgroundMaterial;
  35096. /**
  35097. * Serializes the current material to its JSON representation.
  35098. * @returns The JSON representation.
  35099. */
  35100. serialize(): any;
  35101. /**
  35102. * Gets the class name of the material
  35103. * @returns "BackgroundMaterial"
  35104. */
  35105. getClassName(): string;
  35106. /**
  35107. * Parse a JSON input to create back a background material.
  35108. * @param source The JSON data to parse
  35109. * @param scene The scene to create the parsed material in
  35110. * @param rootUrl The root url of the assets the material depends upon
  35111. * @returns the instantiated BackgroundMaterial.
  35112. */
  35113. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  35114. }
  35115. }
  35116. declare module BABYLON {
  35117. /**
  35118. * The Physically based material base class of BJS.
  35119. *
  35120. * This offers the main features of a standard PBR material.
  35121. * For more information, please refer to the documentation :
  35122. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35123. */
  35124. abstract class PBRBaseMaterial extends PushMaterial {
  35125. /**
  35126. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  35127. */
  35128. static readonly LIGHTFALLOFF_PHYSICAL: number;
  35129. /**
  35130. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  35131. * to enhance interoperability with other engines.
  35132. */
  35133. static readonly LIGHTFALLOFF_GLTF: number;
  35134. /**
  35135. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  35136. * to enhance interoperability with other materials.
  35137. */
  35138. static readonly LIGHTFALLOFF_STANDARD: number;
  35139. /**
  35140. * Intensity of the direct lights e.g. the four lights available in your scene.
  35141. * This impacts both the direct diffuse and specular highlights.
  35142. */
  35143. protected _directIntensity: number;
  35144. /**
  35145. * Intensity of the emissive part of the material.
  35146. * This helps controlling the emissive effect without modifying the emissive color.
  35147. */
  35148. protected _emissiveIntensity: number;
  35149. /**
  35150. * Intensity of the environment e.g. how much the environment will light the object
  35151. * either through harmonics for rough material or through the refelction for shiny ones.
  35152. */
  35153. protected _environmentIntensity: number;
  35154. /**
  35155. * This is a special control allowing the reduction of the specular highlights coming from the
  35156. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35157. */
  35158. protected _specularIntensity: number;
  35159. /**
  35160. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  35161. */
  35162. private _lightingInfos;
  35163. /**
  35164. * Debug Control allowing disabling the bump map on this material.
  35165. */
  35166. protected _disableBumpMap: boolean;
  35167. /**
  35168. * AKA Diffuse Texture in standard nomenclature.
  35169. */
  35170. protected _albedoTexture: BaseTexture;
  35171. /**
  35172. * AKA Occlusion Texture in other nomenclature.
  35173. */
  35174. protected _ambientTexture: BaseTexture;
  35175. /**
  35176. * AKA Occlusion Texture Intensity in other nomenclature.
  35177. */
  35178. protected _ambientTextureStrength: number;
  35179. /**
  35180. * Stores the alpha values in a texture.
  35181. */
  35182. protected _opacityTexture: BaseTexture;
  35183. /**
  35184. * Stores the reflection values in a texture.
  35185. */
  35186. protected _reflectionTexture: BaseTexture;
  35187. /**
  35188. * Stores the refraction values in a texture.
  35189. */
  35190. protected _refractionTexture: BaseTexture;
  35191. /**
  35192. * Stores the emissive values in a texture.
  35193. */
  35194. protected _emissiveTexture: BaseTexture;
  35195. /**
  35196. * AKA Specular texture in other nomenclature.
  35197. */
  35198. protected _reflectivityTexture: BaseTexture;
  35199. /**
  35200. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35201. */
  35202. protected _metallicTexture: BaseTexture;
  35203. /**
  35204. * Specifies the metallic scalar of the metallic/roughness workflow.
  35205. * Can also be used to scale the metalness values of the metallic texture.
  35206. */
  35207. protected _metallic: Nullable<number>;
  35208. /**
  35209. * Specifies the roughness scalar of the metallic/roughness workflow.
  35210. * Can also be used to scale the roughness values of the metallic texture.
  35211. */
  35212. protected _roughness: Nullable<number>;
  35213. /**
  35214. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35215. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35216. */
  35217. protected _microSurfaceTexture: BaseTexture;
  35218. /**
  35219. * Stores surface normal data used to displace a mesh in a texture.
  35220. */
  35221. protected _bumpTexture: BaseTexture;
  35222. /**
  35223. * Stores the pre-calculated light information of a mesh in a texture.
  35224. */
  35225. protected _lightmapTexture: BaseTexture;
  35226. /**
  35227. * The color of a material in ambient lighting.
  35228. */
  35229. protected _ambientColor: Color3;
  35230. /**
  35231. * AKA Diffuse Color in other nomenclature.
  35232. */
  35233. protected _albedoColor: Color3;
  35234. /**
  35235. * AKA Specular Color in other nomenclature.
  35236. */
  35237. protected _reflectivityColor: Color3;
  35238. /**
  35239. * The color applied when light is reflected from a material.
  35240. */
  35241. protected _reflectionColor: Color3;
  35242. /**
  35243. * The color applied when light is emitted from a material.
  35244. */
  35245. protected _emissiveColor: Color3;
  35246. /**
  35247. * AKA Glossiness in other nomenclature.
  35248. */
  35249. protected _microSurface: number;
  35250. /**
  35251. * source material index of refraction (IOR)' / 'destination material IOR.
  35252. */
  35253. protected _indexOfRefraction: number;
  35254. /**
  35255. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35256. */
  35257. protected _invertRefractionY: boolean;
  35258. /**
  35259. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35260. * Materials half opaque for instance using refraction could benefit from this control.
  35261. */
  35262. protected _linkRefractionWithTransparency: boolean;
  35263. /**
  35264. * Specifies that the material will use the light map as a show map.
  35265. */
  35266. protected _useLightmapAsShadowmap: boolean;
  35267. /**
  35268. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35269. * makes the reflect vector face the model (under horizon).
  35270. */
  35271. protected _useHorizonOcclusion: boolean;
  35272. /**
  35273. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35274. * too much the area relying on ambient texture to define their ambient occlusion.
  35275. */
  35276. protected _useRadianceOcclusion: boolean;
  35277. /**
  35278. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35279. */
  35280. protected _useAlphaFromAlbedoTexture: boolean;
  35281. /**
  35282. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35283. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35284. */
  35285. protected _useSpecularOverAlpha: boolean;
  35286. /**
  35287. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35288. */
  35289. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35290. /**
  35291. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35292. */
  35293. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  35294. /**
  35295. * Specifies if the metallic texture contains the roughness information in its green channel.
  35296. */
  35297. protected _useRoughnessFromMetallicTextureGreen: boolean;
  35298. /**
  35299. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35300. */
  35301. protected _useMetallnessFromMetallicTextureBlue: boolean;
  35302. /**
  35303. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35304. */
  35305. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  35306. /**
  35307. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35308. */
  35309. protected _useAmbientInGrayScale: boolean;
  35310. /**
  35311. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35312. * The material will try to infer what glossiness each pixel should be.
  35313. */
  35314. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  35315. /**
  35316. * Defines the falloff type used in this material.
  35317. * It by default is Physical.
  35318. */
  35319. protected _lightFalloff: number;
  35320. /**
  35321. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35322. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35323. */
  35324. protected _useRadianceOverAlpha: boolean;
  35325. /**
  35326. * Allows using an object space normal map (instead of tangent space).
  35327. */
  35328. protected _useObjectSpaceNormalMap: boolean;
  35329. /**
  35330. * Allows using the bump map in parallax mode.
  35331. */
  35332. protected _useParallax: boolean;
  35333. /**
  35334. * Allows using the bump map in parallax occlusion mode.
  35335. */
  35336. protected _useParallaxOcclusion: boolean;
  35337. /**
  35338. * Controls the scale bias of the parallax mode.
  35339. */
  35340. protected _parallaxScaleBias: number;
  35341. /**
  35342. * If sets to true, disables all the lights affecting the material.
  35343. */
  35344. protected _disableLighting: boolean;
  35345. /**
  35346. * Number of Simultaneous lights allowed on the material.
  35347. */
  35348. protected _maxSimultaneousLights: number;
  35349. /**
  35350. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  35351. */
  35352. protected _invertNormalMapX: boolean;
  35353. /**
  35354. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  35355. */
  35356. protected _invertNormalMapY: boolean;
  35357. /**
  35358. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35359. */
  35360. protected _twoSidedLighting: boolean;
  35361. /**
  35362. * Defines the alpha limits in alpha test mode.
  35363. */
  35364. protected _alphaCutOff: number;
  35365. /**
  35366. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35367. */
  35368. protected _forceAlphaTest: boolean;
  35369. /**
  35370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35371. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35372. */
  35373. protected _useAlphaFresnel: boolean;
  35374. /**
  35375. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35376. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35377. */
  35378. protected _useLinearAlphaFresnel: boolean;
  35379. /**
  35380. * The transparency mode of the material.
  35381. */
  35382. protected _transparencyMode: Nullable<number>;
  35383. /**
  35384. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  35385. * from cos thetav and roughness:
  35386. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  35387. */
  35388. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  35389. /**
  35390. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35391. */
  35392. protected _forceIrradianceInFragment: boolean;
  35393. /**
  35394. * Force normal to face away from face.
  35395. */
  35396. protected _forceNormalForward: boolean;
  35397. /**
  35398. * Enables specular anti aliasing in the PBR shader.
  35399. * It will both interacts on the Geometry for analytical and IBL lighting.
  35400. * It also prefilter the roughness map based on the bump values.
  35401. */
  35402. protected _enableSpecularAntiAliasing: boolean;
  35403. /**
  35404. * Default configuration related to image processing available in the PBR Material.
  35405. */
  35406. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35407. /**
  35408. * Keep track of the image processing observer to allow dispose and replace.
  35409. */
  35410. private _imageProcessingObserver;
  35411. /**
  35412. * Attaches a new image processing configuration to the PBR Material.
  35413. * @param configuration
  35414. */
  35415. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35416. /**
  35417. * Stores the available render targets.
  35418. */
  35419. private _renderTargets;
  35420. /**
  35421. * Sets the global ambient color for the material used in lighting calculations.
  35422. */
  35423. private _globalAmbientColor;
  35424. /**
  35425. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35426. */
  35427. private _useLogarithmicDepth;
  35428. /**
  35429. * If set to true, no lighting calculations will be applied.
  35430. */
  35431. private _unlit;
  35432. /**
  35433. * Instantiates a new PBRMaterial instance.
  35434. *
  35435. * @param name The material name
  35436. * @param scene The scene the material will be use in.
  35437. */
  35438. constructor(name: string, scene: Scene);
  35439. /**
  35440. * Gets the name of the material class.
  35441. */
  35442. getClassName(): string;
  35443. /**
  35444. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35445. */
  35446. /**
  35447. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35448. */
  35449. useLogarithmicDepth: boolean;
  35450. /**
  35451. * Gets the current transparency mode.
  35452. */
  35453. /**
  35454. * Sets the transparency mode of the material.
  35455. *
  35456. * | Value | Type | Description |
  35457. * | ----- | ----------------------------------- | ----------- |
  35458. * | 0 | OPAQUE | |
  35459. * | 1 | ALPHATEST | |
  35460. * | 2 | ALPHABLEND | |
  35461. * | 3 | ALPHATESTANDBLEND | |
  35462. *
  35463. */
  35464. transparencyMode: Nullable<number>;
  35465. /**
  35466. * Returns true if alpha blending should be disabled.
  35467. */
  35468. private readonly _disableAlphaBlending;
  35469. /**
  35470. * Specifies whether or not this material should be rendered in alpha blend mode.
  35471. */
  35472. needAlphaBlending(): boolean;
  35473. /**
  35474. * Specifies if the mesh will require alpha blending.
  35475. * @param mesh - BJS mesh.
  35476. */
  35477. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  35478. /**
  35479. * Specifies whether or not this material should be rendered in alpha test mode.
  35480. */
  35481. needAlphaTesting(): boolean;
  35482. /**
  35483. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  35484. */
  35485. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  35486. /**
  35487. * Gets the texture used for the alpha test.
  35488. */
  35489. getAlphaTestTexture(): BaseTexture;
  35490. /**
  35491. * Stores the reflectivity values based on metallic roughness workflow.
  35492. */
  35493. private static _scaledReflectivity;
  35494. /**
  35495. * Specifies that the submesh is ready to be used.
  35496. * @param mesh - BJS mesh.
  35497. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  35498. * @param useInstances - Specifies that instances should be used.
  35499. * @returns - boolean indicating that the submesh is ready or not.
  35500. */
  35501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35502. /**
  35503. * Specifies if the material uses metallic roughness workflow.
  35504. * @returns boolean specifiying if the material uses metallic roughness workflow.
  35505. */
  35506. isMetallicWorkflow(): boolean;
  35507. private _prepareEffect;
  35508. private _prepareDefines;
  35509. /**
  35510. * Force shader compilation
  35511. */
  35512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  35513. clipPlane: boolean;
  35514. }>): void;
  35515. /**
  35516. * Initializes the uniform buffer layout for the shader.
  35517. */
  35518. buildUniformLayout(): void;
  35519. /**
  35520. * Unbinds the textures.
  35521. */
  35522. unbind(): void;
  35523. /**
  35524. * Binds the submesh data.
  35525. * @param world - The world matrix.
  35526. * @param mesh - The BJS mesh.
  35527. * @param subMesh - A submesh of the BJS mesh.
  35528. */
  35529. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35530. /**
  35531. * Returns the animatable textures.
  35532. * @returns - Array of animatable textures.
  35533. */
  35534. getAnimatables(): IAnimatable[];
  35535. /**
  35536. * Returns the texture used for reflections.
  35537. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  35538. */
  35539. private _getReflectionTexture;
  35540. /**
  35541. * Returns the texture used for refraction or null if none is used.
  35542. * @returns - Refection texture if present. If no refraction texture and refraction
  35543. * is linked with transparency, returns environment texture. Otherwise, returns null.
  35544. */
  35545. private _getRefractionTexture;
  35546. /**
  35547. * Disposes the resources of the material.
  35548. * @param forceDisposeEffect - Forces the disposal of effects.
  35549. * @param forceDisposeTextures - Forces the disposal of all textures.
  35550. */
  35551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35552. }
  35553. }
  35554. declare module BABYLON {
  35555. /**
  35556. * The Physically based simple base material of BJS.
  35557. *
  35558. * This enables better naming and convention enforcements on top of the pbrMaterial.
  35559. * It is used as the base class for both the specGloss and metalRough conventions.
  35560. */
  35561. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  35562. /**
  35563. * Number of Simultaneous lights allowed on the material.
  35564. */
  35565. maxSimultaneousLights: number;
  35566. /**
  35567. * If sets to true, disables all the lights affecting the material.
  35568. */
  35569. disableLighting: boolean;
  35570. /**
  35571. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  35572. */
  35573. environmentTexture: BaseTexture;
  35574. /**
  35575. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35576. */
  35577. invertNormalMapX: boolean;
  35578. /**
  35579. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35580. */
  35581. invertNormalMapY: boolean;
  35582. /**
  35583. * Normal map used in the model.
  35584. */
  35585. normalTexture: BaseTexture;
  35586. /**
  35587. * Emissivie color used to self-illuminate the model.
  35588. */
  35589. emissiveColor: Color3;
  35590. /**
  35591. * Emissivie texture used to self-illuminate the model.
  35592. */
  35593. emissiveTexture: BaseTexture;
  35594. /**
  35595. * Occlusion Channel Strenght.
  35596. */
  35597. occlusionStrength: number;
  35598. /**
  35599. * Occlusion Texture of the material (adding extra occlusion effects).
  35600. */
  35601. occlusionTexture: BaseTexture;
  35602. /**
  35603. * Defines the alpha limits in alpha test mode.
  35604. */
  35605. alphaCutOff: number;
  35606. /**
  35607. * Gets the current double sided mode.
  35608. */
  35609. /**
  35610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35611. */
  35612. doubleSided: boolean;
  35613. lightmapTexture: BaseTexture;
  35614. useLightmapAsShadowmap: boolean;
  35615. /**
  35616. * Return the active textures of the material.
  35617. */
  35618. getActiveTextures(): BaseTexture[];
  35619. hasTexture(texture: BaseTexture): boolean;
  35620. /**
  35621. * Instantiates a new PBRMaterial instance.
  35622. *
  35623. * @param name The material name
  35624. * @param scene The scene the material will be use in.
  35625. */
  35626. constructor(name: string, scene: Scene);
  35627. getClassName(): string;
  35628. }
  35629. }
  35630. declare module BABYLON {
  35631. /**
  35632. * The Physically based material of BJS.
  35633. *
  35634. * This offers the main features of a standard PBR material.
  35635. * For more information, please refer to the documentation :
  35636. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35637. */
  35638. class PBRMaterial extends PBRBaseMaterial {
  35639. /**
  35640. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  35641. */
  35642. static readonly PBRMATERIAL_OPAQUE: number;
  35643. /**
  35644. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  35645. */
  35646. static readonly PBRMATERIAL_ALPHATEST: number;
  35647. /**
  35648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35649. */
  35650. static readonly PBRMATERIAL_ALPHABLEND: number;
  35651. /**
  35652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35653. * They are also discarded below the alpha cutoff threshold to improve performances.
  35654. */
  35655. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  35656. /**
  35657. * Intensity of the direct lights e.g. the four lights available in your scene.
  35658. * This impacts both the direct diffuse and specular highlights.
  35659. */
  35660. directIntensity: number;
  35661. /**
  35662. * Intensity of the emissive part of the material.
  35663. * This helps controlling the emissive effect without modifying the emissive color.
  35664. */
  35665. emissiveIntensity: number;
  35666. /**
  35667. * Intensity of the environment e.g. how much the environment will light the object
  35668. * either through harmonics for rough material or through the refelction for shiny ones.
  35669. */
  35670. environmentIntensity: number;
  35671. /**
  35672. * This is a special control allowing the reduction of the specular highlights coming from the
  35673. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35674. */
  35675. specularIntensity: number;
  35676. /**
  35677. * Debug Control allowing disabling the bump map on this material.
  35678. */
  35679. disableBumpMap: boolean;
  35680. /**
  35681. * AKA Diffuse Texture in standard nomenclature.
  35682. */
  35683. albedoTexture: BaseTexture;
  35684. /**
  35685. * AKA Occlusion Texture in other nomenclature.
  35686. */
  35687. ambientTexture: BaseTexture;
  35688. /**
  35689. * AKA Occlusion Texture Intensity in other nomenclature.
  35690. */
  35691. ambientTextureStrength: number;
  35692. /**
  35693. * Stores the alpha values in a texture.
  35694. */
  35695. opacityTexture: BaseTexture;
  35696. /**
  35697. * Stores the reflection values in a texture.
  35698. */
  35699. reflectionTexture: Nullable<BaseTexture>;
  35700. /**
  35701. * Stores the emissive values in a texture.
  35702. */
  35703. emissiveTexture: BaseTexture;
  35704. /**
  35705. * AKA Specular texture in other nomenclature.
  35706. */
  35707. reflectivityTexture: BaseTexture;
  35708. /**
  35709. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35710. */
  35711. metallicTexture: BaseTexture;
  35712. /**
  35713. * Specifies the metallic scalar of the metallic/roughness workflow.
  35714. * Can also be used to scale the metalness values of the metallic texture.
  35715. */
  35716. metallic: Nullable<number>;
  35717. /**
  35718. * Specifies the roughness scalar of the metallic/roughness workflow.
  35719. * Can also be used to scale the roughness values of the metallic texture.
  35720. */
  35721. roughness: Nullable<number>;
  35722. /**
  35723. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35724. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35725. */
  35726. microSurfaceTexture: BaseTexture;
  35727. /**
  35728. * Stores surface normal data used to displace a mesh in a texture.
  35729. */
  35730. bumpTexture: BaseTexture;
  35731. /**
  35732. * Stores the pre-calculated light information of a mesh in a texture.
  35733. */
  35734. lightmapTexture: BaseTexture;
  35735. /**
  35736. * Stores the refracted light information in a texture.
  35737. */
  35738. refractionTexture: BaseTexture;
  35739. /**
  35740. * The color of a material in ambient lighting.
  35741. */
  35742. ambientColor: Color3;
  35743. /**
  35744. * AKA Diffuse Color in other nomenclature.
  35745. */
  35746. albedoColor: Color3;
  35747. /**
  35748. * AKA Specular Color in other nomenclature.
  35749. */
  35750. reflectivityColor: Color3;
  35751. /**
  35752. * The color reflected from the material.
  35753. */
  35754. reflectionColor: Color3;
  35755. /**
  35756. * The color emitted from the material.
  35757. */
  35758. emissiveColor: Color3;
  35759. /**
  35760. * AKA Glossiness in other nomenclature.
  35761. */
  35762. microSurface: number;
  35763. /**
  35764. * source material index of refraction (IOR)' / 'destination material IOR.
  35765. */
  35766. indexOfRefraction: number;
  35767. /**
  35768. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35769. */
  35770. invertRefractionY: boolean;
  35771. /**
  35772. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35773. * Materials half opaque for instance using refraction could benefit from this control.
  35774. */
  35775. linkRefractionWithTransparency: boolean;
  35776. useLightmapAsShadowmap: boolean;
  35777. /**
  35778. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35779. */
  35780. useAlphaFromAlbedoTexture: boolean;
  35781. /**
  35782. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35783. */
  35784. forceAlphaTest: boolean;
  35785. /**
  35786. * Defines the alpha limits in alpha test mode.
  35787. */
  35788. alphaCutOff: number;
  35789. /**
  35790. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35791. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35792. */
  35793. useSpecularOverAlpha: boolean;
  35794. /**
  35795. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35796. */
  35797. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35798. /**
  35799. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35800. */
  35801. useRoughnessFromMetallicTextureAlpha: boolean;
  35802. /**
  35803. * Specifies if the metallic texture contains the roughness information in its green channel.
  35804. */
  35805. useRoughnessFromMetallicTextureGreen: boolean;
  35806. /**
  35807. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35808. */
  35809. useMetallnessFromMetallicTextureBlue: boolean;
  35810. /**
  35811. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35812. */
  35813. useAmbientOcclusionFromMetallicTextureRed: boolean;
  35814. /**
  35815. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35816. */
  35817. useAmbientInGrayScale: boolean;
  35818. /**
  35819. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35820. * The material will try to infer what glossiness each pixel should be.
  35821. */
  35822. useAutoMicroSurfaceFromReflectivityMap: boolean;
  35823. /**
  35824. * BJS is using an harcoded light falloff based on a manually sets up range.
  35825. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35826. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35827. */
  35828. /**
  35829. * BJS is using an harcoded light falloff based on a manually sets up range.
  35830. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35831. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35832. */
  35833. usePhysicalLightFalloff: boolean;
  35834. /**
  35835. * In order to support the falloff compatibility with gltf, a special mode has been added
  35836. * to reproduce the gltf light falloff.
  35837. */
  35838. /**
  35839. * In order to support the falloff compatibility with gltf, a special mode has been added
  35840. * to reproduce the gltf light falloff.
  35841. */
  35842. useGLTFLightFalloff: boolean;
  35843. /**
  35844. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35845. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35846. */
  35847. useRadianceOverAlpha: boolean;
  35848. /**
  35849. * Allows using an object space normal map (instead of tangent space).
  35850. */
  35851. useObjectSpaceNormalMap: boolean;
  35852. /**
  35853. * Allows using the bump map in parallax mode.
  35854. */
  35855. useParallax: boolean;
  35856. /**
  35857. * Allows using the bump map in parallax occlusion mode.
  35858. */
  35859. useParallaxOcclusion: boolean;
  35860. /**
  35861. * Controls the scale bias of the parallax mode.
  35862. */
  35863. parallaxScaleBias: number;
  35864. /**
  35865. * If sets to true, disables all the lights affecting the material.
  35866. */
  35867. disableLighting: boolean;
  35868. /**
  35869. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35870. */
  35871. forceIrradianceInFragment: boolean;
  35872. /**
  35873. * Number of Simultaneous lights allowed on the material.
  35874. */
  35875. maxSimultaneousLights: number;
  35876. /**
  35877. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35878. */
  35879. invertNormalMapX: boolean;
  35880. /**
  35881. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35882. */
  35883. invertNormalMapY: boolean;
  35884. /**
  35885. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35886. */
  35887. twoSidedLighting: boolean;
  35888. /**
  35889. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35890. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35891. */
  35892. useAlphaFresnel: boolean;
  35893. /**
  35894. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35895. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35896. */
  35897. useLinearAlphaFresnel: boolean;
  35898. /**
  35899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35900. * And/Or occlude the blended part.
  35901. */
  35902. environmentBRDFTexture: Nullable<BaseTexture>;
  35903. /**
  35904. * Force normal to face away from face.
  35905. */
  35906. forceNormalForward: boolean;
  35907. /**
  35908. * Enables specular anti aliasing in the PBR shader.
  35909. * It will both interacts on the Geometry for analytical and IBL lighting.
  35910. * It also prefilter the roughness map based on the bump values.
  35911. */
  35912. enableSpecularAntiAliasing: boolean;
  35913. /**
  35914. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35915. * makes the reflect vector face the model (under horizon).
  35916. */
  35917. useHorizonOcclusion: boolean;
  35918. /**
  35919. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35920. * too much the area relying on ambient texture to define their ambient occlusion.
  35921. */
  35922. useRadianceOcclusion: boolean;
  35923. /**
  35924. * If set to true, no lighting calculations will be applied.
  35925. */
  35926. unlit: boolean;
  35927. /**
  35928. * Gets the image processing configuration used either in this material.
  35929. */
  35930. /**
  35931. * Sets the Default image processing configuration used either in the this material.
  35932. *
  35933. * If sets to null, the scene one is in use.
  35934. */
  35935. imageProcessingConfiguration: ImageProcessingConfiguration;
  35936. /**
  35937. * Gets wether the color curves effect is enabled.
  35938. */
  35939. /**
  35940. * Sets wether the color curves effect is enabled.
  35941. */
  35942. cameraColorCurvesEnabled: boolean;
  35943. /**
  35944. * Gets wether the color grading effect is enabled.
  35945. */
  35946. /**
  35947. * Gets wether the color grading effect is enabled.
  35948. */
  35949. cameraColorGradingEnabled: boolean;
  35950. /**
  35951. * Gets wether tonemapping is enabled or not.
  35952. */
  35953. /**
  35954. * Sets wether tonemapping is enabled or not
  35955. */
  35956. cameraToneMappingEnabled: boolean;
  35957. /**
  35958. * The camera exposure used on this material.
  35959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35960. * This corresponds to a photographic exposure.
  35961. */
  35962. /**
  35963. * The camera exposure used on this material.
  35964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35965. * This corresponds to a photographic exposure.
  35966. */
  35967. cameraExposure: number;
  35968. /**
  35969. * Gets The camera contrast used on this material.
  35970. */
  35971. /**
  35972. * Sets The camera contrast used on this material.
  35973. */
  35974. cameraContrast: number;
  35975. /**
  35976. * Gets the Color Grading 2D Lookup Texture.
  35977. */
  35978. /**
  35979. * Sets the Color Grading 2D Lookup Texture.
  35980. */
  35981. cameraColorGradingTexture: Nullable<BaseTexture>;
  35982. /**
  35983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35985. * 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;
  35986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35987. */
  35988. /**
  35989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35991. * 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;
  35992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35993. */
  35994. cameraColorCurves: Nullable<ColorCurves>;
  35995. /**
  35996. * Instantiates a new PBRMaterial instance.
  35997. *
  35998. * @param name The material name
  35999. * @param scene The scene the material will be use in.
  36000. */
  36001. constructor(name: string, scene: Scene);
  36002. /**
  36003. * Returns the name of this material class.
  36004. */
  36005. getClassName(): string;
  36006. /**
  36007. * Returns an array of the actively used textures.
  36008. * @returns - Array of BaseTextures
  36009. */
  36010. getActiveTextures(): BaseTexture[];
  36011. /**
  36012. * Checks to see if a texture is used in the material.
  36013. * @param texture - Base texture to use.
  36014. * @returns - Boolean specifying if a texture is used in the material.
  36015. */
  36016. hasTexture(texture: BaseTexture): boolean;
  36017. /**
  36018. * Makes a duplicate of the current material.
  36019. * @param name - name to use for the new material.
  36020. */
  36021. clone(name: string): PBRMaterial;
  36022. /**
  36023. * Serializes this PBR Material.
  36024. * @returns - An object with the serialized material.
  36025. */
  36026. serialize(): any;
  36027. /**
  36028. * Parses a PBR Material from a serialized object.
  36029. * @param source - Serialized object.
  36030. * @param scene - BJS scene instance.
  36031. * @param rootUrl - url for the scene object
  36032. * @returns - PBRMaterial
  36033. */
  36034. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  36035. }
  36036. }
  36037. declare module BABYLON {
  36038. /**
  36039. * The PBR material of BJS following the metal roughness convention.
  36040. *
  36041. * This fits to the PBR convention in the GLTF definition:
  36042. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  36043. */
  36044. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  36045. /**
  36046. * The base color has two different interpretations depending on the value of metalness.
  36047. * When the material is a metal, the base color is the specific measured reflectance value
  36048. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  36049. * of the material.
  36050. */
  36051. baseColor: Color3;
  36052. /**
  36053. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  36054. * well as opacity information in the alpha channel.
  36055. */
  36056. baseTexture: BaseTexture;
  36057. /**
  36058. * Specifies the metallic scalar value of the material.
  36059. * Can also be used to scale the metalness values of the metallic texture.
  36060. */
  36061. metallic: number;
  36062. /**
  36063. * Specifies the roughness scalar value of the material.
  36064. * Can also be used to scale the roughness values of the metallic texture.
  36065. */
  36066. roughness: number;
  36067. /**
  36068. * Texture containing both the metallic value in the B channel and the
  36069. * roughness value in the G channel to keep better precision.
  36070. */
  36071. metallicRoughnessTexture: BaseTexture;
  36072. /**
  36073. * Instantiates a new PBRMetalRoughnessMaterial instance.
  36074. *
  36075. * @param name The material name
  36076. * @param scene The scene the material will be use in.
  36077. */
  36078. constructor(name: string, scene: Scene);
  36079. /**
  36080. * Return the currrent class name of the material.
  36081. */
  36082. getClassName(): string;
  36083. /**
  36084. * Return the active textures of the material.
  36085. */
  36086. getActiveTextures(): BaseTexture[];
  36087. /**
  36088. * Checks to see if a texture is used in the material.
  36089. * @param texture - Base texture to use.
  36090. * @returns - Boolean specifying if a texture is used in the material.
  36091. */
  36092. hasTexture(texture: BaseTexture): boolean;
  36093. /**
  36094. * Makes a duplicate of the current material.
  36095. * @param name - name to use for the new material.
  36096. */
  36097. clone(name: string): PBRMetallicRoughnessMaterial;
  36098. /**
  36099. * Serialize the material to a parsable JSON object.
  36100. */
  36101. serialize(): any;
  36102. /**
  36103. * Parses a JSON object correponding to the serialize function.
  36104. */
  36105. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  36106. }
  36107. }
  36108. declare module BABYLON {
  36109. /**
  36110. * The PBR material of BJS following the specular glossiness convention.
  36111. *
  36112. * This fits to the PBR convention in the GLTF definition:
  36113. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  36114. */
  36115. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  36116. /**
  36117. * Specifies the diffuse color of the material.
  36118. */
  36119. diffuseColor: Color3;
  36120. /**
  36121. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  36122. * channel.
  36123. */
  36124. diffuseTexture: BaseTexture;
  36125. /**
  36126. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  36127. */
  36128. specularColor: Color3;
  36129. /**
  36130. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  36131. */
  36132. glossiness: number;
  36133. /**
  36134. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  36135. */
  36136. specularGlossinessTexture: BaseTexture;
  36137. /**
  36138. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  36139. *
  36140. * @param name The material name
  36141. * @param scene The scene the material will be use in.
  36142. */
  36143. constructor(name: string, scene: Scene);
  36144. /**
  36145. * Return the currrent class name of the material.
  36146. */
  36147. getClassName(): string;
  36148. /**
  36149. * Return the active textures of the material.
  36150. */
  36151. getActiveTextures(): BaseTexture[];
  36152. /**
  36153. * Checks to see if a texture is used in the material.
  36154. * @param texture - Base texture to use.
  36155. * @returns - Boolean specifying if a texture is used in the material.
  36156. */
  36157. hasTexture(texture: BaseTexture): boolean;
  36158. /**
  36159. * Makes a duplicate of the current material.
  36160. * @param name - name to use for the new material.
  36161. */
  36162. clone(name: string): PBRSpecularGlossinessMaterial;
  36163. /**
  36164. * Serialize the material to a parsable JSON object.
  36165. */
  36166. serialize(): any;
  36167. /**
  36168. * Parses a JSON object correponding to the serialize function.
  36169. */
  36170. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  36171. }
  36172. }
  36173. declare module BABYLON {
  36174. class BaseTexture {
  36175. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36176. name: string;
  36177. private _hasAlpha;
  36178. hasAlpha: boolean;
  36179. getAlphaFromRGB: boolean;
  36180. level: number;
  36181. coordinatesIndex: number;
  36182. private _coordinatesMode;
  36183. /**
  36184. * How a texture is mapped.
  36185. *
  36186. * | Value | Type | Description |
  36187. * | ----- | ----------------------------------- | ----------- |
  36188. * | 0 | EXPLICIT_MODE | |
  36189. * | 1 | SPHERICAL_MODE | |
  36190. * | 2 | PLANAR_MODE | |
  36191. * | 3 | CUBIC_MODE | |
  36192. * | 4 | PROJECTION_MODE | |
  36193. * | 5 | SKYBOX_MODE | |
  36194. * | 6 | INVCUBIC_MODE | |
  36195. * | 7 | EQUIRECTANGULAR_MODE | |
  36196. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36197. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36198. */
  36199. coordinatesMode: number;
  36200. /**
  36201. * | Value | Type | Description |
  36202. * | ----- | ------------------ | ----------- |
  36203. * | 0 | CLAMP_ADDRESSMODE | |
  36204. * | 1 | WRAP_ADDRESSMODE | |
  36205. * | 2 | MIRROR_ADDRESSMODE | |
  36206. */
  36207. wrapU: number;
  36208. /**
  36209. * | Value | Type | Description |
  36210. * | ----- | ------------------ | ----------- |
  36211. * | 0 | CLAMP_ADDRESSMODE | |
  36212. * | 1 | WRAP_ADDRESSMODE | |
  36213. * | 2 | MIRROR_ADDRESSMODE | |
  36214. */
  36215. wrapV: number;
  36216. /**
  36217. * | Value | Type | Description |
  36218. * | ----- | ------------------ | ----------- |
  36219. * | 0 | CLAMP_ADDRESSMODE | |
  36220. * | 1 | WRAP_ADDRESSMODE | |
  36221. * | 2 | MIRROR_ADDRESSMODE | |
  36222. */
  36223. wrapR: number;
  36224. anisotropicFilteringLevel: number;
  36225. isCube: boolean;
  36226. is3D: boolean;
  36227. gammaSpace: boolean;
  36228. /**
  36229. * Gets whether or not the texture contains RGBD data.
  36230. */
  36231. readonly isRGBD: boolean;
  36232. invertZ: boolean;
  36233. lodLevelInAlpha: boolean;
  36234. lodGenerationOffset: number;
  36235. lodGenerationScale: number;
  36236. isRenderTarget: boolean;
  36237. readonly uid: string;
  36238. toString(): string;
  36239. getClassName(): string;
  36240. animations: Animation[];
  36241. /**
  36242. * An event triggered when the texture is disposed.
  36243. */
  36244. onDisposeObservable: Observable<BaseTexture>;
  36245. private _onDisposeObserver;
  36246. onDispose: () => void;
  36247. delayLoadState: number;
  36248. private _scene;
  36249. /** @hidden */
  36250. _texture: Nullable<InternalTexture>;
  36251. private _uid;
  36252. readonly isBlocking: boolean;
  36253. constructor(scene: Nullable<Scene>);
  36254. getScene(): Nullable<Scene>;
  36255. getTextureMatrix(): Matrix;
  36256. getReflectionTextureMatrix(): Matrix;
  36257. getInternalTexture(): Nullable<InternalTexture>;
  36258. isReadyOrNotBlocking(): boolean;
  36259. isReady(): boolean;
  36260. private _cachedSize;
  36261. getSize(): ISize;
  36262. getBaseSize(): ISize;
  36263. scale(ratio: number): void;
  36264. readonly canRescale: boolean;
  36265. /** @hidden */
  36266. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  36267. /** @hidden */
  36268. _rebuild(): void;
  36269. delayLoad(): void;
  36270. clone(): Nullable<BaseTexture>;
  36271. readonly textureType: number;
  36272. readonly textureFormat: number;
  36273. /**
  36274. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  36275. * This will returns an RGBA array buffer containing either in values (0-255) or
  36276. * float values (0-1) depending of the underlying buffer type.
  36277. * @param faceIndex The face of the texture to read (in case of cube texture)
  36278. * @param level The LOD level of the texture to read (in case of Mip Maps)
  36279. * @returns The Array buffer containing the pixels data.
  36280. */
  36281. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  36282. releaseInternalTexture(): void;
  36283. sphericalPolynomial: Nullable<SphericalPolynomial>;
  36284. readonly _lodTextureHigh: Nullable<BaseTexture>;
  36285. readonly _lodTextureMid: Nullable<BaseTexture>;
  36286. readonly _lodTextureLow: Nullable<BaseTexture>;
  36287. dispose(): void;
  36288. serialize(): any;
  36289. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  36290. }
  36291. }
  36292. declare module BABYLON {
  36293. /**
  36294. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  36295. * It can help converting any input color in a desired output one. This can then be used to create effects
  36296. * from sepia, black and white to sixties or futuristic rendering...
  36297. *
  36298. * The only supported format is currently 3dl.
  36299. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  36300. */
  36301. class ColorGradingTexture extends BaseTexture {
  36302. /**
  36303. * The current texture matrix. (will always be identity in color grading texture)
  36304. */
  36305. private _textureMatrix;
  36306. /**
  36307. * The texture URL.
  36308. */
  36309. url: string;
  36310. /**
  36311. * Empty line regex stored for GC.
  36312. */
  36313. private static _noneEmptyLineRegex;
  36314. private _engine;
  36315. /**
  36316. * Instantiates a ColorGradingTexture from the following parameters.
  36317. *
  36318. * @param url The location of the color gradind data (currently only supporting 3dl)
  36319. * @param scene The scene the texture will be used in
  36320. */
  36321. constructor(url: string, scene: Scene);
  36322. /**
  36323. * Returns the texture matrix used in most of the material.
  36324. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  36325. */
  36326. getTextureMatrix(): Matrix;
  36327. /**
  36328. * Occurs when the file being loaded is a .3dl LUT file.
  36329. */
  36330. private load3dlTexture;
  36331. /**
  36332. * Starts the loading process of the texture.
  36333. */
  36334. private loadTexture;
  36335. /**
  36336. * Clones the color gradind texture.
  36337. */
  36338. clone(): ColorGradingTexture;
  36339. /**
  36340. * Called during delayed load for textures.
  36341. */
  36342. delayLoad(): void;
  36343. /**
  36344. * Parses a color grading texture serialized by Babylon.
  36345. * @param parsedTexture The texture information being parsedTexture
  36346. * @param scene The scene to load the texture in
  36347. * @param rootUrl The root url of the data assets to load
  36348. * @return A color gradind texture
  36349. */
  36350. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  36351. /**
  36352. * Serializes the LUT texture to json format.
  36353. */
  36354. serialize(): any;
  36355. }
  36356. }
  36357. declare module BABYLON {
  36358. class CubeTexture extends BaseTexture {
  36359. url: string;
  36360. /**
  36361. * Gets or sets the center of the bounding box associated with the cube texture
  36362. * It must define where the camera used to render the texture was set
  36363. */
  36364. boundingBoxPosition: Vector3;
  36365. private _boundingBoxSize;
  36366. /**
  36367. * Gets or sets the size of the bounding box associated with the cube texture
  36368. * When defined, the cubemap will switch to local mode
  36369. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36370. * @example https://www.babylonjs-playground.com/#RNASML
  36371. */
  36372. boundingBoxSize: Vector3;
  36373. protected _rotationY: number;
  36374. /**
  36375. * Sets texture matrix rotation angle around Y axis in radians.
  36376. */
  36377. /**
  36378. * Gets texture matrix rotation angle around Y axis radians.
  36379. */
  36380. rotationY: number;
  36381. private _noMipmap;
  36382. private _files;
  36383. private _extensions;
  36384. private _textureMatrix;
  36385. private _format;
  36386. private _createPolynomials;
  36387. /** @hidden */
  36388. readonly _prefiltered: boolean;
  36389. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  36390. /**
  36391. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  36392. * @param url defines the url of the prefiltered texture
  36393. * @param scene defines the scene the texture is attached to
  36394. * @param forcedExtension defines the extension of the file if different from the url
  36395. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36396. * @return the prefiltered texture
  36397. */
  36398. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  36399. /**
  36400. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  36401. * as prefiltered data.
  36402. * @param rootUrl defines the url of the texture or the root name of the six images
  36403. * @param scene defines the scene the texture is attached to
  36404. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  36405. * @param noMipmap defines if mipmaps should be created or not
  36406. * @param files defines the six files to load for the different faces
  36407. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36408. * @param onError defines a callback triggered in case of error during load
  36409. * @param format defines the internal format to use for the texture once loaded
  36410. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36411. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36412. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36415. * @return the cube texture
  36416. */
  36417. 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);
  36418. delayLoad(): void;
  36419. getReflectionTextureMatrix(): Matrix;
  36420. setReflectionTextureMatrix(value: Matrix): void;
  36421. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36422. clone(): CubeTexture;
  36423. }
  36424. }
  36425. declare module BABYLON {
  36426. /**
  36427. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36428. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36429. */
  36430. class DynamicTexture extends Texture {
  36431. private _generateMipMaps;
  36432. private _canvas;
  36433. private _context;
  36434. private _engine;
  36435. /**
  36436. * Creates a {BABYLON.DynamicTexture}
  36437. * @param name defines the name of the texture
  36438. * @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
  36439. * @param scene defines the scene where you want the texture
  36440. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36441. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36442. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36443. */
  36444. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36445. /**
  36446. * Gets the current state of canRescale
  36447. */
  36448. readonly canRescale: boolean;
  36449. private _recreate;
  36450. /**
  36451. * Scales the texture
  36452. * @param ratio the scale factor to apply to both width and height
  36453. */
  36454. scale(ratio: number): void;
  36455. /**
  36456. * Resizes the texture
  36457. * @param width the new width
  36458. * @param height the new height
  36459. */
  36460. scaleTo(width: number, height: number): void;
  36461. /**
  36462. * Gets the context of the canvas used by the texture
  36463. * @returns the canvas context of the dynamic texture
  36464. */
  36465. getContext(): CanvasRenderingContext2D;
  36466. /**
  36467. * Clears the texture
  36468. */
  36469. clear(): void;
  36470. /**
  36471. * Updates the texture
  36472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36473. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  36474. */
  36475. update(invertY?: boolean, premulAlpha?: boolean): void;
  36476. /**
  36477. * Draws text onto the texture
  36478. * @param text defines the text to be drawn
  36479. * @param x defines the placement of the text from the left
  36480. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  36481. * @param font defines the font to be used with font-style, font-size, font-name
  36482. * @param color defines the color used for the text
  36483. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  36484. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36485. * @param update defines whether texture is immediately update (default is true)
  36486. */
  36487. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  36488. /**
  36489. * Clones the texture
  36490. * @returns the clone of the texture.
  36491. */
  36492. clone(): DynamicTexture;
  36493. /**
  36494. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  36495. * @returns a serialized dynamic texture object
  36496. */
  36497. serialize(): any;
  36498. /** @hidden */
  36499. _rebuild(): void;
  36500. }
  36501. }
  36502. declare module BABYLON {
  36503. /**
  36504. * This represents a texture coming from an HDR input.
  36505. *
  36506. * The only supported format is currently panorama picture stored in RGBE format.
  36507. * Example of such files can be found on HDRLib: http://hdrlib.com/
  36508. */
  36509. class HDRCubeTexture extends BaseTexture {
  36510. private static _facesMapping;
  36511. private _generateHarmonics;
  36512. private _noMipmap;
  36513. private _textureMatrix;
  36514. private _size;
  36515. private _onLoad;
  36516. private _onError;
  36517. /**
  36518. * The texture URL.
  36519. */
  36520. url: string;
  36521. /**
  36522. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  36523. */
  36524. coordinatesMode: number;
  36525. protected _isBlocking: boolean;
  36526. /**
  36527. * Sets wether or not the texture is blocking during loading.
  36528. */
  36529. /**
  36530. * Gets wether or not the texture is blocking during loading.
  36531. */
  36532. isBlocking: boolean;
  36533. protected _rotationY: number;
  36534. /**
  36535. * Sets texture matrix rotation angle around Y axis in radians.
  36536. */
  36537. /**
  36538. * Gets texture matrix rotation angle around Y axis radians.
  36539. */
  36540. rotationY: number;
  36541. /**
  36542. * Gets or sets the center of the bounding box associated with the cube texture
  36543. * It must define where the camera used to render the texture was set
  36544. */
  36545. boundingBoxPosition: Vector3;
  36546. private _boundingBoxSize;
  36547. /**
  36548. * Gets or sets the size of the bounding box associated with the cube texture
  36549. * When defined, the cubemap will switch to local mode
  36550. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36551. * @example https://www.babylonjs-playground.com/#RNASML
  36552. */
  36553. boundingBoxSize: Vector3;
  36554. /**
  36555. * Instantiates an HDRTexture from the following parameters.
  36556. *
  36557. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  36558. * @param scene The scene the texture will be used in
  36559. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  36560. * @param noMipmap Forces to not generate the mipmap if true
  36561. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  36562. * @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)
  36563. * @param reserved Reserved flag for internal use.
  36564. */
  36565. 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>);
  36566. /**
  36567. * Occurs when the file is raw .hdr file.
  36568. */
  36569. private loadTexture;
  36570. clone(): HDRCubeTexture;
  36571. delayLoad(): void;
  36572. getReflectionTextureMatrix(): Matrix;
  36573. setReflectionTextureMatrix(value: Matrix): void;
  36574. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  36575. serialize(): any;
  36576. }
  36577. }
  36578. declare module BABYLON {
  36579. /**
  36580. * Class used to store data associated with WebGL texture data for the engine
  36581. * This class should not be used directly
  36582. */
  36583. class InternalTexture implements IInternalTextureTracker {
  36584. /**
  36585. * The source of the texture data is unknown
  36586. */
  36587. static DATASOURCE_UNKNOWN: number;
  36588. /**
  36589. * Texture data comes from an URL
  36590. */
  36591. static DATASOURCE_URL: number;
  36592. /**
  36593. * Texture data is only used for temporary storage
  36594. */
  36595. static DATASOURCE_TEMP: number;
  36596. /**
  36597. * Texture data comes from raw data (ArrayBuffer)
  36598. */
  36599. static DATASOURCE_RAW: number;
  36600. /**
  36601. * Texture content is dynamic (video or dynamic texture)
  36602. */
  36603. static DATASOURCE_DYNAMIC: number;
  36604. /**
  36605. * Texture content is generated by rendering to it
  36606. */
  36607. static DATASOURCE_RENDERTARGET: number;
  36608. /**
  36609. * Texture content is part of a multi render target process
  36610. */
  36611. static DATASOURCE_MULTIRENDERTARGET: number;
  36612. /**
  36613. * Texture data comes from a cube data file
  36614. */
  36615. static DATASOURCE_CUBE: number;
  36616. /**
  36617. * Texture data comes from a raw cube data
  36618. */
  36619. static DATASOURCE_CUBERAW: number;
  36620. /**
  36621. * Texture data come from a prefiltered cube data file
  36622. */
  36623. static DATASOURCE_CUBEPREFILTERED: number;
  36624. /**
  36625. * Texture content is raw 3D data
  36626. */
  36627. static DATASOURCE_RAW3D: number;
  36628. /**
  36629. * Texture content is a depth texture
  36630. */
  36631. static DATASOURCE_DEPTHTEXTURE: number;
  36632. /**
  36633. * Texture data comes from a raw cube data encoded with RGBD
  36634. */
  36635. static DATASOURCE_CUBERAW_RGBD: number;
  36636. /**
  36637. * Defines if the texture is ready
  36638. */
  36639. isReady: boolean;
  36640. /**
  36641. * Defines if the texture is a cube texture
  36642. */
  36643. isCube: boolean;
  36644. /**
  36645. * Defines if the texture contains 3D data
  36646. */
  36647. is3D: boolean;
  36648. /**
  36649. * Gets the URL used to load this texture
  36650. */
  36651. url: string;
  36652. /**
  36653. * Gets the sampling mode of the texture
  36654. */
  36655. samplingMode: number;
  36656. /**
  36657. * Gets a boolean indicating if the texture needs mipmaps generation
  36658. */
  36659. generateMipMaps: boolean;
  36660. /**
  36661. * Gets the number of samples used by the texture (WebGL2+ only)
  36662. */
  36663. samples: number;
  36664. /**
  36665. * Gets the type of the texture
  36666. */
  36667. type: number;
  36668. /**
  36669. * Gets the format of the texture
  36670. */
  36671. format: number;
  36672. /**
  36673. * Observable called when the texture is loaded
  36674. */
  36675. onLoadedObservable: Observable<InternalTexture>;
  36676. /**
  36677. * Gets the width of the texture
  36678. */
  36679. width: number;
  36680. /**
  36681. * Gets the height of the texture
  36682. */
  36683. height: number;
  36684. /**
  36685. * Gets the depth of the texture
  36686. */
  36687. depth: number;
  36688. /**
  36689. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36690. */
  36691. baseWidth: number;
  36692. /**
  36693. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36694. */
  36695. baseHeight: number;
  36696. /**
  36697. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36698. */
  36699. baseDepth: number;
  36700. /**
  36701. * Gets a boolean indicating if the texture is inverted on Y axis
  36702. */
  36703. invertY: boolean;
  36704. /**
  36705. * Gets or set the previous tracker in the list
  36706. */
  36707. previous: Nullable<IInternalTextureTracker>;
  36708. /**
  36709. * Gets or set the next tracker in the list
  36710. */
  36711. next: Nullable<IInternalTextureTracker>;
  36712. /** @hidden */
  36713. _initialSlot: number;
  36714. /** @hidden */
  36715. _designatedSlot: number;
  36716. /** @hidden */
  36717. _dataSource: number;
  36718. /** @hidden */
  36719. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36720. /** @hidden */
  36721. _bufferView: Nullable<ArrayBufferView>;
  36722. /** @hidden */
  36723. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36724. /** @hidden */
  36725. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36726. /** @hidden */
  36727. _size: number;
  36728. /** @hidden */
  36729. _extension: string;
  36730. /** @hidden */
  36731. _files: Nullable<string[]>;
  36732. /** @hidden */
  36733. _workingCanvas: HTMLCanvasElement;
  36734. /** @hidden */
  36735. _workingContext: CanvasRenderingContext2D;
  36736. /** @hidden */
  36737. _framebuffer: Nullable<WebGLFramebuffer>;
  36738. /** @hidden */
  36739. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36740. /** @hidden */
  36741. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36742. /** @hidden */
  36743. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36744. /** @hidden */
  36745. _attachments: Nullable<number[]>;
  36746. /** @hidden */
  36747. _cachedCoordinatesMode: Nullable<number>;
  36748. /** @hidden */
  36749. _cachedWrapU: Nullable<number>;
  36750. /** @hidden */
  36751. _cachedWrapV: Nullable<number>;
  36752. /** @hidden */
  36753. _cachedWrapR: Nullable<number>;
  36754. /** @hidden */
  36755. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36756. /** @hidden */
  36757. _isDisabled: boolean;
  36758. /** @hidden */
  36759. _compression: Nullable<string>;
  36760. /** @hidden */
  36761. _generateStencilBuffer: boolean;
  36762. /** @hidden */
  36763. _generateDepthBuffer: boolean;
  36764. /** @hidden */
  36765. _comparisonFunction: number;
  36766. /** @hidden */
  36767. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36768. /** @hidden */
  36769. _lodGenerationScale: number;
  36770. /** @hidden */
  36771. _lodGenerationOffset: number;
  36772. /** @hidden */
  36773. _lodTextureHigh: BaseTexture;
  36774. /** @hidden */
  36775. _lodTextureMid: BaseTexture;
  36776. /** @hidden */
  36777. _lodTextureLow: BaseTexture;
  36778. /** @hidden */
  36779. _isRGBD: boolean;
  36780. /** @hidden */
  36781. _webGLTexture: Nullable<WebGLTexture>;
  36782. /** @hidden */
  36783. _references: number;
  36784. private _engine;
  36785. /**
  36786. * Gets the Engine the texture belongs to.
  36787. * @returns The babylon engine
  36788. */
  36789. getEngine(): Engine;
  36790. /**
  36791. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  36792. */
  36793. readonly dataSource: number;
  36794. /**
  36795. * Creates a new InternalTexture
  36796. * @param engine defines the engine to use
  36797. * @param dataSource defines the type of data that will be used
  36798. */
  36799. constructor(engine: Engine, dataSource: number);
  36800. /**
  36801. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  36802. */
  36803. incrementReferences(): void;
  36804. /**
  36805. * Change the size of the texture (not the size of the content)
  36806. * @param width defines the new width
  36807. * @param height defines the new height
  36808. * @param depth defines the new depth (1 by default)
  36809. */
  36810. updateSize(width: int, height: int, depth?: int): void;
  36811. /** @hidden */
  36812. _rebuild(): void;
  36813. /** @hidden */
  36814. _swapAndDie(target: InternalTexture): void;
  36815. /**
  36816. * Dispose the current allocated resources
  36817. */
  36818. dispose(): void;
  36819. }
  36820. }
  36821. declare module BABYLON {
  36822. /**
  36823. * This represents the required contract to create a new type of texture loader.
  36824. */
  36825. interface IInternalTextureLoader {
  36826. /**
  36827. * Defines wether the loader supports cascade loading the different faces.
  36828. */
  36829. supportCascades: boolean;
  36830. /**
  36831. * This returns if the loader support the current file information.
  36832. * @param extension defines the file extension of the file being loaded
  36833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36834. * @param fallback defines the fallback internal texture if any
  36835. * @param isBase64 defines whether the texture is encoded as a base64
  36836. * @param isBuffer defines whether the texture data are stored as a buffer
  36837. * @returns true if the loader can load the specified file
  36838. */
  36839. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  36840. /**
  36841. * Transform the url before loading if required.
  36842. * @param rootUrl the url of the texture
  36843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36844. * @returns the transformed texture
  36845. */
  36846. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  36847. /**
  36848. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  36849. * @param rootUrl the url of the texture
  36850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36851. * @returns the fallback texture
  36852. */
  36853. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  36854. /**
  36855. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  36856. * @param data contains the texture data
  36857. * @param texture defines the BabylonJS internal texture
  36858. * @param createPolynomials will be true if polynomials have been requested
  36859. * @param onLoad defines the callback to trigger once the texture is ready
  36860. * @param onError defines the callback to trigger in case of error
  36861. */
  36862. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  36863. /**
  36864. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  36865. * @param data contains the texture data
  36866. * @param texture defines the BabylonJS internal texture
  36867. * @param callback defines the method to call once ready to upload
  36868. */
  36869. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  36870. }
  36871. }
  36872. declare module BABYLON {
  36873. /**
  36874. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  36875. */
  36876. interface IInternalTextureTracker {
  36877. /**
  36878. * Gets or set the previous tracker in the list
  36879. */
  36880. previous: Nullable<IInternalTextureTracker>;
  36881. /**
  36882. * Gets or set the next tracker in the list
  36883. */
  36884. next: Nullable<IInternalTextureTracker>;
  36885. }
  36886. /**
  36887. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  36888. */
  36889. class DummyInternalTextureTracker {
  36890. /**
  36891. * Gets or set the previous tracker in the list
  36892. */
  36893. previous: Nullable<IInternalTextureTracker>;
  36894. /**
  36895. * Gets or set the next tracker in the list
  36896. */
  36897. next: Nullable<IInternalTextureTracker>;
  36898. }
  36899. }
  36900. declare module BABYLON {
  36901. class MirrorTexture extends RenderTargetTexture {
  36902. private scene;
  36903. mirrorPlane: Plane;
  36904. private _transformMatrix;
  36905. private _mirrorMatrix;
  36906. private _savedViewMatrix;
  36907. private _blurX;
  36908. private _blurY;
  36909. private _adaptiveBlurKernel;
  36910. private _blurKernelX;
  36911. private _blurKernelY;
  36912. private _blurRatio;
  36913. blurRatio: number;
  36914. adaptiveBlurKernel: number;
  36915. blurKernel: number;
  36916. blurKernelX: number;
  36917. blurKernelY: number;
  36918. private _autoComputeBlurKernel;
  36919. protected _onRatioRescale(): void;
  36920. private _updateGammaSpace;
  36921. private _imageProcessingConfigChangeObserver;
  36922. constructor(name: string, size: number | {
  36923. width: number;
  36924. height: number;
  36925. } | {
  36926. ratio: number;
  36927. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  36928. private _preparePostProcesses;
  36929. clone(): MirrorTexture;
  36930. serialize(): any;
  36931. dispose(): void;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. interface IMultiRenderTargetOptions {
  36936. generateMipMaps?: boolean;
  36937. types?: number[];
  36938. samplingModes?: number[];
  36939. generateDepthBuffer?: boolean;
  36940. generateStencilBuffer?: boolean;
  36941. generateDepthTexture?: boolean;
  36942. textureCount?: number;
  36943. doNotChangeAspectRatio?: boolean;
  36944. defaultType?: number;
  36945. }
  36946. class MultiRenderTarget extends RenderTargetTexture {
  36947. private _internalTextures;
  36948. private _textures;
  36949. readonly isSupported: boolean;
  36950. private _multiRenderTargetOptions;
  36951. readonly textures: Texture[];
  36952. readonly depthTexture: Texture;
  36953. wrapU: number;
  36954. wrapV: number;
  36955. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  36956. /** @hidden */
  36957. _rebuild(): void;
  36958. private _createInternalTextures;
  36959. private _createTextures;
  36960. samples: number;
  36961. resize(size: any): void;
  36962. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36963. dispose(): void;
  36964. releaseInternalTextures(): void;
  36965. }
  36966. }
  36967. declare module BABYLON {
  36968. /**
  36969. * Raw cube texture where the raw buffers are passed in
  36970. */
  36971. class RawCubeTexture extends CubeTexture {
  36972. /**
  36973. * Creates a cube texture where the raw buffers are passed in.
  36974. * @param scene defines the scene the texture is attached to
  36975. * @param data defines the array of data to use to create each face
  36976. * @param size defines the size of the textures
  36977. * @param format defines the format of the data
  36978. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  36979. * @param generateMipMaps defines if the engine should generate the mip levels
  36980. * @param invertY defines if data must be stored with Y axis inverted
  36981. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  36982. * @param compression defines the compression used (null by default)
  36983. */
  36984. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  36985. /**
  36986. * Updates the raw cube texture.
  36987. * @param data defines the data to store
  36988. * @param format defines the data format
  36989. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36990. * @param invertY defines if data must be stored with Y axis inverted
  36991. * @param compression defines the compression used (null by default)
  36992. * @param level defines which level of the texture to update
  36993. */
  36994. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  36995. /**
  36996. * Updates a raw cube texture with RGBD encoded data.
  36997. * @param data defines the array of data [mipmap][face] to use to create each face
  36998. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  36999. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37000. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37001. * @returns a promsie that resolves when the operation is complete
  37002. */
  37003. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  37004. /**
  37005. * Clones the raw cube texture.
  37006. * @return a new cube texture
  37007. */
  37008. clone(): CubeTexture;
  37009. /** @hidden */
  37010. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. class RawTexture extends Texture {
  37015. format: number;
  37016. private _engine;
  37017. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  37018. update(data: ArrayBufferView): void;
  37019. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37020. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37021. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  37022. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37023. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37024. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  37025. }
  37026. }
  37027. declare module BABYLON {
  37028. /**
  37029. * Class used to store 3D textures containing user data
  37030. */
  37031. class RawTexture3D extends Texture {
  37032. /** Gets or sets the texture format to use */
  37033. format: number;
  37034. private _engine;
  37035. /**
  37036. * Create a new RawTexture3D
  37037. * @param data defines the data of the texture
  37038. * @param width defines the width of the texture
  37039. * @param height defines the height of the texture
  37040. * @param depth defines the depth of the texture
  37041. * @param format defines the texture format to use
  37042. * @param scene defines the hosting scene
  37043. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  37044. * @param invertY defines if texture must be stored with Y axis inverted
  37045. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37046. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  37047. */
  37048. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  37049. /** Gets or sets the texture format to use */
  37050. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  37051. /**
  37052. * Update the texture with new data
  37053. * @param data defines the data to store in the texture
  37054. */
  37055. update(data: ArrayBufferView): void;
  37056. }
  37057. }
  37058. declare module BABYLON {
  37059. /**
  37060. * Creates a refraction texture used by refraction channel of the standard material.
  37061. * @param name the texture name
  37062. * @param size size of the underlying texture
  37063. * @param scene root scene
  37064. */
  37065. class RefractionTexture extends RenderTargetTexture {
  37066. refractionPlane: Plane;
  37067. depth: number;
  37068. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  37069. clone(): RefractionTexture;
  37070. serialize(): any;
  37071. }
  37072. }
  37073. declare module BABYLON {
  37074. class RenderTargetTexture extends Texture {
  37075. isCube: boolean;
  37076. static _REFRESHRATE_RENDER_ONCE: number;
  37077. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37078. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37079. static readonly REFRESHRATE_RENDER_ONCE: number;
  37080. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37081. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37082. /**
  37083. * Use this predicate to dynamically define the list of mesh you want to render.
  37084. * If set, the renderList property will be overwritten.
  37085. */
  37086. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37087. private _renderList;
  37088. /**
  37089. * Use this list to define the list of mesh you want to render.
  37090. */
  37091. renderList: Nullable<Array<AbstractMesh>>;
  37092. private _hookArray;
  37093. renderParticles: boolean;
  37094. renderSprites: boolean;
  37095. coordinatesMode: number;
  37096. activeCamera: Nullable<Camera>;
  37097. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37098. useCameraPostProcesses: boolean;
  37099. ignoreCameraViewport: boolean;
  37100. private _postProcessManager;
  37101. private _postProcesses;
  37102. private _resizeObserver;
  37103. /**
  37104. * An event triggered when the texture is unbind.
  37105. */
  37106. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37107. /**
  37108. * An event triggered when the texture is unbind.
  37109. */
  37110. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37111. private _onAfterUnbindObserver;
  37112. onAfterUnbind: () => void;
  37113. /**
  37114. * An event triggered before rendering the texture
  37115. */
  37116. onBeforeRenderObservable: Observable<number>;
  37117. private _onBeforeRenderObserver;
  37118. onBeforeRender: (faceIndex: number) => void;
  37119. /**
  37120. * An event triggered after rendering the texture
  37121. */
  37122. onAfterRenderObservable: Observable<number>;
  37123. private _onAfterRenderObserver;
  37124. onAfterRender: (faceIndex: number) => void;
  37125. /**
  37126. * An event triggered after the texture clear
  37127. */
  37128. onClearObservable: Observable<Engine>;
  37129. private _onClearObserver;
  37130. onClear: (Engine: Engine) => void;
  37131. clearColor: Color4;
  37132. protected _size: number | {
  37133. width: number;
  37134. height: number;
  37135. };
  37136. protected _initialSizeParameter: number | {
  37137. width: number;
  37138. height: number;
  37139. } | {
  37140. ratio: number;
  37141. };
  37142. protected _sizeRatio: Nullable<number>;
  37143. /** @hidden */
  37144. _generateMipMaps: boolean;
  37145. protected _renderingManager: RenderingManager;
  37146. /** @hidden */
  37147. _waitingRenderList: string[];
  37148. protected _doNotChangeAspectRatio: boolean;
  37149. protected _currentRefreshId: number;
  37150. protected _refreshRate: number;
  37151. protected _textureMatrix: Matrix;
  37152. protected _samples: number;
  37153. protected _renderTargetOptions: RenderTargetCreationOptions;
  37154. readonly renderTargetOptions: RenderTargetCreationOptions;
  37155. protected _engine: Engine;
  37156. protected _onRatioRescale(): void;
  37157. /**
  37158. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37159. * It must define where the camera used to render the texture is set
  37160. */
  37161. boundingBoxPosition: Vector3;
  37162. private _boundingBoxSize;
  37163. /**
  37164. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37165. * When defined, the cubemap will switch to local mode
  37166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37167. * @example https://www.babylonjs-playground.com/#RNASML
  37168. */
  37169. boundingBoxSize: Vector3;
  37170. /**
  37171. * In case the RTT has been created with a depth texture, get the associated
  37172. * depth texture.
  37173. * Otherwise, return null.
  37174. */
  37175. depthStencilTexture: Nullable<InternalTexture>;
  37176. /**
  37177. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  37178. * or used a shadow, depth texture...
  37179. * @param name The friendly name of the texture
  37180. * @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)
  37181. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37182. * @param generateMipMaps True if mip maps need to be generated after render.
  37183. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37184. * @param type The type of the buffer in the RTT (int, half float, float...)
  37185. * @param isCube True if a cube texture needs to be created
  37186. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37187. * @param generateDepthBuffer True to generate a depth buffer
  37188. * @param generateStencilBuffer True to generate a stencil buffer
  37189. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37190. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37191. */
  37192. constructor(name: string, size: number | {
  37193. width: number;
  37194. height: number;
  37195. } | {
  37196. ratio: number;
  37197. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  37198. /**
  37199. * Creates a depth stencil texture.
  37200. * This is only available in WebGL 2 or with the depth texture extension available.
  37201. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37202. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37203. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37204. */
  37205. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37206. private _processSizeParameter;
  37207. samples: number;
  37208. resetRefreshCounter(): void;
  37209. refreshRate: number;
  37210. addPostProcess(postProcess: PostProcess): void;
  37211. clearPostProcesses(dispose?: boolean): void;
  37212. removePostProcess(postProcess: PostProcess): void;
  37213. /** @hidden */
  37214. _shouldRender(): boolean;
  37215. getRenderSize(): number;
  37216. getRenderWidth(): number;
  37217. getRenderHeight(): number;
  37218. readonly canRescale: boolean;
  37219. scale(ratio: number): void;
  37220. getReflectionTextureMatrix(): Matrix;
  37221. resize(size: number | {
  37222. width: number;
  37223. height: number;
  37224. } | {
  37225. ratio: number;
  37226. }): void;
  37227. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37228. private _bestReflectionRenderTargetDimension;
  37229. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37230. private renderToTarget;
  37231. /**
  37232. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37233. * This allowed control for front to back rendering or reversly depending of the special needs.
  37234. *
  37235. * @param renderingGroupId The rendering group id corresponding to its index
  37236. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37237. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37238. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37239. */
  37240. 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;
  37241. /**
  37242. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37243. *
  37244. * @param renderingGroupId The rendering group id corresponding to its index
  37245. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37246. */
  37247. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37248. clone(): RenderTargetTexture;
  37249. serialize(): any;
  37250. disposeFramebufferObjects(): void;
  37251. dispose(): void;
  37252. /** @hidden */
  37253. _rebuild(): void;
  37254. /**
  37255. * Clear the info related to rendering groups preventing retention point in material dispose.
  37256. */
  37257. freeRenderingGroups(): void;
  37258. }
  37259. }
  37260. declare module BABYLON {
  37261. class Texture extends BaseTexture {
  37262. static NEAREST_SAMPLINGMODE: number;
  37263. static NEAREST_NEAREST_MIPLINEAR: number;
  37264. static BILINEAR_SAMPLINGMODE: number;
  37265. static LINEAR_LINEAR_MIPNEAREST: number;
  37266. static TRILINEAR_SAMPLINGMODE: number;
  37267. static LINEAR_LINEAR_MIPLINEAR: number;
  37268. static NEAREST_NEAREST_MIPNEAREST: number;
  37269. static NEAREST_LINEAR_MIPNEAREST: number;
  37270. static NEAREST_LINEAR_MIPLINEAR: number;
  37271. static NEAREST_LINEAR: number;
  37272. static NEAREST_NEAREST: number;
  37273. static LINEAR_NEAREST_MIPNEAREST: number;
  37274. static LINEAR_NEAREST_MIPLINEAR: number;
  37275. static LINEAR_LINEAR: number;
  37276. static LINEAR_NEAREST: number;
  37277. static EXPLICIT_MODE: number;
  37278. static SPHERICAL_MODE: number;
  37279. static PLANAR_MODE: number;
  37280. static CUBIC_MODE: number;
  37281. static PROJECTION_MODE: number;
  37282. static SKYBOX_MODE: number;
  37283. static INVCUBIC_MODE: number;
  37284. static EQUIRECTANGULAR_MODE: number;
  37285. static FIXED_EQUIRECTANGULAR_MODE: number;
  37286. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37287. static readonly CLAMP_ADDRESSMODE: number;
  37288. static readonly WRAP_ADDRESSMODE: number;
  37289. static readonly MIRROR_ADDRESSMODE: number;
  37290. /**
  37291. * 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
  37292. */
  37293. static UseSerializedUrlIfAny: boolean;
  37294. url: Nullable<string>;
  37295. uOffset: number;
  37296. vOffset: number;
  37297. uScale: number;
  37298. vScale: number;
  37299. uAng: number;
  37300. vAng: number;
  37301. wAng: number;
  37302. /**
  37303. * Defines the center of rotation (U)
  37304. */
  37305. uRotationCenter: number;
  37306. /**
  37307. * Defines the center of rotation (V)
  37308. */
  37309. vRotationCenter: number;
  37310. /**
  37311. * Defines the center of rotation (W)
  37312. */
  37313. wRotationCenter: number;
  37314. readonly noMipmap: boolean;
  37315. private _noMipmap;
  37316. /** @hidden */
  37317. _invertY: boolean;
  37318. private _rowGenerationMatrix;
  37319. private _cachedTextureMatrix;
  37320. private _projectionModeMatrix;
  37321. private _t0;
  37322. private _t1;
  37323. private _t2;
  37324. private _cachedUOffset;
  37325. private _cachedVOffset;
  37326. private _cachedUScale;
  37327. private _cachedVScale;
  37328. private _cachedUAng;
  37329. private _cachedVAng;
  37330. private _cachedWAng;
  37331. private _cachedProjectionMatrixId;
  37332. private _cachedCoordinatesMode;
  37333. /** @hidden */
  37334. _samplingMode: number;
  37335. /** @hidden */
  37336. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37337. private _deleteBuffer;
  37338. protected _format: Nullable<number>;
  37339. private _delayedOnLoad;
  37340. private _delayedOnError;
  37341. protected _onLoadObservable: Nullable<Observable<Texture>>;
  37342. protected _isBlocking: boolean;
  37343. isBlocking: boolean;
  37344. readonly samplingMode: number;
  37345. 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);
  37346. /**
  37347. * Update the url (and optional buffer) of this texture if url was null during construction.
  37348. * @param url the url of the texture
  37349. * @param buffer the buffer of the texture (defaults to null)
  37350. */
  37351. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  37352. delayLoad(): void;
  37353. /**
  37354. * Default is Trilinear mode.
  37355. *
  37356. * | Value | Type | Description |
  37357. * | ----- | ------------------ | ----------- |
  37358. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37359. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37360. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37361. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37362. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37363. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37364. * | 7 | NEAREST_LINEAR | |
  37365. * | 8 | NEAREST_NEAREST | |
  37366. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37367. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37368. * | 11 | LINEAR_LINEAR | |
  37369. * | 12 | LINEAR_NEAREST | |
  37370. *
  37371. * > _mag_: magnification filter (close to the viewer)
  37372. * > _min_: minification filter (far from the viewer)
  37373. * > _mip_: filter used between mip map levels
  37374. *
  37375. */
  37376. updateSamplingMode(samplingMode: number): void;
  37377. private _prepareRowForTextureGeneration;
  37378. getTextureMatrix(): Matrix;
  37379. getReflectionTextureMatrix(): Matrix;
  37380. clone(): Texture;
  37381. readonly onLoadObservable: Observable<Texture>;
  37382. serialize(): any;
  37383. getClassName(): string;
  37384. dispose(): void;
  37385. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  37386. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  37387. 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;
  37388. }
  37389. }
  37390. declare module BABYLON {
  37391. /**
  37392. * Settings for finer control over video usage
  37393. */
  37394. interface VideoTextureSettings {
  37395. /**
  37396. * Applies `autoplay` to video, if specified
  37397. */
  37398. autoPlay?: boolean;
  37399. /**
  37400. * Applies `loop` to video, if specified
  37401. */
  37402. loop?: boolean;
  37403. /**
  37404. * Automatically updates internal texture from video at every frame in the render loop
  37405. */
  37406. autoUpdateTexture: boolean;
  37407. /**
  37408. * Image src displayed during the video loading or until the user interacts with the video.
  37409. */
  37410. poster?: string;
  37411. }
  37412. class VideoTexture extends Texture {
  37413. /**
  37414. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  37415. */
  37416. readonly autoUpdateTexture: boolean;
  37417. /**
  37418. * The video instance used by the texture internally
  37419. */
  37420. readonly video: HTMLVideoElement;
  37421. private _onUserActionRequestedObservable;
  37422. readonly onUserActionRequestedObservable: Observable<Texture>;
  37423. private _generateMipMaps;
  37424. private _engine;
  37425. private _stillImageCaptured;
  37426. private _poster;
  37427. /**
  37428. * Creates a video texture.
  37429. * Sample : https://doc.babylonjs.com/how_to/video_texture
  37430. * @param {string | null} name optional name, will detect from video source, if not defined
  37431. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37432. * @param {BABYLON.Scene} scene is obviously the current scene.
  37433. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37434. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37435. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37436. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37437. */
  37438. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37439. private _getName;
  37440. private _getVideo;
  37441. private _createInternalTexture;
  37442. private reset;
  37443. /**
  37444. * @hidden Internal method to initiate `update`.
  37445. */
  37446. _rebuild(): void;
  37447. /**
  37448. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  37449. */
  37450. update(): void;
  37451. /**
  37452. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  37453. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  37454. */
  37455. updateTexture(isVisible: boolean): void;
  37456. protected _updateInternalTexture: (e?: Event | undefined) => void;
  37457. /**
  37458. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  37459. * @param url New url.
  37460. */
  37461. updateURL(url: string): void;
  37462. dispose(): void;
  37463. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  37464. minWidth: number;
  37465. maxWidth: number;
  37466. minHeight: number;
  37467. maxHeight: number;
  37468. deviceId: string;
  37469. }): void;
  37470. }
  37471. }
  37472. declare var DracoDecoderModule: any;
  37473. declare var WebAssembly: any;
  37474. declare module BABYLON {
  37475. /**
  37476. * Configuration for Draco compression
  37477. */
  37478. interface IDracoCompressionConfiguration {
  37479. /**
  37480. * Configuration for the decoder.
  37481. */
  37482. decoder?: {
  37483. /**
  37484. * The url to the WebAssembly module.
  37485. */
  37486. wasmUrl?: string;
  37487. /**
  37488. * The url to the WebAssembly binary.
  37489. */
  37490. wasmBinaryUrl?: string;
  37491. /**
  37492. * The url to the fallback JavaScript module.
  37493. */
  37494. fallbackUrl?: string;
  37495. };
  37496. }
  37497. /**
  37498. * Draco compression (https://google.github.io/draco/)
  37499. *
  37500. * This class wraps the Draco module.
  37501. *
  37502. * **Encoder**
  37503. *
  37504. * The encoder is not currently implemented.
  37505. *
  37506. * **Decoder**
  37507. *
  37508. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  37509. *
  37510. * To update the configuration, use the following code:
  37511. * ```javascript
  37512. * BABYLON.DracoCompression.Configuration = {
  37513. * decoder: {
  37514. * wasmUrl: "<url to the WebAssembly library>",
  37515. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  37516. * fallbackUrl: "<url to the fallback JavaScript library>",
  37517. * }
  37518. * };
  37519. * ```
  37520. *
  37521. * 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.
  37522. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  37523. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  37524. *
  37525. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  37526. * ```javascript
  37527. * var dracoCompression = new BABYLON.DracoCompression();
  37528. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  37529. * [BABYLON.VertexBuffer.PositionKind]: 0
  37530. * });
  37531. * ```
  37532. *
  37533. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  37534. */
  37535. class DracoCompression implements IDisposable {
  37536. private static _DecoderModulePromise;
  37537. /**
  37538. * The configuration. Defaults to the following urls:
  37539. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  37540. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  37541. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  37542. */
  37543. static Configuration: IDracoCompressionConfiguration;
  37544. /**
  37545. * Returns true if the decoder is available.
  37546. */
  37547. static readonly DecoderAvailable: boolean;
  37548. /**
  37549. * Constructor
  37550. */
  37551. constructor();
  37552. /**
  37553. * Stop all async operations and release resources.
  37554. */
  37555. dispose(): void;
  37556. /**
  37557. * Decode Draco compressed mesh data to vertex data.
  37558. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  37559. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37560. * @returns A promise that resolves with the decoded vertex data
  37561. */
  37562. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  37563. [kind: string]: number;
  37564. }): Promise<VertexData>;
  37565. private static _GetDecoderModule;
  37566. private static _LoadScriptAsync;
  37567. private static _LoadFileAsync;
  37568. }
  37569. }
  37570. declare module BABYLON {
  37571. /**
  37572. * Particle emitter emitting particles from the inside of a box.
  37573. * It emits the particles randomly between 2 given directions.
  37574. */
  37575. class BoxParticleEmitter implements IParticleEmitterType {
  37576. /**
  37577. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37578. */
  37579. direction1: Vector3;
  37580. /**
  37581. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37582. */
  37583. direction2: Vector3;
  37584. /**
  37585. * 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.
  37586. */
  37587. minEmitBox: Vector3;
  37588. /**
  37589. * 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.
  37590. */
  37591. maxEmitBox: Vector3;
  37592. /**
  37593. * Creates a new instance BoxParticleEmitter
  37594. */
  37595. constructor();
  37596. /**
  37597. * Called by the particle System when the direction is computed for the created particle.
  37598. * @param worldMatrix is the world matrix of the particle system
  37599. * @param directionToUpdate is the direction vector to update with the result
  37600. * @param particle is the particle we are computed the direction for
  37601. */
  37602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37603. /**
  37604. * Called by the particle System when the position is computed for the created particle.
  37605. * @param worldMatrix is the world matrix of the particle system
  37606. * @param positionToUpdate is the position vector to update with the result
  37607. * @param particle is the particle we are computed the position for
  37608. */
  37609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37610. /**
  37611. * Clones the current emitter and returns a copy of it
  37612. * @returns the new emitter
  37613. */
  37614. clone(): BoxParticleEmitter;
  37615. /**
  37616. * Called by the GPUParticleSystem to setup the update shader
  37617. * @param effect defines the update shader
  37618. */
  37619. applyToShader(effect: Effect): void;
  37620. /**
  37621. * Returns a string to use to update the GPU particles update shader
  37622. * @returns a string containng the defines string
  37623. */
  37624. getEffectDefines(): string;
  37625. /**
  37626. * Returns the string "BoxParticleEmitter"
  37627. * @returns a string containing the class name
  37628. */
  37629. getClassName(): string;
  37630. /**
  37631. * Serializes the particle system to a JSON object.
  37632. * @returns the JSON object
  37633. */
  37634. serialize(): any;
  37635. /**
  37636. * Parse properties from a JSON object
  37637. * @param serializationObject defines the JSON object
  37638. */
  37639. parse(serializationObject: any): void;
  37640. }
  37641. }
  37642. declare module BABYLON {
  37643. /**
  37644. * Particle emitter emitting particles from the inside of a cone.
  37645. * It emits the particles alongside the cone volume from the base to the particle.
  37646. * The emission direction might be randomized.
  37647. */
  37648. class ConeParticleEmitter implements IParticleEmitterType {
  37649. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37650. directionRandomizer: number;
  37651. private _radius;
  37652. private _angle;
  37653. private _height;
  37654. /**
  37655. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  37656. */
  37657. radiusRange: number;
  37658. /**
  37659. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  37660. */
  37661. heightRange: number;
  37662. /**
  37663. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  37664. */
  37665. emitFromSpawnPointOnly: boolean;
  37666. /**
  37667. * Gets or sets the radius of the emission cone
  37668. */
  37669. radius: number;
  37670. /**
  37671. * Gets or sets the angle of the emission cone
  37672. */
  37673. angle: number;
  37674. private _buildHeight;
  37675. /**
  37676. * Creates a new instance ConeParticleEmitter
  37677. * @param radius the radius of the emission cone (1 by default)
  37678. * @param angles the cone base angle (PI by default)
  37679. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  37680. */
  37681. constructor(radius?: number, angle?: number,
  37682. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37683. directionRandomizer?: number);
  37684. /**
  37685. * Called by the particle System when the direction is computed for the created particle.
  37686. * @param worldMatrix is the world matrix of the particle system
  37687. * @param directionToUpdate is the direction vector to update with the result
  37688. * @param particle is the particle we are computed the direction for
  37689. */
  37690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37691. /**
  37692. * Called by the particle System when the position is computed for the created particle.
  37693. * @param worldMatrix is the world matrix of the particle system
  37694. * @param positionToUpdate is the position vector to update with the result
  37695. * @param particle is the particle we are computed the position for
  37696. */
  37697. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37698. /**
  37699. * Clones the current emitter and returns a copy of it
  37700. * @returns the new emitter
  37701. */
  37702. clone(): ConeParticleEmitter;
  37703. /**
  37704. * Called by the GPUParticleSystem to setup the update shader
  37705. * @param effect defines the update shader
  37706. */
  37707. applyToShader(effect: Effect): void;
  37708. /**
  37709. * Returns a string to use to update the GPU particles update shader
  37710. * @returns a string containng the defines string
  37711. */
  37712. getEffectDefines(): string;
  37713. /**
  37714. * Returns the string "ConeParticleEmitter"
  37715. * @returns a string containing the class name
  37716. */
  37717. getClassName(): string;
  37718. /**
  37719. * Serializes the particle system to a JSON object.
  37720. * @returns the JSON object
  37721. */
  37722. serialize(): any;
  37723. /**
  37724. * Parse properties from a JSON object
  37725. * @param serializationObject defines the JSON object
  37726. */
  37727. parse(serializationObject: any): void;
  37728. }
  37729. }
  37730. declare module BABYLON {
  37731. /**
  37732. * Particle emitter emitting particles from the inside of a hemisphere.
  37733. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  37734. */
  37735. class HemisphericParticleEmitter implements IParticleEmitterType {
  37736. /**
  37737. * The radius of the emission hemisphere.
  37738. */
  37739. radius: number;
  37740. /**
  37741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37742. */
  37743. radiusRange: number;
  37744. /**
  37745. * How much to randomize the particle direction [0-1].
  37746. */
  37747. directionRandomizer: number;
  37748. /**
  37749. * Creates a new instance HemisphericParticleEmitter
  37750. * @param radius the radius of the emission hemisphere (1 by default)
  37751. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37752. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37753. */
  37754. constructor(
  37755. /**
  37756. * The radius of the emission hemisphere.
  37757. */
  37758. radius?: number,
  37759. /**
  37760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37761. */
  37762. radiusRange?: number,
  37763. /**
  37764. * How much to randomize the particle direction [0-1].
  37765. */
  37766. directionRandomizer?: number);
  37767. /**
  37768. * Called by the particle System when the direction is computed for the created particle.
  37769. * @param worldMatrix is the world matrix of the particle system
  37770. * @param directionToUpdate is the direction vector to update with the result
  37771. * @param particle is the particle we are computed the direction for
  37772. */
  37773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37774. /**
  37775. * Called by the particle System when the position is computed for the created particle.
  37776. * @param worldMatrix is the world matrix of the particle system
  37777. * @param positionToUpdate is the position vector to update with the result
  37778. * @param particle is the particle we are computed the position for
  37779. */
  37780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37781. /**
  37782. * Clones the current emitter and returns a copy of it
  37783. * @returns the new emitter
  37784. */
  37785. clone(): HemisphericParticleEmitter;
  37786. /**
  37787. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37788. * @param effect defines the update shader
  37789. */
  37790. applyToShader(effect: Effect): void;
  37791. /**
  37792. * Returns a string to use to update the GPU particles update shader
  37793. * @returns a string containng the defines string
  37794. */
  37795. getEffectDefines(): string;
  37796. /**
  37797. * Returns the string "HemisphericParticleEmitter"
  37798. * @returns a string containing the class name
  37799. */
  37800. getClassName(): string;
  37801. /**
  37802. * Serializes the particle system to a JSON object.
  37803. * @returns the JSON object
  37804. */
  37805. serialize(): any;
  37806. /**
  37807. * Parse properties from a JSON object
  37808. * @param serializationObject defines the JSON object
  37809. */
  37810. parse(serializationObject: any): void;
  37811. }
  37812. }
  37813. declare module BABYLON {
  37814. /**
  37815. * Particle emitter represents a volume emitting particles.
  37816. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  37817. */
  37818. interface IParticleEmitterType {
  37819. /**
  37820. * Called by the particle System when the direction is computed for the created particle.
  37821. * @param worldMatrix is the world matrix of the particle system
  37822. * @param directionToUpdate is the direction vector to update with the result
  37823. * @param particle is the particle we are computed the direction for
  37824. */
  37825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37826. /**
  37827. * Called by the particle System when the position is computed for the created particle.
  37828. * @param worldMatrix is the world matrix of the particle system
  37829. * @param positionToUpdate is the position vector to update with the result
  37830. * @param particle is the particle we are computed the position for
  37831. */
  37832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37833. /**
  37834. * Clones the current emitter and returns a copy of it
  37835. * @returns the new emitter
  37836. */
  37837. clone(): IParticleEmitterType;
  37838. /**
  37839. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37840. * @param effect defines the update shader
  37841. */
  37842. applyToShader(effect: Effect): void;
  37843. /**
  37844. * Returns a string to use to update the GPU particles update shader
  37845. * @returns the effect defines string
  37846. */
  37847. getEffectDefines(): string;
  37848. /**
  37849. * Returns a string representing the class name
  37850. * @returns a string containing the class name
  37851. */
  37852. getClassName(): string;
  37853. /**
  37854. * Serializes the particle system to a JSON object.
  37855. * @returns the JSON object
  37856. */
  37857. serialize(): any;
  37858. /**
  37859. * Parse properties from a JSON object
  37860. * @param serializationObject defines the JSON object
  37861. */
  37862. parse(serializationObject: any): void;
  37863. }
  37864. }
  37865. declare module BABYLON {
  37866. /**
  37867. * Particle emitter emitting particles from a point.
  37868. * It emits the particles randomly between 2 given directions.
  37869. */
  37870. class PointParticleEmitter implements IParticleEmitterType {
  37871. /**
  37872. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37873. */
  37874. direction1: Vector3;
  37875. /**
  37876. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37877. */
  37878. direction2: Vector3;
  37879. /**
  37880. * Creates a new instance PointParticleEmitter
  37881. */
  37882. constructor();
  37883. /**
  37884. * Called by the particle System when the direction is computed for the created particle.
  37885. * @param worldMatrix is the world matrix of the particle system
  37886. * @param directionToUpdate is the direction vector to update with the result
  37887. * @param particle is the particle we are computed the direction for
  37888. */
  37889. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37890. /**
  37891. * Called by the particle System when the position is computed for the created particle.
  37892. * @param worldMatrix is the world matrix of the particle system
  37893. * @param positionToUpdate is the position vector to update with the result
  37894. * @param particle is the particle we are computed the position for
  37895. */
  37896. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37897. /**
  37898. * Clones the current emitter and returns a copy of it
  37899. * @returns the new emitter
  37900. */
  37901. clone(): PointParticleEmitter;
  37902. /**
  37903. * Called by the GPUParticleSystem to setup the update shader
  37904. * @param effect defines the update shader
  37905. */
  37906. applyToShader(effect: Effect): void;
  37907. /**
  37908. * Returns a string to use to update the GPU particles update shader
  37909. * @returns a string containng the defines string
  37910. */
  37911. getEffectDefines(): string;
  37912. /**
  37913. * Returns the string "PointParticleEmitter"
  37914. * @returns a string containing the class name
  37915. */
  37916. getClassName(): string;
  37917. /**
  37918. * Serializes the particle system to a JSON object.
  37919. * @returns the JSON object
  37920. */
  37921. serialize(): any;
  37922. /**
  37923. * Parse properties from a JSON object
  37924. * @param serializationObject defines the JSON object
  37925. */
  37926. parse(serializationObject: any): void;
  37927. }
  37928. }
  37929. declare module BABYLON {
  37930. /**
  37931. * Particle emitter emitting particles from the inside of a sphere.
  37932. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  37933. */
  37934. class SphereParticleEmitter implements IParticleEmitterType {
  37935. /**
  37936. * The radius of the emission sphere.
  37937. */
  37938. radius: number;
  37939. /**
  37940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37941. */
  37942. radiusRange: number;
  37943. /**
  37944. * How much to randomize the particle direction [0-1].
  37945. */
  37946. directionRandomizer: number;
  37947. /**
  37948. * Creates a new instance SphereParticleEmitter
  37949. * @param radius the radius of the emission sphere (1 by default)
  37950. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37951. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37952. */
  37953. constructor(
  37954. /**
  37955. * The radius of the emission sphere.
  37956. */
  37957. radius?: number,
  37958. /**
  37959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37960. */
  37961. radiusRange?: number,
  37962. /**
  37963. * How much to randomize the particle direction [0-1].
  37964. */
  37965. directionRandomizer?: number);
  37966. /**
  37967. * Called by the particle System when the direction is computed for the created particle.
  37968. * @param worldMatrix is the world matrix of the particle system
  37969. * @param directionToUpdate is the direction vector to update with the result
  37970. * @param particle is the particle we are computed the direction for
  37971. */
  37972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37973. /**
  37974. * Called by the particle System when the position is computed for the created particle.
  37975. * @param worldMatrix is the world matrix of the particle system
  37976. * @param positionToUpdate is the position vector to update with the result
  37977. * @param particle is the particle we are computed the position for
  37978. */
  37979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37980. /**
  37981. * Clones the current emitter and returns a copy of it
  37982. * @returns the new emitter
  37983. */
  37984. clone(): SphereParticleEmitter;
  37985. /**
  37986. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37987. * @param effect defines the update shader
  37988. */
  37989. applyToShader(effect: Effect): void;
  37990. /**
  37991. * Returns a string to use to update the GPU particles update shader
  37992. * @returns a string containng the defines string
  37993. */
  37994. getEffectDefines(): string;
  37995. /**
  37996. * Returns the string "SphereParticleEmitter"
  37997. * @returns a string containing the class name
  37998. */
  37999. getClassName(): string;
  38000. /**
  38001. * Serializes the particle system to a JSON object.
  38002. * @returns the JSON object
  38003. */
  38004. serialize(): any;
  38005. /**
  38006. * Parse properties from a JSON object
  38007. * @param serializationObject defines the JSON object
  38008. */
  38009. parse(serializationObject: any): void;
  38010. }
  38011. /**
  38012. * Particle emitter emitting particles from the inside of a sphere.
  38013. * It emits the particles randomly between two vectors.
  38014. */
  38015. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  38016. /**
  38017. * The min limit of the emission direction.
  38018. */
  38019. direction1: Vector3;
  38020. /**
  38021. * The max limit of the emission direction.
  38022. */
  38023. direction2: Vector3;
  38024. /**
  38025. * Creates a new instance SphereDirectedParticleEmitter
  38026. * @param radius the radius of the emission sphere (1 by default)
  38027. * @param direction1 the min limit of the emission direction (up vector by default)
  38028. * @param direction2 the max limit of the emission direction (up vector by default)
  38029. */
  38030. constructor(radius?: number,
  38031. /**
  38032. * The min limit of the emission direction.
  38033. */
  38034. direction1?: Vector3,
  38035. /**
  38036. * The max limit of the emission direction.
  38037. */
  38038. direction2?: Vector3);
  38039. /**
  38040. * Called by the particle System when the direction is computed for the created particle.
  38041. * @param worldMatrix is the world matrix of the particle system
  38042. * @param directionToUpdate is the direction vector to update with the result
  38043. * @param particle is the particle we are computed the direction for
  38044. */
  38045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38046. /**
  38047. * Clones the current emitter and returns a copy of it
  38048. * @returns the new emitter
  38049. */
  38050. clone(): SphereDirectedParticleEmitter;
  38051. /**
  38052. * Called by the GPUParticleSystem to setup the update shader
  38053. * @param effect defines the update shader
  38054. */
  38055. applyToShader(effect: Effect): void;
  38056. /**
  38057. * Returns a string to use to update the GPU particles update shader
  38058. * @returns a string containng the defines string
  38059. */
  38060. getEffectDefines(): string;
  38061. /**
  38062. * Returns the string "SphereDirectedParticleEmitter"
  38063. * @returns a string containing the class name
  38064. */
  38065. getClassName(): string;
  38066. /**
  38067. * Serializes the particle system to a JSON object.
  38068. * @returns the JSON object
  38069. */
  38070. serialize(): any;
  38071. /**
  38072. * Parse properties from a JSON object
  38073. * @param serializationObject defines the JSON object
  38074. */
  38075. parse(serializationObject: any): void;
  38076. }
  38077. }
  38078. declare module BABYLON {
  38079. class CannonJSPlugin implements IPhysicsEnginePlugin {
  38080. private _useDeltaForWorldStep;
  38081. world: any;
  38082. name: string;
  38083. private _physicsMaterials;
  38084. private _fixedTimeStep;
  38085. BJSCANNON: any;
  38086. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  38087. setGravity(gravity: Vector3): void;
  38088. setTimeStep(timeStep: number): void;
  38089. getTimeStep(): number;
  38090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38094. private _processChildMeshes;
  38095. removePhysicsBody(impostor: PhysicsImpostor): void;
  38096. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38097. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38098. private _addMaterial;
  38099. private _checkWithEpsilon;
  38100. private _createShape;
  38101. private _createHeightmap;
  38102. private _minus90X;
  38103. private _plus90X;
  38104. private _tmpPosition;
  38105. private _tmpDeltaPosition;
  38106. private _tmpUnityRotation;
  38107. private _updatePhysicsBodyTransformation;
  38108. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38109. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38110. isSupported(): boolean;
  38111. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38112. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38113. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38114. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38115. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38116. getBodyMass(impostor: PhysicsImpostor): number;
  38117. getBodyFriction(impostor: PhysicsImpostor): number;
  38118. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38119. getBodyRestitution(impostor: PhysicsImpostor): number;
  38120. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38121. sleepBody(impostor: PhysicsImpostor): void;
  38122. wakeUpBody(impostor: PhysicsImpostor): void;
  38123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38124. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  38125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  38126. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38127. getRadius(impostor: PhysicsImpostor): number;
  38128. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38129. dispose(): void;
  38130. private _extendNamespace;
  38131. }
  38132. }
  38133. declare module BABYLON {
  38134. class OimoJSPlugin implements IPhysicsEnginePlugin {
  38135. world: any;
  38136. name: string;
  38137. BJSOIMO: any;
  38138. constructor(iterations?: number);
  38139. setGravity(gravity: Vector3): void;
  38140. setTimeStep(timeStep: number): void;
  38141. getTimeStep(): number;
  38142. private _tmpImpostorsArray;
  38143. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  38144. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38145. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  38146. generatePhysicsBody(impostor: PhysicsImpostor): void;
  38147. private _tmpPositionVector;
  38148. removePhysicsBody(impostor: PhysicsImpostor): void;
  38149. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  38150. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  38151. isSupported(): boolean;
  38152. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  38153. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  38154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  38156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  38158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  38159. getBodyMass(impostor: PhysicsImpostor): number;
  38160. getBodyFriction(impostor: PhysicsImpostor): number;
  38161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  38162. getBodyRestitution(impostor: PhysicsImpostor): number;
  38163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  38164. sleepBody(impostor: PhysicsImpostor): void;
  38165. wakeUpBody(impostor: PhysicsImpostor): void;
  38166. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  38167. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  38168. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  38169. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  38170. getRadius(impostor: PhysicsImpostor): number;
  38171. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  38172. dispose(): void;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * This represents a set of one or more post processes in Babylon.
  38178. * A post process can be used to apply a shader to a texture after it is rendered.
  38179. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38180. */
  38181. class PostProcessRenderEffect {
  38182. private _postProcesses;
  38183. private _getPostProcesses;
  38184. private _singleInstance;
  38185. private _cameras;
  38186. private _indicesForCamera;
  38187. /**
  38188. * Name of the effect
  38189. * @hidden
  38190. */
  38191. _name: string;
  38192. /**
  38193. * Instantiates a post process render effect.
  38194. * A post process can be used to apply a shader to a texture after it is rendered.
  38195. * @param engine The engine the effect is tied to
  38196. * @param name The name of the effect
  38197. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  38198. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  38199. */
  38200. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  38201. /**
  38202. * Checks if all the post processes in the effect are supported.
  38203. */
  38204. readonly isSupported: boolean;
  38205. /**
  38206. * Updates the current state of the effect
  38207. * @hidden
  38208. */
  38209. _update(): void;
  38210. /**
  38211. * Attaches the effect on cameras
  38212. * @param cameras The camera to attach to.
  38213. * @hidden
  38214. */
  38215. _attachCameras(cameras: Camera): void;
  38216. /**
  38217. * Attaches the effect on cameras
  38218. * @param cameras The camera to attach to.
  38219. * @hidden
  38220. */
  38221. _attachCameras(cameras: Camera[]): void;
  38222. /**
  38223. * Detatches the effect on cameras
  38224. * @param cameras The camera to detatch from.
  38225. * @hidden
  38226. */
  38227. _detachCameras(cameras: Camera): void;
  38228. /**
  38229. * Detatches the effect on cameras
  38230. * @param cameras The camera to detatch from.
  38231. * @hidden
  38232. */
  38233. _detachCameras(cameras: Camera[]): void;
  38234. /**
  38235. * Enables the effect on given cameras
  38236. * @param cameras The camera to enable.
  38237. * @hidden
  38238. */
  38239. _enable(cameras: Camera): void;
  38240. /**
  38241. * Enables the effect on given cameras
  38242. * @param cameras The camera to enable.
  38243. * @hidden
  38244. */
  38245. _enable(cameras: Nullable<Camera[]>): void;
  38246. /**
  38247. * Disables the effect on the given cameras
  38248. * @param cameras The camera to disable.
  38249. * @hidden
  38250. */
  38251. _disable(cameras: Camera): void;
  38252. /**
  38253. * Disables the effect on the given cameras
  38254. * @param cameras The camera to disable.
  38255. * @hidden
  38256. */
  38257. _disable(cameras: Nullable<Camera[]>): void;
  38258. /**
  38259. * Gets a list of the post processes contained in the effect.
  38260. * @param camera The camera to get the post processes on.
  38261. * @returns The list of the post processes in the effect.
  38262. */
  38263. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  38264. }
  38265. }
  38266. declare module BABYLON {
  38267. class PostProcessRenderPipeline {
  38268. private engine;
  38269. private _renderEffects;
  38270. private _renderEffectsForIsolatedPass;
  38271. protected _cameras: Camera[];
  38272. /** @hidden */
  38273. _name: string;
  38274. constructor(engine: Engine, name: string);
  38275. getClassName(): string;
  38276. readonly isSupported: boolean;
  38277. addEffect(renderEffect: PostProcessRenderEffect): void;
  38278. /** @hidden */
  38279. _rebuild(): void;
  38280. /** @hidden */
  38281. _enableEffect(renderEffectName: string, cameras: Camera): void;
  38282. /** @hidden */
  38283. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  38284. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38285. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  38286. /** @hidden */
  38287. _attachCameras(cameras: Camera, unique: boolean): void;
  38288. /** @hidden */
  38289. _attachCameras(cameras: Camera[], unique: boolean): void;
  38290. /** @hidden */
  38291. _detachCameras(cameras: Camera): void;
  38292. /** @hidden */
  38293. _detachCameras(cameras: Nullable<Camera[]>): void;
  38294. /** @hidden */
  38295. _update(): void;
  38296. /** @hidden */
  38297. _reset(): void;
  38298. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  38299. dispose(): void;
  38300. }
  38301. }
  38302. declare module BABYLON {
  38303. class PostProcessRenderPipelineManager {
  38304. private _renderPipelines;
  38305. constructor();
  38306. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  38307. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  38308. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  38309. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  38310. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  38311. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38312. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38313. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  38314. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  38315. update(): void;
  38316. /** @hidden */
  38317. _rebuild(): void;
  38318. dispose(): void;
  38319. }
  38320. }
  38321. declare module BABYLON {
  38322. interface Scene {
  38323. /** @hidden (Backing field) */
  38324. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38325. /**
  38326. * Gets the postprocess render pipeline manager
  38327. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  38328. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38329. */
  38330. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  38331. }
  38332. /**
  38333. * Defines the Render Pipeline scene component responsible to rendering pipelines
  38334. */
  38335. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  38336. /**
  38337. * The component name helpfull to identify the component in the list of scene components.
  38338. */
  38339. readonly name: string;
  38340. /**
  38341. * The scene the component belongs to.
  38342. */
  38343. scene: Scene;
  38344. /**
  38345. * Creates a new instance of the component for the given scene
  38346. * @param scene Defines the scene to register the component in
  38347. */
  38348. constructor(scene: Scene);
  38349. /**
  38350. * Registers the component in a given scene
  38351. */
  38352. register(): void;
  38353. /**
  38354. * Rebuilds the elements related to this component in case of
  38355. * context lost for instance.
  38356. */
  38357. rebuild(): void;
  38358. /**
  38359. * Disposes the component and the associated ressources
  38360. */
  38361. dispose(): void;
  38362. private _gatherRenderTargets;
  38363. private _rebuildGeometry;
  38364. }
  38365. }
  38366. declare module BABYLON {
  38367. /**
  38368. * Helper class dealing with the extraction of spherical polynomial dataArray
  38369. * from a cube map.
  38370. */
  38371. class CubeMapToSphericalPolynomialTools {
  38372. private static FileFaces;
  38373. /**
  38374. * Converts a texture to the according Spherical Polynomial data.
  38375. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38376. *
  38377. * @param texture The texture to extract the information from.
  38378. * @return The Spherical Polynomial data.
  38379. */
  38380. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  38381. /**
  38382. * Converts a cubemap to the according Spherical Polynomial data.
  38383. * This extracts the first 3 orders only as they are the only one used in the lighting.
  38384. *
  38385. * @param cubeInfo The Cube map to extract the information from.
  38386. * @return The Spherical Polynomial data.
  38387. */
  38388. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  38389. }
  38390. }
  38391. declare module BABYLON {
  38392. /**
  38393. * Header information of HDR texture files.
  38394. */
  38395. interface HDRInfo {
  38396. /**
  38397. * The height of the texture in pixels.
  38398. */
  38399. height: number;
  38400. /**
  38401. * The width of the texture in pixels.
  38402. */
  38403. width: number;
  38404. /**
  38405. * The index of the beginning of the data in the binary file.
  38406. */
  38407. dataPosition: number;
  38408. }
  38409. /**
  38410. * This groups tools to convert HDR texture to native colors array.
  38411. */
  38412. class HDRTools {
  38413. private static Ldexp;
  38414. private static Rgbe2float;
  38415. private static readStringLine;
  38416. /**
  38417. * Reads header information from an RGBE texture stored in a native array.
  38418. * More information on this format are available here:
  38419. * https://en.wikipedia.org/wiki/RGBE_image_format
  38420. *
  38421. * @param uint8array The binary file stored in native array.
  38422. * @return The header information.
  38423. */
  38424. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  38425. /**
  38426. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  38427. * This RGBE texture needs to store the information as a panorama.
  38428. *
  38429. * More information on this format are available here:
  38430. * https://en.wikipedia.org/wiki/RGBE_image_format
  38431. *
  38432. * @param buffer The binary file stored in an array buffer.
  38433. * @param size The expected size of the extracted cubemap.
  38434. * @return The Cube Map information.
  38435. */
  38436. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  38437. /**
  38438. * Returns the pixels data extracted from an RGBE texture.
  38439. * This pixels will be stored left to right up to down in the R G B order in one array.
  38440. *
  38441. * More information on this format are available here:
  38442. * https://en.wikipedia.org/wiki/RGBE_image_format
  38443. *
  38444. * @param uint8array The binary file stored in an array buffer.
  38445. * @param hdrInfo The header information of the file.
  38446. * @return The pixels data in RGB right to left up to down order.
  38447. */
  38448. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  38449. private static RGBE_ReadPixels_RLE;
  38450. }
  38451. }
  38452. declare module BABYLON {
  38453. /**
  38454. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  38455. */
  38456. interface CubeMapInfo {
  38457. /**
  38458. * The pixel array for the front face.
  38459. * This is stored in format, left to right, up to down format.
  38460. */
  38461. front: Nullable<ArrayBufferView>;
  38462. /**
  38463. * The pixel array for the back face.
  38464. * This is stored in format, left to right, up to down format.
  38465. */
  38466. back: Nullable<ArrayBufferView>;
  38467. /**
  38468. * The pixel array for the left face.
  38469. * This is stored in format, left to right, up to down format.
  38470. */
  38471. left: Nullable<ArrayBufferView>;
  38472. /**
  38473. * The pixel array for the right face.
  38474. * This is stored in format, left to right, up to down format.
  38475. */
  38476. right: Nullable<ArrayBufferView>;
  38477. /**
  38478. * The pixel array for the up face.
  38479. * This is stored in format, left to right, up to down format.
  38480. */
  38481. up: Nullable<ArrayBufferView>;
  38482. /**
  38483. * The pixel array for the down face.
  38484. * This is stored in format, left to right, up to down format.
  38485. */
  38486. down: Nullable<ArrayBufferView>;
  38487. /**
  38488. * The size of the cubemap stored.
  38489. *
  38490. * Each faces will be size * size pixels.
  38491. */
  38492. size: number;
  38493. /**
  38494. * The format of the texture.
  38495. *
  38496. * RGBA, RGB.
  38497. */
  38498. format: number;
  38499. /**
  38500. * The type of the texture data.
  38501. *
  38502. * UNSIGNED_INT, FLOAT.
  38503. */
  38504. type: number;
  38505. /**
  38506. * Specifies whether the texture is in gamma space.
  38507. */
  38508. gammaSpace: boolean;
  38509. }
  38510. /**
  38511. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  38512. */
  38513. class PanoramaToCubeMapTools {
  38514. private static FACE_FRONT;
  38515. private static FACE_BACK;
  38516. private static FACE_RIGHT;
  38517. private static FACE_LEFT;
  38518. private static FACE_DOWN;
  38519. private static FACE_UP;
  38520. /**
  38521. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  38522. *
  38523. * @param float32Array The source data.
  38524. * @param inputWidth The width of the input panorama.
  38525. * @param inputhHeight The height of the input panorama.
  38526. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  38527. * @return The cubemap data
  38528. */
  38529. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  38530. private static CreateCubemapTexture;
  38531. private static CalcProjectionSpherical;
  38532. }
  38533. }
  38534. declare module BABYLON {
  38535. class CustomProceduralTexture extends ProceduralTexture {
  38536. private _animate;
  38537. private _time;
  38538. private _config;
  38539. private _texturePath;
  38540. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38541. private loadJson;
  38542. isReady(): boolean;
  38543. render(useCameraPostProcess?: boolean): void;
  38544. updateTextures(): void;
  38545. updateShaderUniforms(): void;
  38546. animate: boolean;
  38547. }
  38548. }
  38549. declare module BABYLON {
  38550. /**
  38551. * Class used to generate noise procedural textures
  38552. */
  38553. class NoiseProceduralTexture extends ProceduralTexture {
  38554. private _time;
  38555. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  38556. brightness: number;
  38557. /** Defines the number of octaves to process */
  38558. octaves: number;
  38559. /** Defines the level of persistence (0.8 by default) */
  38560. persistence: number;
  38561. /** Gets or sets animation speed factor (default is 1) */
  38562. animationSpeedFactor: number;
  38563. /**
  38564. * Creates a new NoiseProceduralTexture
  38565. * @param name defines the name fo the texture
  38566. * @param size defines the size of the texture (default is 256)
  38567. * @param scene defines the hosting scene
  38568. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  38569. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  38570. */
  38571. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38572. private _updateShaderUniforms;
  38573. /** Generate the current state of the procedural texture */
  38574. render(useCameraPostProcess?: boolean): void;
  38575. /**
  38576. * Serializes this noise procedural texture
  38577. * @returns a serialized noise procedural texture object
  38578. */
  38579. serialize(): any;
  38580. /**
  38581. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  38582. * @param parsedTexture defines parsed texture data
  38583. * @param scene defines the current scene
  38584. * @param rootUrl defines the root URL containing noise procedural texture information
  38585. * @returns a parsed NoiseProceduralTexture
  38586. */
  38587. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  38588. }
  38589. }
  38590. declare module BABYLON {
  38591. class ProceduralTexture extends Texture {
  38592. isCube: boolean;
  38593. private _size;
  38594. /** @hidden */
  38595. _generateMipMaps: boolean;
  38596. isEnabled: boolean;
  38597. private _currentRefreshId;
  38598. private _refreshRate;
  38599. onGenerated: () => void;
  38600. private _vertexBuffers;
  38601. private _indexBuffer;
  38602. private _effect;
  38603. private _uniforms;
  38604. private _samplers;
  38605. private _fragment;
  38606. /** @hidden */
  38607. _textures: {
  38608. [key: string]: Texture;
  38609. };
  38610. private _floats;
  38611. private _ints;
  38612. private _floatsArrays;
  38613. private _colors3;
  38614. private _colors4;
  38615. private _vectors2;
  38616. private _vectors3;
  38617. private _matrices;
  38618. private _fallbackTexture;
  38619. private _fallbackTextureUsed;
  38620. private _engine;
  38621. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  38622. private _createIndexBuffer;
  38623. /** @hidden */
  38624. _rebuild(): void;
  38625. reset(): void;
  38626. isReady(): boolean;
  38627. resetRefreshCounter(): void;
  38628. setFragment(fragment: any): void;
  38629. refreshRate: number;
  38630. /** @hidden */
  38631. _shouldRender(): boolean;
  38632. getRenderSize(): number;
  38633. resize(size: number, generateMipMaps: boolean): void;
  38634. private _checkUniform;
  38635. setTexture(name: string, texture: Texture): ProceduralTexture;
  38636. setFloat(name: string, value: number): ProceduralTexture;
  38637. /**
  38638. * Set the value of an uniform to an integer value
  38639. * @param name defines the name of the uniform
  38640. * @param value defines the value to set
  38641. * @returns the current procedural texture
  38642. */
  38643. setInt(name: string, value: number): ProceduralTexture;
  38644. setFloats(name: string, value: number[]): ProceduralTexture;
  38645. setColor3(name: string, value: Color3): ProceduralTexture;
  38646. setColor4(name: string, value: Color4): ProceduralTexture;
  38647. setVector2(name: string, value: Vector2): ProceduralTexture;
  38648. setVector3(name: string, value: Vector3): ProceduralTexture;
  38649. setMatrix(name: string, value: Matrix): ProceduralTexture;
  38650. render(useCameraPostProcess?: boolean): void;
  38651. clone(): ProceduralTexture;
  38652. dispose(): void;
  38653. }
  38654. }
  38655. declare module BABYLON {
  38656. }
  38657. declare module BABYLON {
  38658. }
  38659. declare module BABYLON {
  38660. }
  38661. declare module BABYLON {
  38662. }
  38663. declare module BABYLON {
  38664. /**
  38665. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  38666. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38667. */
  38668. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38669. private _scene;
  38670. private _camerasToBeAttached;
  38671. /**
  38672. * ID of the sharpen post process,
  38673. */
  38674. private readonly SharpenPostProcessId;
  38675. /**
  38676. * ID of the image processing post process;
  38677. */
  38678. readonly ImageProcessingPostProcessId: string;
  38679. /**
  38680. * ID of the Fast Approximate Anti-Aliasing post process;
  38681. */
  38682. readonly FxaaPostProcessId: string;
  38683. /**
  38684. * ID of the chromatic aberration post process,
  38685. */
  38686. private readonly ChromaticAberrationPostProcessId;
  38687. /**
  38688. * ID of the grain post process
  38689. */
  38690. private readonly GrainPostProcessId;
  38691. /**
  38692. * Sharpen post process which will apply a sharpen convolution to enhance edges
  38693. */
  38694. sharpen: SharpenPostProcess;
  38695. private _sharpenEffect;
  38696. private bloom;
  38697. /**
  38698. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  38699. */
  38700. depthOfField: DepthOfFieldEffect;
  38701. /**
  38702. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  38703. */
  38704. fxaa: FxaaPostProcess;
  38705. /**
  38706. * Image post processing pass used to perform operations such as tone mapping or color grading.
  38707. */
  38708. imageProcessing: ImageProcessingPostProcess;
  38709. /**
  38710. * Chromatic aberration post process which will shift rgb colors in the image
  38711. */
  38712. chromaticAberration: ChromaticAberrationPostProcess;
  38713. private _chromaticAberrationEffect;
  38714. /**
  38715. * Grain post process which add noise to the image
  38716. */
  38717. grain: GrainPostProcess;
  38718. private _grainEffect;
  38719. /**
  38720. * Glow post process which adds a glow to emmisive areas of the image
  38721. */
  38722. private _glowLayer;
  38723. /**
  38724. * Animations which can be used to tweak settings over a period of time
  38725. */
  38726. animations: Animation[];
  38727. private _imageProcessingConfigurationObserver;
  38728. private _sharpenEnabled;
  38729. private _bloomEnabled;
  38730. private _depthOfFieldEnabled;
  38731. private _depthOfFieldBlurLevel;
  38732. private _fxaaEnabled;
  38733. private _imageProcessingEnabled;
  38734. private _defaultPipelineTextureType;
  38735. private _bloomScale;
  38736. private _chromaticAberrationEnabled;
  38737. private _grainEnabled;
  38738. private _buildAllowed;
  38739. /**
  38740. * Enable or disable the sharpen process from the pipeline
  38741. */
  38742. sharpenEnabled: boolean;
  38743. private _resizeObserver;
  38744. private _hardwareScaleLevel;
  38745. private _bloomKernel;
  38746. /**
  38747. * Specifies the size of the bloom blur kernel, relative to the final output size
  38748. */
  38749. bloomKernel: number;
  38750. /**
  38751. * Specifies the weight of the bloom in the final rendering
  38752. */
  38753. private _bloomWeight;
  38754. /**
  38755. * Specifies the luma threshold for the area that will be blurred by the bloom
  38756. */
  38757. private _bloomThreshold;
  38758. private _hdr;
  38759. /**
  38760. * The strength of the bloom.
  38761. */
  38762. bloomWeight: number;
  38763. /**
  38764. * The strength of the bloom.
  38765. */
  38766. bloomThreshold: number;
  38767. /**
  38768. * The scale of the bloom, lower value will provide better performance.
  38769. */
  38770. bloomScale: number;
  38771. /**
  38772. * Enable or disable the bloom from the pipeline
  38773. */
  38774. bloomEnabled: boolean;
  38775. private _rebuildBloom;
  38776. /**
  38777. * If the depth of field is enabled.
  38778. */
  38779. depthOfFieldEnabled: boolean;
  38780. /**
  38781. * Blur level of the depth of field effect. (Higher blur will effect performance)
  38782. */
  38783. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  38784. /**
  38785. * If the anti aliasing is enabled.
  38786. */
  38787. fxaaEnabled: boolean;
  38788. private _samples;
  38789. /**
  38790. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  38791. */
  38792. samples: number;
  38793. /**
  38794. * If image processing is enabled.
  38795. */
  38796. imageProcessingEnabled: boolean;
  38797. /**
  38798. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  38799. */
  38800. glowLayerEnabled: boolean;
  38801. /**
  38802. * Enable or disable the chromaticAberration process from the pipeline
  38803. */
  38804. chromaticAberrationEnabled: boolean;
  38805. /**
  38806. * Enable or disable the grain process from the pipeline
  38807. */
  38808. grainEnabled: boolean;
  38809. /**
  38810. * @constructor
  38811. * @param {string} name - The rendering pipeline name (default: "")
  38812. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  38813. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  38814. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  38815. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  38816. */
  38817. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  38818. /**
  38819. * Force the compilation of the entire pipeline.
  38820. */
  38821. prepare(): void;
  38822. private _hasCleared;
  38823. private _prevPostProcess;
  38824. private _prevPrevPostProcess;
  38825. private _setAutoClearAndTextureSharing;
  38826. private _buildPipeline;
  38827. private _disposePostProcesses;
  38828. /**
  38829. * Adds a camera to the pipeline
  38830. * @param camera the camera to be added
  38831. */
  38832. addCamera(camera: Camera): void;
  38833. /**
  38834. * Removes a camera from the pipeline
  38835. * @param camera the camera to remove
  38836. */
  38837. removeCamera(camera: Camera): void;
  38838. /**
  38839. * Dispose of the pipeline and stop all post processes
  38840. */
  38841. dispose(): void;
  38842. /**
  38843. * Serialize the rendering pipeline (Used when exporting)
  38844. * @returns the serialized object
  38845. */
  38846. serialize(): any;
  38847. /**
  38848. * Parse the serialized pipeline
  38849. * @param source Source pipeline.
  38850. * @param scene The scene to load the pipeline to.
  38851. * @param rootUrl The URL of the serialized pipeline.
  38852. * @returns An instantiated pipeline from the serialized object.
  38853. */
  38854. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. class LensRenderingPipeline extends PostProcessRenderPipeline {
  38859. /**
  38860. * The chromatic aberration PostProcess id in the pipeline
  38861. */
  38862. LensChromaticAberrationEffect: string;
  38863. /**
  38864. * The highlights enhancing PostProcess id in the pipeline
  38865. */
  38866. HighlightsEnhancingEffect: string;
  38867. /**
  38868. * The depth-of-field PostProcess id in the pipeline
  38869. */
  38870. LensDepthOfFieldEffect: string;
  38871. private _scene;
  38872. private _depthTexture;
  38873. private _grainTexture;
  38874. private _chromaticAberrationPostProcess;
  38875. private _highlightsPostProcess;
  38876. private _depthOfFieldPostProcess;
  38877. private _edgeBlur;
  38878. private _grainAmount;
  38879. private _chromaticAberration;
  38880. private _distortion;
  38881. private _highlightsGain;
  38882. private _highlightsThreshold;
  38883. private _dofDistance;
  38884. private _dofAperture;
  38885. private _dofDarken;
  38886. private _dofPentagon;
  38887. private _blurNoise;
  38888. /**
  38889. * @constructor
  38890. *
  38891. * Effect parameters are as follow:
  38892. * {
  38893. * chromatic_aberration: number; // from 0 to x (1 for realism)
  38894. * edge_blur: number; // from 0 to x (1 for realism)
  38895. * distortion: number; // from 0 to x (1 for realism)
  38896. * grain_amount: number; // from 0 to 1
  38897. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  38898. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  38899. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  38900. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  38901. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  38902. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  38903. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  38904. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  38905. * }
  38906. * Note: if an effect parameter is unset, effect is disabled
  38907. *
  38908. * @param {string} name - The rendering pipeline name
  38909. * @param {object} parameters - An object containing all parameters (see above)
  38910. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38911. * @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)
  38912. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38913. */
  38914. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  38915. setEdgeBlur(amount: number): void;
  38916. disableEdgeBlur(): void;
  38917. setGrainAmount(amount: number): void;
  38918. disableGrain(): void;
  38919. setChromaticAberration(amount: number): void;
  38920. disableChromaticAberration(): void;
  38921. setEdgeDistortion(amount: number): void;
  38922. disableEdgeDistortion(): void;
  38923. setFocusDistance(amount: number): void;
  38924. disableDepthOfField(): void;
  38925. setAperture(amount: number): void;
  38926. setDarkenOutOfFocus(amount: number): void;
  38927. enablePentagonBokeh(): void;
  38928. disablePentagonBokeh(): void;
  38929. enableNoiseBlur(): void;
  38930. disableNoiseBlur(): void;
  38931. setHighlightsGain(amount: number): void;
  38932. setHighlightsThreshold(amount: number): void;
  38933. disableHighlights(): void;
  38934. /**
  38935. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  38936. */
  38937. dispose(disableDepthRender?: boolean): void;
  38938. private _createChromaticAberrationPostProcess;
  38939. private _createHighlightsPostProcess;
  38940. private _createDepthOfFieldPostProcess;
  38941. private _createGrainTexture;
  38942. }
  38943. }
  38944. declare module BABYLON {
  38945. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  38946. /**
  38947. * The PassPostProcess id in the pipeline that contains the original scene color
  38948. */
  38949. SSAOOriginalSceneColorEffect: string;
  38950. /**
  38951. * The SSAO PostProcess id in the pipeline
  38952. */
  38953. SSAORenderEffect: string;
  38954. /**
  38955. * The horizontal blur PostProcess id in the pipeline
  38956. */
  38957. SSAOBlurHRenderEffect: string;
  38958. /**
  38959. * The vertical blur PostProcess id in the pipeline
  38960. */
  38961. SSAOBlurVRenderEffect: string;
  38962. /**
  38963. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38964. */
  38965. SSAOCombineRenderEffect: string;
  38966. /**
  38967. * The output strength of the SSAO post-process. Default value is 1.0.
  38968. */
  38969. totalStrength: number;
  38970. /**
  38971. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  38972. */
  38973. maxZ: number;
  38974. /**
  38975. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  38976. */
  38977. minZAspect: number;
  38978. private _samples;
  38979. /**
  38980. * Number of samples used for the SSAO calculations. Default value is 8
  38981. */
  38982. samples: number;
  38983. private _textureSamples;
  38984. /**
  38985. * Number of samples to use for antialiasing
  38986. */
  38987. textureSamples: number;
  38988. /**
  38989. * Ratio object used for SSAO ratio and blur ratio
  38990. */
  38991. private _ratio;
  38992. /**
  38993. * Dynamically generated sphere sampler.
  38994. */
  38995. private _sampleSphere;
  38996. /**
  38997. * Blur filter offsets
  38998. */
  38999. private _samplerOffsets;
  39000. /**
  39001. * Are we using bilateral blur ?
  39002. */
  39003. private _expensiveBlur;
  39004. expensiveBlur: boolean;
  39005. /**
  39006. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  39007. */
  39008. radius: number;
  39009. /**
  39010. * The base color of the SSAO post-process
  39011. * The final result is "base + ssao" between [0, 1]
  39012. */
  39013. base: number;
  39014. /**
  39015. * Support test.
  39016. */
  39017. static readonly IsSupported: boolean;
  39018. private _scene;
  39019. private _depthTexture;
  39020. private _normalTexture;
  39021. private _randomTexture;
  39022. private _originalColorPostProcess;
  39023. private _ssaoPostProcess;
  39024. private _blurHPostProcess;
  39025. private _blurVPostProcess;
  39026. private _ssaoCombinePostProcess;
  39027. private _firstUpdate;
  39028. /**
  39029. * @constructor
  39030. * @param {string} name - The rendering pipeline name
  39031. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39032. * @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 }
  39033. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39034. */
  39035. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39036. /**
  39037. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39038. */
  39039. dispose(disableGeometryBufferRenderer?: boolean): void;
  39040. private _createBlurPostProcess;
  39041. /** @hidden */
  39042. _rebuild(): void;
  39043. private _bits;
  39044. private _radicalInverse_VdC;
  39045. private _hammersley;
  39046. private _hemisphereSample_uniform;
  39047. private _generateHemisphere;
  39048. private _createSSAOPostProcess;
  39049. private _createSSAOCombinePostProcess;
  39050. private _createRandomTexture;
  39051. /**
  39052. * Serialize the rendering pipeline (Used when exporting)
  39053. * @returns the serialized object
  39054. */
  39055. serialize(): any;
  39056. /**
  39057. * Parse the serialized pipeline
  39058. * @param source Source pipeline.
  39059. * @param scene The scene to load the pipeline to.
  39060. * @param rootUrl The URL of the serialized pipeline.
  39061. * @returns An instantiated pipeline from the serialized object.
  39062. */
  39063. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  39064. }
  39065. }
  39066. declare module BABYLON {
  39067. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  39068. /**
  39069. * The PassPostProcess id in the pipeline that contains the original scene color
  39070. */
  39071. SSAOOriginalSceneColorEffect: string;
  39072. /**
  39073. * The SSAO PostProcess id in the pipeline
  39074. */
  39075. SSAORenderEffect: string;
  39076. /**
  39077. * The horizontal blur PostProcess id in the pipeline
  39078. */
  39079. SSAOBlurHRenderEffect: string;
  39080. /**
  39081. * The vertical blur PostProcess id in the pipeline
  39082. */
  39083. SSAOBlurVRenderEffect: string;
  39084. /**
  39085. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  39086. */
  39087. SSAOCombineRenderEffect: string;
  39088. /**
  39089. * The output strength of the SSAO post-process. Default value is 1.0.
  39090. */
  39091. totalStrength: number;
  39092. /**
  39093. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  39094. */
  39095. radius: number;
  39096. /**
  39097. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  39098. * Must not be equal to fallOff and superior to fallOff.
  39099. * Default value is 0.975
  39100. */
  39101. area: number;
  39102. /**
  39103. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  39104. * Must not be equal to area and inferior to area.
  39105. * Default value is 0.0
  39106. */
  39107. fallOff: number;
  39108. /**
  39109. * The base color of the SSAO post-process
  39110. * The final result is "base + ssao" between [0, 1]
  39111. */
  39112. base: number;
  39113. private _scene;
  39114. private _depthTexture;
  39115. private _randomTexture;
  39116. private _originalColorPostProcess;
  39117. private _ssaoPostProcess;
  39118. private _blurHPostProcess;
  39119. private _blurVPostProcess;
  39120. private _ssaoCombinePostProcess;
  39121. private _firstUpdate;
  39122. /**
  39123. * @constructor
  39124. * @param {string} name - The rendering pipeline name
  39125. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39126. * @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 }
  39127. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39128. */
  39129. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  39130. /**
  39131. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  39132. */
  39133. dispose(disableDepthRender?: boolean): void;
  39134. private _createBlurPostProcess;
  39135. /** @hidden */
  39136. _rebuild(): void;
  39137. private _createSSAOPostProcess;
  39138. private _createSSAOCombinePostProcess;
  39139. private _createRandomTexture;
  39140. }
  39141. }
  39142. declare module BABYLON {
  39143. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  39144. /**
  39145. * Public members
  39146. */
  39147. originalPostProcess: Nullable<PostProcess>;
  39148. downSampleX4PostProcess: Nullable<PostProcess>;
  39149. brightPassPostProcess: Nullable<PostProcess>;
  39150. blurHPostProcesses: PostProcess[];
  39151. blurVPostProcesses: PostProcess[];
  39152. textureAdderPostProcess: Nullable<PostProcess>;
  39153. volumetricLightPostProcess: Nullable<PostProcess>;
  39154. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  39155. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  39156. volumetricLightMergePostProces: Nullable<PostProcess>;
  39157. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  39158. luminancePostProcess: Nullable<PostProcess>;
  39159. luminanceDownSamplePostProcesses: PostProcess[];
  39160. hdrPostProcess: Nullable<PostProcess>;
  39161. textureAdderFinalPostProcess: Nullable<PostProcess>;
  39162. lensFlareFinalPostProcess: Nullable<PostProcess>;
  39163. hdrFinalPostProcess: Nullable<PostProcess>;
  39164. lensFlarePostProcess: Nullable<PostProcess>;
  39165. lensFlareComposePostProcess: Nullable<PostProcess>;
  39166. motionBlurPostProcess: Nullable<PostProcess>;
  39167. depthOfFieldPostProcess: Nullable<PostProcess>;
  39168. brightThreshold: number;
  39169. blurWidth: number;
  39170. horizontalBlur: boolean;
  39171. exposure: number;
  39172. lensTexture: Nullable<Texture>;
  39173. volumetricLightCoefficient: number;
  39174. volumetricLightPower: number;
  39175. volumetricLightBlurScale: number;
  39176. sourceLight: Nullable<SpotLight | DirectionalLight>;
  39177. hdrMinimumLuminance: number;
  39178. hdrDecreaseRate: number;
  39179. hdrIncreaseRate: number;
  39180. lensColorTexture: Nullable<Texture>;
  39181. lensFlareStrength: number;
  39182. lensFlareGhostDispersal: number;
  39183. lensFlareHaloWidth: number;
  39184. lensFlareDistortionStrength: number;
  39185. lensStarTexture: Nullable<Texture>;
  39186. lensFlareDirtTexture: Nullable<Texture>;
  39187. depthOfFieldDistance: number;
  39188. depthOfFieldBlurWidth: number;
  39189. motionStrength: number;
  39190. animations: Animation[];
  39191. /**
  39192. * Private members
  39193. */
  39194. private _scene;
  39195. private _currentDepthOfFieldSource;
  39196. private _basePostProcess;
  39197. private _hdrCurrentLuminance;
  39198. private _floatTextureType;
  39199. private _ratio;
  39200. private _bloomEnabled;
  39201. private _depthOfFieldEnabled;
  39202. private _vlsEnabled;
  39203. private _lensFlareEnabled;
  39204. private _hdrEnabled;
  39205. private _motionBlurEnabled;
  39206. private _motionBlurSamples;
  39207. private _volumetricLightStepsCount;
  39208. BloomEnabled: boolean;
  39209. DepthOfFieldEnabled: boolean;
  39210. LensFlareEnabled: boolean;
  39211. HDREnabled: boolean;
  39212. VLSEnabled: boolean;
  39213. MotionBlurEnabled: boolean;
  39214. volumetricLightStepsCount: number;
  39215. motionBlurSamples: number;
  39216. /**
  39217. * @constructor
  39218. * @param {string} name - The rendering pipeline name
  39219. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  39220. * @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)
  39221. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  39222. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  39223. */
  39224. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  39225. private _buildPipeline;
  39226. private _createDownSampleX4PostProcess;
  39227. private _createBrightPassPostProcess;
  39228. private _createBlurPostProcesses;
  39229. private _createTextureAdderPostProcess;
  39230. private _createVolumetricLightPostProcess;
  39231. private _createLuminancePostProcesses;
  39232. private _createHdrPostProcess;
  39233. private _createLensFlarePostProcess;
  39234. private _createDepthOfFieldPostProcess;
  39235. private _createMotionBlurPostProcess;
  39236. private _getDepthTexture;
  39237. private _disposePostProcesses;
  39238. /**
  39239. * Dispose of the pipeline and stop all post processes
  39240. */
  39241. dispose(): void;
  39242. /**
  39243. * Serialize the rendering pipeline (Used when exporting)
  39244. * @returns the serialized object
  39245. */
  39246. serialize(): any;
  39247. /**
  39248. * Parse the serialized pipeline
  39249. * @param source Source pipeline.
  39250. * @param scene The scene to load the pipeline to.
  39251. * @param rootUrl The URL of the serialized pipeline.
  39252. * @returns An instantiated pipeline from the serialized object.
  39253. */
  39254. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  39255. static LuminanceSteps: number;
  39256. }
  39257. }